Search in sources :

Example 1 with SampDetail

use of cl.utfsm.samplingSystemUI.core.SampDetail in project ACS by ACS-Community.

the class Display2 method main.

public static void main(String[] args) throws AcsJContainerEx {
    String component = "";
    String property = "";
    long frequency;
    long reportRate;
    Display2 display = new Display2();
    try {
        spinUp("SampTool", "SAMP1");
    } catch (AcsInformationException e) {
        System.out.print(e.getMessage());
        System.exit(-1);
    } catch (SamplingManagerException e) {
        System.out.print(e.getMessage());
        System.exit(-1);
    }
    /*The previous code should be more or less the same for every tool, perhaps it could be cotaines withind a class tool and future tools inherit this. */
    display.start();
    try {
        while (true) {
            //Input Reading.
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
            System.out.print("Component name(type - LAMP1):");
            component = in.readLine();
            if (component == null)
                continue;
            if (component.compareToIgnoreCase("exit") == 0) {
                break;
            }
            if (!componentExists(component)) {
                System.out.print("No such component");
                continue;
            }
            System.out.print("Property name(type - brightness):");
            property = in.readLine();
            prop = property;
            if (property == null)
                property = "";
            if (!propertyExists(component, property)) {
                System.out.print("No such property in " + component + " component");
                continue;
            }
            System.out.print("Sampling Frequency (hz) (type - 1):");
            frequency = (long) 10000000 / ((new Long(in.readLine())).longValue());
            System.out.print("Reporting Frequency (s) (type - 1):");
            reportRate = (new Long(in.readLine())).longValue();
            startSample(new SampDetail(component, property, frequency, reportRate));
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            display.halt();
            tearDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) AcsInformationException(cl.utfsm.samplingSystemUI.core.AcsInformationException) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException) AcsInformationException(cl.utfsm.samplingSystemUI.core.AcsInformationException) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException)

Example 2 with SampDetail

use of cl.utfsm.samplingSystemUI.core.SampDetail in project ACS by ACS-Community.

the class DataPrinter method stopSampling.

public void stopSampling() {
    synchronized (this) {
        initializations--;
        if (componentAvailable == true) {
            samp.halt();
            SamplingManagerUITool.stopSample(new SampDetail(component, property, (long) frequency, reportRate));
            postProcessing();
        }
    }
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail)

Example 3 with SampDetail

use of cl.utfsm.samplingSystemUI.core.SampDetail in project ACS by ACS-Community.

the class DataPrinter method startSample.

/**
	 * Starts the sampling, connecting to ACS Manager and the Sampling Manager.
	 * @throws CouldntAccessComponentEx Component wasn't available at the time.
	 * @throws TypeNotSupportedEx Sampling Manager specific exception. Some types are currently not supported in acssamp.
	 * @throws CouldntAccessPropertyEx
	 */
public void startSample() throws CouldntAccessComponentEx, TypeNotSupportedEx, CouldntAccessPropertyEx, SamplingManagerException {
    samp = new Sampler();
    synchronized (this) {
        System.out.println("Initialization:" + initializations);
        if (initializations == 0) {
            try {
                spinUp(SampTool.NAME, ssg.MAN_NAME);
            } catch (AcsInformationException e) {
                System.out.print(e.getMessage());
                System.exit(-1);
            } catch (SamplingManagerException e) {
                System.out.print(e.getMessage());
                System.exit(-1);
            } catch (AcsJContainerEx e) {
                System.out.println(e.getMessage());
                System.exit(-1);
            }
        }
        initializations++;
    }
    try {
        SamplingManagerUITool.startSample(new SampDetail(component, property, (long) this.frequency, reportRate));
    } catch (alma.ACSErrTypeCommon.CouldntAccessComponentEx e) {
        setComponentAvailable(false, "Cannot access component implementation");
        throw e;
    } catch (alma.ACSErrTypeCommon.TypeNotSupportedEx e) {
        setComponentAvailable(false, "Type not supported");
        throw e;
    } catch (CouldntAccessPropertyEx e) {
        setComponentAvailable(false, "Cannot access the property");
        throw e;
    } catch (SamplingManagerException e) {
        setComponentAvailable(false, e.getMessage());
        throw e;
    }
    samp.start();
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) CouldntAccessComponentEx(alma.ACSErrTypeCommon.CouldntAccessComponentEx) SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) TypeNotSupportedEx(alma.ACSErrTypeCommon.TypeNotSupportedEx) AcsInformationException(cl.utfsm.samplingSystemUI.core.AcsInformationException) CouldntAccessPropertyEx(alma.ACSErrTypeCommon.CouldntAccessPropertyEx) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException)

Example 4 with SampDetail

use of cl.utfsm.samplingSystemUI.core.SampDetail in project ACS by ACS-Community.

the class SamplingManagerTest method testGetSampObjExceptions.

public void testGetSampObjExceptions() throws Exception {
    SamplingManager man1 = SamplingManager.getInstance("SAMP1");
    SampObj temp = null;
    boolean exceptionCaught;
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED4", "my_ROdouble", 100, 1));
    } catch (CouldntAccessComponentEx e) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED1", "my_ROstring", 100, 1));
    } catch (TypeNotSupportedEx e) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED2", "my_RWdouble", 100, 1));
    } catch (Exception e) {
        exceptionCaught = true;
    }
    assertTrue(!exceptionCaught);
    assertNotNull(temp);
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) SampObj(alma.acssamp.SampObj) SamplingManager(cl.utfsm.samplingSystemUI.core.SamplingManager) TypeNotSupportedEx(alma.ACSErrTypeCommon.TypeNotSupportedEx) CouldntAccessComponentEx(alma.ACSErrTypeCommon.CouldntAccessComponentEx) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException)

Example 5 with SampDetail

use of cl.utfsm.samplingSystemUI.core.SampDetail in project ACS by ACS-Community.

the class SamplingManagerTest method testGetSampObj.

public void testGetSampObj() throws Exception {
    SamplingManager man1 = null;
    SampDetail sDetail1 = new SampDetail("LAMP1", "brightness", 100, 1);
    SampDetail sDetail2 = new SampDetail("LAMP1", "brightness", 200, 1);
    SampObj temp;
    man1 = SamplingManager.getInstance("SAMP1");
    temp = man1.getSamplingObj(sDetail1);
    assertNotNull(temp);
    assertNotNull(man1.getSamplingObj(sDetail2));
    assertEquals(man1.getSamplingObj(sDetail1), temp);
    assertEquals(man1.getSamplingObj(sDetail1), man1.getSamplingObj(sDetail1));
    assertNotSame(man1.getSamplingObj(sDetail2), temp);
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) SampObj(alma.acssamp.SampObj) SamplingManager(cl.utfsm.samplingSystemUI.core.SamplingManager)

Aggregations

SampDetail (cl.utfsm.samplingSystemUI.core.SampDetail)6 SamplingManagerException (cl.utfsm.samplingSystemUI.core.SamplingManagerException)3 CouldntAccessComponentEx (alma.ACSErrTypeCommon.CouldntAccessComponentEx)2 TypeNotSupportedEx (alma.ACSErrTypeCommon.TypeNotSupportedEx)2 SampObj (alma.acssamp.SampObj)2 AcsInformationException (cl.utfsm.samplingSystemUI.core.AcsInformationException)2 SamplingManager (cl.utfsm.samplingSystemUI.core.SamplingManager)2 CouldntAccessPropertyEx (alma.ACSErrTypeCommon.CouldntAccessPropertyEx)1 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1