Search in sources :

Example 6 with ACSAlarmSystemInterface

use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.

the class UserPropsTest method send_alarm.

/**
	 * Push an alarm
	 * 
	 * @param active If true the alarm is active
	 */
private void send_alarm(String family, String member, int code, boolean active, Properties props) throws Exception {
    ACSAlarmSystemInterface alarmSource;
    alarmSource = ACSAlarmSystemInterfaceFactory.createSource(member);
    ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(family, member, code);
    if (active) {
        fs.setDescriptor(FaultState.ACTIVE);
    } else {
        fs.setDescriptor(FaultState.TERMINATE);
    }
    fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
    if (props != null && props.size() > 0) {
        fs.setUserProperties((Properties) props.clone());
    }
    alarmSource.push(fs);
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState) ACSAlarmSystemInterface(alma.alarmsystem.source.ACSAlarmSystemInterface) Timestamp(java.sql.Timestamp)

Example 7 with ACSAlarmSystemInterface

use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.

the class CategoryClientTest method send_alarm.

/**
	 * Push an alarm
	 * 
	 * @param active If true the alarm is active
	 */
private void send_alarm(String family, String member, int code, boolean active) throws Exception {
    ACSAlarmSystemInterface alarmSource;
    alarmSource = ACSAlarmSystemInterfaceFactory.createSource(member);
    ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(family, member, code);
    if (active) {
        fs.setDescriptor(FaultState.ACTIVE);
    } else {
        fs.setDescriptor(FaultState.TERMINATE);
    }
    fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
    alarmSource.push(fs);
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState) ACSAlarmSystemInterface(alma.alarmsystem.source.ACSAlarmSystemInterface) Timestamp(java.sql.Timestamp)

Example 8 with ACSAlarmSystemInterface

use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.

the class SendTest method testStress.

// Send 20K alarms
public void testStress() throws Exception {
    ACSAlarmSystemInterface alarmSource;
    try {
        alarmSource = ACSAlarmSystemInterfaceFactory.createSource();
        assertNotNull("Error instantiating the source", alarmSource);
        ACSFaultState[] faultStates = new ACSFaultState[ITERATIONS];
        for (int t = 0; t < ITERATIONS; t++) {
            faultStates[t] = ACSAlarmSystemInterfaceFactory.createFaultState(faultFamily + t, faultMember + t, t);
            assertNotNull("Error instantiating a fault state", faultStates[t]);
            if (t % 2 == 0) {
                faultStates[t].setDescriptor(ACSFaultState.ACTIVE);
            } else {
                faultStates[t].setDescriptor(ACSFaultState.TERMINATE);
            }
            Properties props = new Properties();
            props.setProperty(ACSFaultState.ASI_PREFIX_PROPERTY, "prefix");
            props.setProperty(ACSFaultState.ASI_SUFFIX_PROPERTY, "suffix");
            faultStates[t].setUserProperties(props);
            faultStates[t].setUserTimestamp(new Timestamp(System.currentTimeMillis()));
        }
        m_logger.info("all alarm messages are prepared.");
        for (int t = 0; t < ITERATIONS; t++) {
            m_logger.info("alarm message #" + t + " will be sent now.");
            alarmSource.push(faultStates[t]);
            try {
                // HSO: if alarm system needs 10 ms sleep, then this should be enforced in the alarm classes, not in the test!
                Thread.sleep(10);
            } catch (Exception e) {
            }
        }
        try {
            Thread.sleep(10000);
        } catch (Exception e) {
        }
    } catch (Exception e) {
        System.out.println("Exception caught while pushing" + e.getMessage());
        System.out.println("Cause: " + e.getCause());
        e.printStackTrace();
        throw e;
    } finally {
        assertNull(receiverError);
    }
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState) ACSAlarmSystemInterface(alma.alarmsystem.source.ACSAlarmSystemInterface) Properties(java.util.Properties) Timestamp(java.sql.Timestamp)

Example 9 with ACSAlarmSystemInterface

use of alma.alarmsystem.source.ACSAlarmSystemInterface 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);
    }
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState) ACSAlarmSystemInterface(alma.alarmsystem.source.ACSAlarmSystemInterface)

Example 10 with ACSAlarmSystemInterface

use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.

the class ObjectsTest method testSourceType.

public void testSourceType() throws Exception {
    ACSAlarmSystemInterface source;
    String sourceName = this.getName();
    try {
        source = ACSAlarmSystemInterfaceFactory.createSource(sourceName);
    } catch (Exception e) {
        System.out.println("Error creating the source: " + e.getMessage());
        e.printStackTrace();
        throw e;
    }
    assertNotNull("Error creating the source", source);
    assertTrue("The source has wrong class type", source instanceof AlarmSystemInterfaceProxy);
}
Also used : ACSAlarmSystemInterface(alma.alarmsystem.source.ACSAlarmSystemInterface) AlarmSystemInterfaceProxy(cern.laser.source.alarmsysteminterface.impl.AlarmSystemInterfaceProxy)

Aggregations

ACSAlarmSystemInterface (alma.alarmsystem.source.ACSAlarmSystemInterface)12 ACSFaultState (alma.alarmsystem.source.ACSFaultState)10 Timestamp (java.sql.Timestamp)6 Properties (java.util.Properties)2 AlarmSystemInterfaceProxy (cern.laser.source.alarmsysteminterface.impl.AlarmSystemInterfaceProxy)1 Collection (java.util.Collection)1 Vector (java.util.Vector)1