Search in sources :

Example 11 with ACSFaultState

use of alma.alarmsystem.source.ACSFaultState 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 12 with ACSFaultState

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

the class RRWithRegExp method sendAlarm.

/**
	 * Send an alarm
	 * 
	 * @param FF The fault family
	 * @param FM The fault Member
	 * @param FC The fault code
	 * @param active The state active/terminate
	 */
private void sendAlarm(String FF, String FM, int FC, boolean active) throws Exception {
    ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(FF, FM, FC);
    assertNotNull(fs);
    if (active) {
        fs.setDescriptor(FaultState.ACTIVE);
    } else {
        fs.setDescriptor(FaultState.TERMINATE);
    }
    fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
    alarmSource.push(fs);
    m_logger.info("Alarm sent <" + FF + ", " + FM + ", " + FC + "> " + fs.getDescriptor());
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState) Timestamp(java.sql.Timestamp)

Example 13 with ACSFaultState

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

the class RRWithDefaultFM method sendAlarm.

/**
	 * Send an alarm
	 * 
	 * @param FF The fault family
	 * @param FM The fault Member
	 * @param FC The fault code
	 * @param active The state active/terminate
	 */
private void sendAlarm(String FF, String FM, int FC, boolean active) throws Exception {
    ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(FF, FM, FC);
    assertNotNull(fs);
    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) Timestamp(java.sql.Timestamp)

Example 14 with ACSFaultState

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

the class StressTest method cleanActiveAlarms.

/**
	 * Clean all the active alarms published by the test.
	 * This method must be called in the <code>cleanUp</code> in order
	 * to terminate all the active alarms and be ready for a new test.
	 */
private void cleanActiveAlarms() throws Exception {
    for (MiniFaultState mfs : statesToPublish) {
        if (mfs.description.equals(FaultState.ACTIVE)) {
            ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(mfs.FF, mfs.FM, mfs.FC);
            assertNotNull("Error instantiating the FS", fs);
            fs.setDescriptor(FaultState.TERMINATE);
            fs.setUserTimestamp(mfs.timestamp);
            alarmSource.push(fs);
        }
    }
}
Also used : ACSFaultState(alma.alarmsystem.source.ACSFaultState)

Example 15 with ACSFaultState

use of alma.alarmsystem.source.ACSFaultState 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)

Aggregations

ACSFaultState (alma.alarmsystem.source.ACSFaultState)19 Timestamp (java.sql.Timestamp)11 ACSAlarmSystemInterface (alma.alarmsystem.source.ACSAlarmSystemInterface)10 Properties (java.util.Properties)2 FaultStateImpl (cern.laser.source.alarmsysteminterface.impl.FaultStateImpl)1 Collection (java.util.Collection)1 Vector (java.util.Vector)1