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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#include <maciSimpleClient.h> #include <acsncSimpleSupplier.h> #include <ExampleEventC.h> int main(int argc, char *argv[]) { maci::SimpleClient client; if (client.init(argc,argv) == 0) { return -1; } else { client.login(); } workshop::ExampleEvent event; event.msg ="Example Supplier"; event.value = 10; sup = new nc::SimpleSupplier(workshop::CHANNELNAME_EXAMPLE, NULL); sup->publishData<workshop::ExampleEvent>(event); sup.disconnect() client.logout(); ACE_OS::sleep(3); return 0; } |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package ...;
import java.util.logging.Logger;
import alma.acs.nc.AcsEventSubscriber;
import alma.acs.component.client.ComponentClient;
import alma.workshop.ExampleEvent;
import alma.workshop.CHANNELNAME_EXAMPLE;
public class ExampleEventConsumer extends ComponentClient implements AcsEventSubscriber.Callback<ExampleEvent> {
private Logger m_logger;
public ExampleEventConsumer() {
String managerLoc = System.getProperty("ACS.manager");
super(null, managerLoc, clientName);
m_logger = getContainerServices().getLogger()
}
public doStuff() {
ExampleEvent event = new ExampleEvent("Example Supplier", 10);
AcsEventSubscriber<ExampleEvent> con = getContainerServices().createNotificationChannelSubscriber(CHANNELNAME_EXAMPLE.value, ExampleEvent.class);
con.addSubscription(this);
con.startReceivingEvents();
Thread.sleep(10);
con.disconnect();
}
public void receive(ExampleEvent event, EventDescription desc) {
m_logger.info("New messsage received: " + event)
m_logger.info(event.msg)
m_logger.info(event.value)
}
public static void main(String[] args) {
ExampleEventSupplier client = new ExampleEventSupplier();
client.doStuff();
}
} |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import#include time<maciSimpleClient.h> import workshop from Acspy.Nc.Consumer import Consumer def eventHandler(event):#include <acsncSimpleConsumer.h> #include <ExampleEventC.h> void eventHandler(workshop::ExampleEvent event, void* handlerParam) { print(ACS_SHORT_LOG((LM_INFO, "New messsage received: " + str(event)))); ACS_SHORT_LOG((LM_INFO, "event.msg: ->%s<-", event.msg.in())); print(event.msg) print(event.value) g = Consumer(workshop.CHANNELNAME_EXAMPLE) g.addSubscription(workshop.ExampleEvent, eventHandler) g.consumerReady() time.sleep(10) g.disconnect()ACS_SHORT_LOG((LM_INFO, "event.value: ->%d<-", event.value)); } int main(int argc, char *argv[]) { maci::SimpleClient client; if (client.init(argc,argv) == 0) { return -1; } else { client.login(); } con = new nc::SimpleConsumer<workshop::ExampleEvent>(workshop::CHANNELNAME_EXAMPLE, ""); con->addSubscription<workshop::ExampleEvent>(eventHandler, NULL); con->consumerReady(); ACE_Time_Value tv(10); client.run(tv); con.disconnect() client.logout(); ACE_OS::sleep(3); return 0; } |