Search in sources :

Example 1 with FaultState

use of cern.laser.source.alarmsysteminterface.impl.message.FaultState in project ACS by ACS-Community.

the class LaserComponent method buildMessage.

/**
	 * Build the {@link ACSJMSTextMessage} for a given fault state
	 * 
	 * @param state The fault state
	 * @param hostName The host name
	 * 
	 * @see AlarmSystemInterfaceProxy#publish
	 */
private TextMessage buildMessage(cern.laser.source.alarmsysteminterface.impl.message.FaultState state, String hostName, String sourceName) throws Exception {
    if (state == null) {
        throw new IllegalArgumentException("The fault state can't be null");
    }
    if (hostName == null || hostName.isEmpty()) {
        throw new IllegalArgumentException("Invalid host name");
    }
    if (sourceName == null || sourceName.isEmpty()) {
        throw new IllegalArgumentException("Invalid source name");
    }
    Collection<FaultStateImpl> tempStates = new Vector<FaultStateImpl>();
    cern.laser.source.alarmsysteminterface.impl.message.FaultState tempState = new FaultState();
    ASIMessage asi_message = ASIMessageHelper.marshal(tempStates);
    FaultStates states = new FaultStates();
    states.addFaultState(state);
    asi_message.setFaultStates(states);
    asi_message.setSourceName("ALARM_SYSTEM_SOURCES");
    asi_message.setSourceHostname(hostName);
    asi_message.setSourceTimestamp(IsoDateFormat.formatCurrentDate());
    asi_message.setBackup(false);
    Configurator configurator = new Configurator();
    ASIConfiguration configuration = configurator.getConfiguration();
    asi_message.setVersion(configuration.getASIVersion());
    ACSJMSTextMessage tm = new ACSJMSTextMessage(alSysContSvcs);
    tm.setText(XMLMessageHelper.marshal(asi_message));
    tm.setStringProperty(configuration.getSourceNameProperty(), sourceName);
    tm.setStringProperty(configuration.getSourceHostnameProperty(), hostName);
    tm.setStringProperty(configuration.getBackupProperty(), String.valueOf(false));
    tm.setStringProperty(configuration.getAlarmsNumberProperty(), String.valueOf(1));
    return tm;
}
Also used : ASIConfiguration(cern.laser.source.alarmsysteminterface.impl.configuration.ASIConfiguration) FaultStates(cern.laser.source.alarmsysteminterface.impl.message.FaultStates) Configurator(cern.laser.source.alarmsysteminterface.impl.Configurator) ACSFaultState(alma.alarmsystem.source.ACSFaultState) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) LaserCoreFaultState(alma.alarmsystem.core.alarms.LaserCoreFaultState) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) FaultStateImpl(cern.laser.source.alarmsysteminterface.impl.FaultStateImpl) Vector(java.util.Vector) ASIMessage(cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)

Aggregations

LaserCoreFaultState (alma.alarmsystem.core.alarms.LaserCoreFaultState)1 ACSFaultState (alma.alarmsystem.source.ACSFaultState)1 Configurator (cern.laser.source.alarmsysteminterface.impl.Configurator)1 FaultStateImpl (cern.laser.source.alarmsysteminterface.impl.FaultStateImpl)1 ASIConfiguration (cern.laser.source.alarmsysteminterface.impl.configuration.ASIConfiguration)1 ASIMessage (cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)1 FaultState (cern.laser.source.alarmsysteminterface.impl.message.FaultState)1 FaultStates (cern.laser.source.alarmsysteminterface.impl.message.FaultStates)1 ACSJMSTextMessage (com.cosylab.acs.jms.ACSJMSTextMessage)1 Vector (java.util.Vector)1