Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
... <e Name="ComponentCallerAPI" Code="acs.ComponentCallerAPI" Type="IDL:alma/ACS/ACSComponent:1.0" Container="aragornContainer" ImplLang="py" Autostart="true"/> ... |
Interact with a component using curl. For instance to retrieve name and componentState attributes:
Code Block | ||
---|---|---|
| ||
> curl -XPOST http://127.0.0.1:9000/ -d'{"componentName": "EventConverter", "methodName": "_get_name", "arguments": {}}'
{"data": "EventConverter"}
> curl -XPOST http://127.0.0.1:9000/ -d'{"componentName": "EventConverter", "methodName": "_get_componentState", "arguments": {}}'
{"data": {"meta": {"type": "omniORB.EnumItem"}, "data": {"_n": "COMPSTATE_OPERATIONAL", "_v": 3, "_parent_id": "IDL:alma/ACS/ComponentStates:1.0"}}} |
Install redis
Code Block | ||
---|---|---|
| ||
> sudo yum install redis |
Component Configuration
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
...
<e
Name="EventConverter"
Code="acs.EventConverter"
Type="IDL:alma/ACS/ACSComponent:1.0"
Container="aragornContainer"
ImplLang="py"
Autostart="true"/>
... |
XMLDoc
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
<EventConverter xmlns="urn:schemas-cosylab-com:EventConverter:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RedisConn host="localhost" port="6379"/>
<PubSub>
<Channel name=" |
...
example"> <EventType type=" |
...
workshop. |
...
ExampleEvent"/> </Channel> </PubSub> <ReliableSubscribers> <Subscriber name=" |
...
example" queueLimit="20"> <Channel name=" |
...
example"> <EventType type=" |
...
workshop. |
...
ExampleEvent"/> </Channel> </Subscriber> </ReliableSubscribers> </EventConverter> |
IDL Event Definition
Code Block |
---|
#ifndef _ExampleEvent_IDL_
#define _ExampleEvent_IDL_
#pragma prefix "alma"
module workshop {
const string CHANNELNAME_EXAMPLE = "example";
struct ExampleEvent {
string msg;
long value;
};
};
#endif |
Start redis-server
Code Block | ||
---|---|---|
| ||
> redis-server |
Send events with ExampleSupplier.py
Code Block |
---|
import workshop
from Acspy.Nc.Supplier import Supplier
event = workshop.ExampleEvent("Example Supplier", 10)
sup = Supplier(workshop.CHANNELNAME_EXAMPLE)
sup.publishEvent(simple_data=event)
sup.disconnect() |
Check Redis
Code Block |
---|
> redis-cli #Get all queues 127.0.0.1:6379> keys * 1) "example" #Check elements of ' |
...
example' queue 127.0.0.1:6379> LRANGE |
...
example 0 -1 1) "{\"meta\": {\"type\": \"workshop.ExampleEvent\"}, \"data\": {\"msg\": \"Example Supplier\", \"value\": 10}}" |