use of org.omg.CosNotification.StructuredEvent in project ACS by ACS-Community.
the class EventDetailTestHarness method parsePttDataEvent.
public static ParsedAnyData[] parsePttDataEvent() {
pttDataEvent pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
StructuredEvent se = null;
String eventName = null;
Any eventAny = null;
try {
se = seCreator.createEvent(pde);
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
} catch (AcsJException e) {
e.printStackTrace();
System.err.println("Couldn't create structured event for pttDataEvent");
}
StopWatch sw = new StopWatch(logger);
DynAnyParser parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
use of org.omg.CosNotification.StructuredEvent in project ACS by ACS-Community.
the class StructuredEventCreator method getCORBAEvent.
/**
* Method used to create a pre-filled CORBA event.
*
* @param typeName
* The structured event's type_name.
* @param eventName
* Name of the event.
* @return A pre-filled CORBA event.
*/
private StructuredEvent getCORBAEvent(String typeName, String eventName) {
// return value
StructuredEvent event = new StructuredEvent();
// event.header.fixed_header.event_type
String channelDomain = alma.acscommon.ALMADOMAIN.value;
EventType event_type = new EventType(channelDomain, typeName);
//
FixedEventHeader fixed_header = new FixedEventHeader(event_type, eventName);
// event.header.variable_header
Property[] variable_header = new Property[0];
// event.header
event.header = new EventHeader(fixed_header, variable_header);
return event;
}
use of org.omg.CosNotification.StructuredEvent in project ACS by ACS-Community.
the class StructuredEventCreator method createEvent.
public StructuredEvent createEvent(IDLEntity customStruct) throws AcsJException {
// The Java class name without package becomes the name of the "event type".
String typeName = customStruct.getClass().getName().substring(customStruct.getClass().getName().lastIndexOf('.') + 1);
// event to send
StructuredEvent event = getCORBAEvent(typeName, "");
// Store the info for Exec/I&T into the event.
// create the any
event.remainder_of_body = m_services.getAdvancedContainerServices().getAny();
// get the useful data which includes the component's name, timestamp, and event count (=1 here)
EventDescription descrip = new EventDescription(m_services.getName(), alma.acs.util.UTCUtility.utcJavaToOmg(System.currentTimeMillis()), 1);
// store the IDL struct into the structured event
EventDescriptionHelper.insert(event.remainder_of_body, descrip);
// preallocate one name/value pair
event.filterable_data = new Property[1];
event.filterable_data[0] = new Property(alma.acscommon.DEFAULTDATANAME.value, m_anyAide.complexObjectToCorbaAny(customStruct));
return event;
}
use of org.omg.CosNotification.StructuredEvent in project ACS by ACS-Community.
the class NCPublisher method getCORBAEvent.
/**
* Method used to create a pre-filled CORBA event.
*
* @param typeName
* The structured event's type_name.
* @param eventName
* Name of the event.
* @return A pre-filled CORBA event.
*/
protected StructuredEvent getCORBAEvent(String typeName, String eventName) {
// return value
StructuredEvent event = new StructuredEvent();
// event.header.fixed_header.event_type
String channelDomain = alma.acscommon.ALMADOMAIN.value;
EventType event_type = new EventType(channelDomain, typeName);
FixedEventHeader fixed_header = new FixedEventHeader(event_type, eventName);
// event.header.variable_header
Property[] variable_header = new Property[0];
// event.header
event.header = new EventHeader(fixed_header, variable_header);
return event;
}
use of org.omg.CosNotification.StructuredEvent in project ACS by ACS-Community.
the class NCPublisher method publishEvent.
/**
* Takes the given Java object and tries to pack it into a CORBA Any and
* publish it to the notification channel.
* This will fail if the parameter is not
* CORBA-generated from a user-defined IDL struct. In simple terms, trying
* to publish native Java types is impossible because they have no CORBA
* mapping to say Python or C++ types.
*
* @param customStruct
* An instance of the IDL struct (Java class) to be published.
* @throws AcsJPublishEventFailureEx If <code>customStruct</code> is not an IDL struct,
* for which it must be a subclass of IDLEntity.
* @throws AcsJException
* There are an enormous amount of possibilities pertaining to
* why an AcsJException would be thrown by publishEvent.
*/
@Override
public void publishEvent(T customStruct) throws AcsJException {
// Let's first verify that the use of generics between base class and here is OK also for the DDS side.
if (!(customStruct instanceof IDLEntity)) {
String msg = "ACS is using Corba NC as the underlying pub/sub framework. Event data must be IDL-defined structs that inherit from org.omg.CORBA.portable.IDLEntity.";
AcsJPublishEventFailureEx ex = new AcsJPublishEventFailureEx();
ex.setFailureDescription(msg);
ex.setChannelName(channelName);
ex.setEventName(customStruct.getClass().getName());
throw ex;
}
IDLEntity customStructEntity = (IDLEntity) customStruct;
String typeName = customStructEntity.getClass().getSimpleName();
// Event to send
// Header: domain_name = "ALMA", type_name = simple name of IDL struct, event_name = ""
StructuredEvent event = getCORBAEvent(typeName, "");
// Send event meta data (client name, timestamp, counter) in the accompanying EventDescription object,
// which we transmit as the Any field 'remainder_of_body'.
event.remainder_of_body = services.getAdvancedContainerServices().getAny();
EventDescription descrip = new EventDescription(services.getName(), alma.acs.util.UTCUtility.utcJavaToOmg(System.currentTimeMillis()), count.getAndIncrement());
EventDescriptionHelper.insert(event.remainder_of_body, descrip);
// In the 'filterable_data' field, we send our IDL struct coded as an Any
event.filterable_data = new Property[1];
event.filterable_data[0] = new Property(alma.acscommon.DEFAULTDATANAME.value, anyAide.complexObjectToCorbaAny(customStructEntity));
// Check the queue for events from previous failures.
synchronized (eventQueueSync) {
if (eventQueue != null) {
CircularQueue<T>.Data<T> tmp;
try {
while ((tmp = eventQueue.pop()) != null) {
publishCORBAEvent(tmp.corbaData, tmp.userData);
}
} catch (Exception ex) {
Level lev = (isTraceEventsEnabled ? Level.INFO : Level.FINEST);
logger.log(lev, "Failed to flush event queue.", ex);
// go on and try to send the new event, to at least have it inserted into the queue.
}
}
}
try {
publishCORBAEvent(event, customStruct);
} catch (AcsJCORBAProblemEx ex) {
String info = ex.getInfo();
if (false == info.contains("org.omg.CORBA.TRANSIENT")) {
throw ex;
}
}
}
Aggregations