Search in sources :

Example 11 with Counter

use of com.automatak.dnp3.Counter in project Scientist4J by rawls238.

the class ExpectingAnException method candidateExceptionsAreCounted_dropwizard.

@Test
public void candidateExceptionsAreCounted_dropwizard() throws Exception {
    final DropwizardMetricsProvider provider = new DropwizardMetricsProvider();
    Experiment<Integer> exp = new Experiment<>("test", provider);
    exp.run(() -> 1, this::exceptionThrowingFunction);
    Counter result = provider.getRegistry().getCounters().get(MetricName.build("scientist", "test", "candidate", "exception"));
    assertThat(result.getCount()).isEqualTo(1);
}
Also used : Counter(io.dropwizard.metrics5.Counter) DropwizardMetricsProvider(com.github.rawls238.scientist4j.metrics.DropwizardMetricsProvider) Test(org.junit.Test)

Example 12 with Counter

use of com.automatak.dnp3.Counter in project solarnetwork-node by SolarNetwork.

the class OutstationService method createEventBufferConfig.

private EventBufferConfig createEventBufferConfig(Map<MeasurementType, List<MeasurementConfig>> configs, Map<ControlType, List<ControlConfig>> controlConfigs) {
    EventBufferConfig config = EventBufferConfig.allTypes(0);
    final int size = getEventBufferSize();
    if (configs != null) {
        for (Map.Entry<MeasurementType, List<MeasurementConfig>> me : configs.entrySet()) {
            MeasurementType type = me.getKey();
            List<MeasurementConfig> list = me.getValue();
            if (type == null || list == null || list.isEmpty()) {
                continue;
            }
            switch(type) {
                case AnalogInput:
                    config.maxAnalogEvents = size;
                    break;
                case AnalogOutputStatus:
                    config.maxAnalogOutputStatusEvents = size;
                    break;
                case BinaryInput:
                    config.maxBinaryEvents = size;
                    break;
                case BinaryOutputStatus:
                    config.maxBinaryOutputStatusEvents = size;
                    break;
                case Counter:
                    config.maxCounterEvents = size;
                    break;
                case DoubleBitBinaryInput:
                    config.maxDoubleBinaryEvents = size;
                    break;
                case FrozenCounter:
                    config.maxFrozenCounterEvents = size;
                    break;
            }
        }
    }
    if (controlConfigs != null) {
        for (Map.Entry<ControlType, List<ControlConfig>> me : controlConfigs.entrySet()) {
            ControlType type = me.getKey();
            List<ControlConfig> list = me.getValue();
            if (type == null || list == null || list.isEmpty()) {
                continue;
            }
            switch(type) {
                case Analog:
                    config.maxAnalogOutputStatusEvents = size;
                    break;
                case Binary:
                    config.maxBinaryOutputStatusEvents = size;
                    break;
            }
        }
    }
    return config;
}
Also used : EventBufferConfig(com.automatak.dnp3.EventBufferConfig) MeasurementConfig(net.solarnetwork.node.io.dnp3.domain.MeasurementConfig) ControlConfig(net.solarnetwork.node.io.dnp3.domain.ControlConfig) MeasurementType(net.solarnetwork.node.io.dnp3.domain.MeasurementType) List(java.util.List) ArrayList(java.util.ArrayList) ControlType(net.solarnetwork.node.io.dnp3.domain.ControlType) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with Counter

use of com.automatak.dnp3.Counter in project solarnetwork-node by SolarNetwork.

the class OutstationService method createDatabaseConfig.

private DatabaseConfig createDatabaseConfig(Map<MeasurementType, List<MeasurementConfig>> configs, Map<ControlType, List<ControlConfig>> controlConfigs) {
    int analogCount = 0;
    int aoStatusCount = 0;
    int binaryCount = 0;
    int boStatusCount = 0;
    int counterCount = 0;
    int doubleBinaryCount = 0;
    int frozenCounterCount = 0;
    StringBuilder infoBuf = new StringBuilder();
    if (configs != null) {
        for (Map.Entry<MeasurementType, List<MeasurementConfig>> me : configs.entrySet()) {
            MeasurementType type = me.getKey();
            List<MeasurementConfig> list = me.getValue();
            if (type == null || list == null || list.isEmpty()) {
                continue;
            }
            switch(type) {
                case AnalogInput:
                    analogCount = list.size();
                    appendMeasurementInfos(infoBuf, type, list);
                    break;
                case AnalogOutputStatus:
                    aoStatusCount = list.size();
                    break;
                case BinaryInput:
                    binaryCount = list.size();
                    appendMeasurementInfos(infoBuf, type, list);
                    break;
                case BinaryOutputStatus:
                    boStatusCount = list.size();
                    break;
                case Counter:
                    counterCount = list.size();
                    appendMeasurementInfos(infoBuf, type, list);
                    break;
                case DoubleBitBinaryInput:
                    doubleBinaryCount = list.size();
                    appendMeasurementInfos(infoBuf, type, list);
                    break;
                case FrozenCounter:
                    frozenCounterCount = list.size();
                    appendMeasurementInfos(infoBuf, type, list);
                    break;
            }
        }
    }
    if (controlConfigs != null) {
        for (Map.Entry<ControlType, List<ControlConfig>> me : controlConfigs.entrySet()) {
            ControlType type = me.getKey();
            List<ControlConfig> list = me.getValue();
            if (type == null || list == null || list.isEmpty()) {
                continue;
            }
            switch(type) {
                case Analog:
                    appendControlInfos(infoBuf, type, list, aoStatusCount);
                    aoStatusCount += list.size();
                    break;
                case Binary:
                    appendControlInfos(infoBuf, type, list, boStatusCount);
                    boStatusCount += list.size();
                    break;
            }
        }
    }
    log.info("DNP3 outstation [{}] database configured with following registers:\n{}", getUid(), infoBuf);
    return new DatabaseConfig(binaryCount, doubleBinaryCount, analogCount, counterCount, frozenCounterCount, boStatusCount, aoStatusCount);
}
Also used : MeasurementConfig(net.solarnetwork.node.io.dnp3.domain.MeasurementConfig) ControlConfig(net.solarnetwork.node.io.dnp3.domain.ControlConfig) MeasurementType(net.solarnetwork.node.io.dnp3.domain.MeasurementType) List(java.util.List) ArrayList(java.util.ArrayList) ControlType(net.solarnetwork.node.io.dnp3.domain.ControlType) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) DatabaseConfig(com.automatak.dnp3.DatabaseConfig)

Aggregations

Counter (edu.princeton.cs.algs4.Counter)5 Counter (io.dropwizard.metrics5.Counter)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Counter (com.automatak.dnp3.Counter)2 OutstationChangeSet (com.automatak.dnp3.OutstationChangeSet)2 CleanupDepositJob (edu.unc.lib.boxc.deposit.CleanupDepositJob)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 ControlConfig (net.solarnetwork.node.io.dnp3.domain.ControlConfig)2 ControlType (net.solarnetwork.node.io.dnp3.domain.ControlType)2 MeasurementConfig (net.solarnetwork.node.io.dnp3.domain.MeasurementConfig)2 MeasurementType (net.solarnetwork.node.io.dnp3.domain.MeasurementType)2 AnalogInput (com.automatak.dnp3.AnalogInput)1 AnalogOutputStatus (com.automatak.dnp3.AnalogOutputStatus)1 BinaryInput (com.automatak.dnp3.BinaryInput)1 BinaryOutputStatus (com.automatak.dnp3.BinaryOutputStatus)1 Channel (com.automatak.dnp3.Channel)1 DatabaseConfig (com.automatak.dnp3.DatabaseConfig)1 DoubleBitBinaryInput (com.automatak.dnp3.DoubleBitBinaryInput)1