use of alma.alarmsystem.source.ACSFaultState in project ACS by ACS-Community.
the class MultiSourceStressTest method send.
/**
* Send a fault state to the NC.
* It uses the global source or build a new one depending on the
* parameter
*
* @param mfs The fault state to publish
* @param sameSource If true the same source is used to send the alarm
* if true a new source is built and the fault state is
* sent using this new source
*/
private void send(MiniFaultState mfs, boolean sameSource) throws Exception {
assertNotNull(mfs);
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(mfs.FF, mfs.FM, mfs.FC);
assertNotNull("Error instantiating the FS", fs);
fs.setDescriptor(mfs.description);
fs.setUserTimestamp(mfs.timestamp);
if (sameSource) {
alarmSource.push(fs);
} else {
ACSAlarmSystemInterface newSource = ACSAlarmSystemInterfaceFactory.createSource();
assertNotNull(newSource);
newSource.push(fs);
}
}
use of alma.alarmsystem.source.ACSFaultState in project ACS by ACS-Community.
the class ObjectsTest method testFaultStateType.
public void testFaultStateType() throws Exception {
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(faultFamily, faultMember, faultCode);
String descriptor = "A description for this FS";
assertNotNull("Error creting the FS", fs);
assertTrue("The FS has wrong class type", fs instanceof FaultStateImpl);
assertEquals("Wrong FF", faultFamily, fs.getFamily());
assertEquals("Wrong FM", faultMember, fs.getMember());
assertEquals("Wrong FC", faultCode, new Integer(fs.getCode()));
fs.setDescriptor(descriptor);
assertEquals("Wrong descriptor", descriptor, fs.getDescriptor());
}
use of alma.alarmsystem.source.ACSFaultState in project ACS by ACS-Community.
the class AlarmSender method sendSynch.
/**
* Synchronously publishes the specified alarm in the source NC.
* <P>
* Sending alarms through this method should be generally avoided, preferring
* {@link #send(Triplet, AlarmDescriptorType, Properties)} instead.
*
* @param triplet The triplet in the form FF,FM,FC
* @param The descriptor
* @param props The user properties
* @throws FaultStateCreationErrorEx
* @throws ACSASFactoryNotInitedEx
*/
protected void sendSynch(Triplet triplet, AlarmDescriptorType descriptor, Properties props) {
if (triplet == null) {
throw new IllegalArgumentException("The Triplet can't be null");
}
if (descriptor == null) {
throw new IllegalArgumentException("The descriptor can't be null");
}
if (closed) {
return;
}
logger.log(AcsLogLevel.DELOUSE, "Sending alarm " + triplet.toString() + " with descriptor " + descriptor);
ACSFaultState state = null;
try {
state = ACSAlarmSystemInterfaceFactory.createFaultState(triplet.faultFamily, triplet.faultMember, triplet.faultCode);
} catch (Throwable t) {
notifyListeners(triplet, descriptor, false);
logger.log(AcsLogLevel.ERROR, "Alarm " + triplet.toString() + " sent with descriptor " + descriptor, t);
return;
}
state.setDescriptor(descriptor.descriptor);
state.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
if (props != null && !props.isEmpty()) {
state.setUserProperties(props);
}
alarmSource.push(state);
notifyListeners(triplet, descriptor, true);
logger.log(AcsLogLevel.DELOUSE, "Alarm " + triplet.toString() + " sent");
}
use of alma.alarmsystem.source.ACSFaultState in project ACS by ACS-Community.
the class AlarmSender method sendAlarm.
/**
* Send an alarm with user properties
*
* @param FF The fault family
* @param FM The fault member
* @param FC The fault code
* @param properties The properties (can be <code>null</code> or empty)
* @param active If <code>true</code> the alarm is activated otherwise it is terminated
*/
public void sendAlarm(String FF, String FM, int FC, Properties properties, boolean active) {
if (closed) {
StringBuilder str = new StringBuilder("Alarm factory closed alarm sending disabled");
containerServices.getLogger().log(AcsLogLevel.WARNING, str.toString());
return;
}
if (source == null) {
try {
init();
} catch (Throwable t) {
containerServices.getLogger().log(AcsLogLevel.ERROR, "Error initializing the alarm service structs", t);
// @TODO (hso): return? exception? Otherwise NPE from source.push below
}
}
if (properties == null) {
properties = emptyProps;
}
try {
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(FF, FM, FC);
if (active) {
fs.setDescriptor(ACSFaultState.ACTIVE);
} else {
fs.setDescriptor(ACSFaultState.TERMINATE);
}
fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
fs.setUserProperties(properties);
source.push(fs);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations