Search in sources :

Example 1 with FaultStates

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

the class ASIMessageHelper method unmarshal.

/**
	 * DOCUMENT ME!
	 * 
	 * @param asiMessage
	 *            DOCUMENT ME!
	 * 
	 * @return DOCUMENT ME!
	 */
public static Collection<FaultState> unmarshal(ASIMessage asiMessage) {
    if (asiMessage == null) {
        throw (new IllegalArgumentException("ASI message is null"));
    }
    Collection<FaultState> ret = new ArrayList<FaultState>();
    FaultStates generated_states = asiMessage.getFaultStates();
    if (generated_states != null) {
        for (cern.laser.source.alarmsysteminterface.impl.message.FaultState generated_state : generated_states.getFaultState()) {
            ret.add(FaultStateHelper.unmarshal(generated_state));
        }
    }
    return ret;
}
Also used : FaultStates(cern.laser.source.alarmsysteminterface.impl.message.FaultStates) ArrayList(java.util.ArrayList) FaultState(cern.laser.source.alarmsysteminterface.FaultState)

Example 2 with FaultStates

use of cern.laser.source.alarmsysteminterface.impl.message.FaultStates 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)

Example 3 with FaultStates

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

the class ASIMessageHelper method marshal.

/**
   * DOCUMENT ME!
   *
   * @param states DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
public static ASIMessage marshal(Collection states) {
    if (states == null) {
        throw (new IllegalArgumentException("states collection is null"));
    }
    ASIMessage asi_message = new ASIMessage();
    Iterator iterator = states.iterator();
    FaultStates fault_states = new FaultStates();
    while (iterator.hasNext()) {
        Object ref = iterator.next();
        if (ref instanceof FaultState) {
            fault_states.addFaultState(FaultStateHelper.marshal((FaultState) ref));
        } else {
            throw new IllegalArgumentException("collection does not contain FaultState instances");
        }
    }
    asi_message.setFaultStates(fault_states);
    return asi_message;
}
Also used : FaultStates(cern.laser.source.alarmsysteminterface.impl.message.FaultStates) Iterator(java.util.Iterator) FaultState(cern.laser.source.alarmsysteminterface.FaultState) ASIMessage(cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)

Aggregations

FaultStates (cern.laser.source.alarmsysteminterface.impl.message.FaultStates)3 FaultState (cern.laser.source.alarmsysteminterface.FaultState)2 ASIMessage (cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)2 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 FaultState (cern.laser.source.alarmsysteminterface.impl.message.FaultState)1 ACSJMSTextMessage (com.cosylab.acs.jms.ACSJMSTextMessage)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1