Esempio n. 1
0
def run_master(hang=False):
    """Demonstrate hanging when channel and master are not deleted prior to manager.Shutdown()
    """
    logger = asiodnp3.ConsoleLogger().Create()
    manager = asiodnp3.DNP3Manager(1, asiodnp3.ConsoleLogger().Create())
    #printing_channel_listener = asiodnp3.PrintingChannelListener().Create()
    channel = manager.AddTCPClient("tcpclient", FILTERS,
                                   asiopal.ChannelRetry(), HOST, LOCAL, PORT,
                                   asiodnp3.PrintingChannelListener().Create())
    stack_config = asiodnp3.MasterStackConfig()
    stack_config.master.responseTimeout = openpal.TimeDuration().Seconds(2)
    stack_config.link.RemoteAddr = 10
    soe_handler = asiodnp3.PrintingSOEHandler().Create()
    default_master_app = asiodnp3.DefaultMasterApplication().Create()
    master = channel.AddMaster("master", soe_handler, default_master_app,
                               stack_config)
    master.Enable()
    time.sleep(2)
    if not hang:
        #del logger
        #del printing_channel_listener
        del channel
        #del stack_config
        #del soe_handler
        #del default_master_app
        del master
    print("Shutdown, Hang = {}".format(hang))
    manager.Shutdown()
Esempio n. 2
0
def run_master():
    # Root DNP3 object used to create channels and sessions
    manager = asiodnp3.DNP3Manager(1, asiodnp3.ConsoleLogger().Create())

    # Connect via a TCPClient socket to an outstation
    channel = manager.AddTCPClient("tcpclient",
                                   FILTERS,
                                   asiopal.ChannelRetry(),
                                   HOST,
                                   LOCAL,
                                   PORT,
                                   asiodnp3.PrintingChannelListener().Create())

    # Master config object for a master
    stack_config = asiodnp3.MasterStackConfig()
    stack_config.master.responseTimeout = openpal.TimeDuration().Seconds(2)
    stack_config.link.RemoteAddr = 10

    # Add a master to a communication channel
    master = channel.AddMaster("master",
                               asiodnp3.PrintingSOEHandler().Create(),
                               asiodnp3.DefaultMasterApplication().Create(),
                               stack_config)

    # Enable the master. This will start communications.
    master.Enable()

    return manager
Esempio n. 3
0
    def __init__(
            self,
            log_levels=opendnp3.levels.NORMAL | opendnp3.levels.ALL_APP_COMMS,
            host_ip="127.0.0.1",  # presumably outstation
            local_ip="0.0.0.0",
            port=20000,
            log_handler=asiodnp3.ConsoleLogger().Create(),
            channel_listener=asiodnp3.PrintingChannelListener().Create(),
            soe_handler=asiodnp3.PrintingSOEHandler().Create(),
            master_application=asiodnp3.DefaultMasterApplication().Create(),
            stack_config=None):

        self.log_levels = log_levels
        self.host_ip = host_ip
        self.local_ip = local_ip
        self.port = port
        self.log_handler = log_handler
        self.channel_listener = channel_listener
        self.soe_handler = soe_handler
        self.master_application = master_application

        self.stackConfig = stack_config
        if not self.stackConfig:
            # The master config object for a master.
            self.stackConfig = asiodnp3.MasterStackConfig()
            self.stackConfig.master.responseTimeout = openpal.TimeDuration(
            ).Seconds(2)
            self.stackConfig.link.RemoteAddr = 10

        self.manager = None
        self.channel = None
        self.master = None
Esempio n. 4
0
def run_outstation():
    # Root DNP3 object used to create channels and sessions
    manager = asiodnp3.DNP3Manager(1, asiodnp3.ConsoleLogger().Create())

    # Connect via a TCPServer socket to a server
    channel = manager.AddTCPServer("server",
                                   FILTERS,
                                   asiopal.ChannelRetry().Default(),
                                   LOCAL,
                                   PORT,
                                   asiodnp3.PrintingChannelListener().Create())

    # A composite configuration struct that contains all the config information for a dnp3 outstation stack
    config = asiodnp3.OutstationStackConfig(opendnp3.DatabaseSizes.AllTypes(10))
    config.outstation.eventBufferConfig = opendnp3.EventBufferConfig().AllTypes(10)
    config.outstation.params.allowUnsolicited = True
    config.link.LocalAddr = 10
    config.link.KeepAliveTimeout = openpal.TimeDuration().Max()

    # Add an outstation to a communication channel
    outstation = channel.AddOutstation("outstation",
                                       opendnp3.SuccessCommandHandler().Create(),
                                       opendnp3.DefaultOutstationApplication().Create(),
                                       config)
    outstation.Enable()

    return manager
Esempio n. 5
0
    def __init__(
            self,
            log_handler=asiodnp3.ConsoleLogger().Create(),
            listener=asiodnp3.PrintingChannelListener().Create(),
            soe_handler=asiodnp3.PrintingSOEHandler().Create(),
            master_application=asiodnp3.DefaultMasterApplication().Create(),
            stack_config=None):

        _log.debug('Creating a DNP3Manager.')
        self.log_handler = log_handler
        self.manager = asiodnp3.DNP3Manager(1, self.log_handler)

        _log.debug('Creating the DNP3 channel, a TCP client.')
        self.retry = asiopal.ChannelRetry().Default()
        self.listener = listener
        self.channel = self.manager.AddTCPClient("tcpclient", FILTERS,
                                                 self.retry, HOST, LOCAL, PORT,
                                                 self.listener)

        _log.debug('Configuring the DNP3 stack.')
        self.stack_config = stack_config
        if not self.stack_config:
            self.stack_config = asiodnp3.MasterStackConfig()
            self.stack_config.master.responseTimeout = openpal.TimeDuration(
            ).Seconds(2)
            self.stack_config.link.RemoteAddr = 10

        _log.debug('Adding the master to the channel.')
        self.soe_handler = soe_handler
        self.master_application = master_application
        self.master = self.channel.AddMaster(
            "master",
            asiodnp3.PrintingSOEHandler().Create(), self.master_application,
            self.stack_config)

        _log.debug('Configuring some scans (periodic reads).')
        # Set up a "slow scan", an infrequent integrity poll that requests events and static data for all classes.
        self.slow_scan = self.master.AddClassScan(
            opendnp3.ClassField().AllClasses(),
            openpal.TimeDuration().Minutes(30),
            opendnp3.TaskConfig().Default())
        # Set up a "fast scan", a relatively-frequent exception poll that requests events and class 1 static data.
        self.fast_scan = self.master.AddClassScan(
            opendnp3.ClassField(opendnp3.ClassField.CLASS_1),
            openpal.TimeDuration().Minutes(1),
            opendnp3.TaskConfig().Default())

        self.channel.SetLogFilters(
            openpal.LogFilters(opendnp3.levels.ALL_COMMS))
        self.master.SetLogFilters(openpal.LogFilters(
            opendnp3.levels.ALL_COMMS))

        _log.debug(
            'Enabling the master. At this point, traffic will start to flow between the Master and Outstations.'
        )
        self.master.Enable()
        time.sleep(5)
Esempio n. 6
0
    def __init__(self,outstation_ip, outstation_id):
        
        self._soe_handler = SOEHandler()
        self._soe_handler.values = self.values

        log_handler = asiodnp3.ConsoleLogger().Create()

        self._manager = asiodnp3.DNP3Manager(1, log_handler)
        retry = asiopal.ChannelRetry().Default()
        listener = asiodnp3.PrintingChannelListener().Create()
        channel = self._manager.AddTCPClient('client', opendnp3.levels.NOTHING, retry, outstation_ip, '0.0.0.0', 20000, listener)
        master_application = asiodnp3.DefaultMasterApplication().Create()
        stack_config = asiodnp3.MasterStackConfig()
        stack_config.master.responseTimeout = openpal.TimeDuration().Seconds(2)
        stack_config.link.RemoteAddr = outstation_id

        self._master = channel.AddMaster('master', self._soe_handler, master_application, stack_config)
Esempio n. 7
0
    def __init__(self):
        super(OutstationApplication, self).__init__()

        _log.debug('Configuring the DNP3 stack.')
        self.stack_config = self.configure_stack()

        _log.debug('Configuring the outstation database.')
        self.configure_database(self.stack_config.dbConfig)

        _log.debug('Creating a DNP3Manager.')
        threads_to_allocate = 1
        # self.log_handler = MyLogger()
        self.log_handler = asiodnp3.ConsoleLogger().Create(
        )  # (or use this during regression testing)
        self.manager = asiodnp3.DNP3Manager(threads_to_allocate,
                                            self.log_handler)

        _log.debug('Creating the DNP3 channel, a TCP server.')
        self.retry_parameters = asiopal.ChannelRetry().Default()
        self.listener = AppChannelListener()
        # self.listener = asiodnp3.PrintingChannelListener().Create()       # (or use this during regression testing)
        self.channel = self.manager.AddTCPServer("server", LOG_LEVELS,
                                                 self.retry_parameters,
                                                 LOCAL_IP, PORT, self.listener)

        _log.debug('Adding the outstation to the channel.')
        self.command_handler = OutstationCommandHandler()
        # self.command_handler =  opendnp3.SuccessCommandHandler().Create() # (or use this during regression testing)
        self.outstation = self.channel.AddOutstation("outstation",
                                                     self.command_handler,
                                                     self, self.stack_config)

        # Put the Outstation singleton in OutstationApplication so that it can be used to send updates to the Master.
        OutstationApplication.set_outstation(self.outstation)

        _log.debug('Enabling the outstation. Traffic will now start to flow.')
        self.outstation.Enable()
Esempio n. 8
0
 def test_default_constructors(self):
     """
         Create the class object with default values for instance variable and test if the object is not empty.
     """
     assert asiodnp3.ConsoleLogger() is not None
     assert asiodnp3.DefaultListenCallbacks() is not None
     assert asiodnp3.DefaultMasterApplication() is not None
     assert asiodnp3.MasterStackConfig() is not None
     assert asiodnp3.PrintingChannelListener is not None
     assert asiodnp3.PrintingSOEHandler() is not None
     assert asiodnp3.UpdateBuilder() is not None
     assert asiopal.ChannelRetry() is not None
     assert asiopal.ResourceManager() is not None
     assert asiopal.SerialSettings() is not None
     assert asiopal.steady_clock_t() is not None
     assert opendnp3.AnalogCommandEvent() is not None
     assert opendnp3.AnalogOutputInt16() is not None
     assert opendnp3.AnalogOutputInt32() is not None
     assert opendnp3.AnalogOutputFloat32() is not None
     assert opendnp3.AnalogOutputDouble64() is not None
     assert opendnp3.BinaryCommandEvent() is not None
     assert opendnp3.ClassField() is not None
     assert opendnp3.ControlRelayOutputBlock() is not None
     assert opendnp3.DNPTime() is not None
     assert opendnp3.Flags() is not None
     assert opendnp3.GroupVariationID() is not None
     assert opendnp3.IndexedBinary() is not None
     assert opendnp3.IndexedDoubleBitBinary() is not None
     assert opendnp3.IndexedAnalog() is not None
     assert opendnp3.IndexedCounter() is not None
     assert opendnp3.IndexedFrozenCounter() is not None
     assert opendnp3.IndexedBinaryOutputStatus() is not None
     assert opendnp3.IndexedAnalogOutputStatus() is not None
     assert opendnp3.IndexedOctetString() is not None
     assert opendnp3.IndexedTimeAndInterval() is not None
     assert opendnp3.IndexedBinaryCommandEvent() is not None
     assert opendnp3.IndexedAnalogCommandEvent() is not None
     assert opendnp3.IndexedSecurityStat() is not None
     assert opendnp3.IndexedControlRelayOutputBlock() is not None
     assert opendnp3.IndexedAnalogOutputInt16() is not None
     assert opendnp3.IndexedAnalogOutputInt32() is not None
     assert opendnp3.IndexedAnalogOutputFloat32() is not None
     assert opendnp3.IndexedAnalogOutputDouble64() is not None
     assert opendnp3.Binary() is not None
     assert opendnp3.DoubleBitBinary() is not None
     assert opendnp3.BinaryOutputStatus() is not None
     assert opendnp3.Analog() is not None
     assert opendnp3.Counter() is not None
     assert opendnp3.FrozenCounter() is not None
     assert opendnp3.AnalogOutputStatus() is not None
     assert opendnp3.TimeAndInterval() is not None
     assert opendnp3.OctetData() is not None
     assert opendnp3.OctetString() is not None
     assert opendnp3.SecurityStat() is not None
     assert opendnp3.LinkHeaderFields() is not None
     assert opendnp3.LinkStatistics() is not None
     assert opendnp3.CommandSet() is not None
     assert opendnp3.HeaderInfo() is not None
     assert opendnp3.StartStopRangeUint8() is not None
     assert opendnp3.StartStopRangeUint16() is not None
     assert opendnp3.CountUint8() is not None
     assert opendnp3.CountUint16() is not None
     assert opendnp3.HeaderUnion() is not None
     assert opendnp3.Header() is not None
     assert opendnp3.MasterParams() is not None
     assert opendnp3.RestartOperationResult() is not None
     assert opendnp3.TaskConfig() is not None
     assert opendnp3.ApplicationIIN() is not None
     assert opendnp3.DatabaseSizes() is not None
     assert opendnp3.EventBufferConfig() is not None
     assert opendnp3.OutstationConfig() is not None
     assert opendnp3.OutstationParams() is not None
     assert opendnp3.StaticTypeBitField() is not None
     assert opendnp3.StackStatistics() is not None
     assert opendnp3.IINField() is not None
     assert openpal.ArrayBinaryConfig() is not None
     assert openpal.ArrayDoubleBitBinaryConfig() is not None
     assert openpal.ArrayAnalogConfig() is not None
     assert openpal.ArrayCounterConfig() is not None
     assert openpal.ArrayFrozenCounterConfig() is not None
     assert openpal.ArrayBOStatusConfig() is not None
     assert openpal.ArrayAOStatusConfig() is not None
     assert openpal.ArrayTimeAndIntervalConfig() is not None
     assert openpal.ArrayBuffer() is not None
     assert openpal.ArrayViewBinaryConfig() is not None
     assert openpal.ArrayViewDoubleBitBinaryConfig() is not None
     assert openpal.ArrayViewAnalogConfig() is not None
     assert openpal.ArrayViewCounterConfig() is not None
     assert openpal.ArrayViewFrozenCounterConfig() is not None
     assert openpal.ArrayViewBOStatusConfig() is not None
     assert openpal.ArrayViewAOStatusConfig() is not None
     assert openpal.ArrayViewTimeAndIntervalConfig() is not None
     assert openpal.ArrayViewBuffer() is not None
     assert openpal.Buffer() is not None
     assert openpal.RingBuffer16() is not None
     assert openpal.RSlice() is not None
     assert openpal.SecureBuffer() is not None
     assert openpal.SettableRSlice() is not None
     assert openpal.SettableWSlice() is not None
     assert openpal.StaticBuffer4() is not None
     assert openpal.StaticBuffer14() is not None
     assert openpal.StaticBuffer100() is not None
     assert openpal.StaticBuffer292() is not None
     assert openpal.WSlice() is not None
     assert openpal.MonotonicTimestamp() is not None
     assert openpal.TimeDurationBase() is not None
     assert openpal.TimeDuration() is not None
     assert openpal.UTCTimestamp() is not None
     assert openpal.LogFilters() is not None
     assert openpal.Logger() is not None
     assert openpal.SerializerBinary() is not None
     assert openpal.SerializerDoubleBitBinary() is not None
     assert openpal.SerializerBinaryOutputStatus() is not None
     assert openpal.SerializerAnalog() is not None
     assert openpal.SerializerCounter() is not None
     assert openpal.SerializerFrozenCounter() is not None
     assert openpal.SerializerAnalogOutputStatus() is not None
     assert openpal.SerializerTimeAndInterval() is not None
     assert openpal.SerializerAnalogOutputInt16() is not None
     assert openpal.SerializerAnalogOutputInt32() is not None
     assert openpal.SerializerAnalogOutputFloat32() is not None
     assert openpal.SerializerAnalogOutputDouble64() is not None
Esempio n. 9
0
 def test_passing_args(self):
     """
         Create the class object with defined arguments and test if the object is not empty.
     """
     assert asiodnp3.ConsoleLogger(True) is not None
     assert asiodnp3.DatabaseConfig(opendnp3.DatabaseSizes()) is not None
     assert asiodnp3.DNP3Manager(1) is not None
     assert asiodnp3.DNP3Manager(
         1,
         asiodnp3.ConsoleLogger().Create()) is not None
     assert asiodnp3.OutstationStackConfig(
         opendnp3.DatabaseSizes()) is not None
     assert asiodnp3.X509Info(1, openpal.RSlice(), "test") is not None
     assert asiopal.ChannelRetry(openpal.TimeDuration(),
                                 openpal.TimeDuration()) is not None
     assert asiopal.ChannelRetry(openpal.TimeDuration(),
                                 openpal.TimeDuration(),
                                 asiopal.IOpenDelayStrategy()) is not None
     assert asiopal.Executor(asiopal.IO()) is not None
     assert asiopal.IPEndpoint("127.0.0.1", 502) is not None
     assert asiopal.LoggingConnectionCondition(openpal.Logger()) is not None
     assert asiopal.SerialChannel(asiopal.Executor(
         asiopal.IO())) is not None
     assert asiopal.TCPClient(openpal.Logger(),
                              asiopal.Executor(asiopal.IO()),
                              asiopal.IPEndpoint("127.0.0.1", 502),
                              "adapter") is not None
     assert asiopal.ThreadPool(openpal.Logger(), asiopal.IO(),
                               1) is not None
     assert asiopal.TLSConfig("~/files/peerCert", "~/files/localCert",
                              "~/files/privateKey") is not None
     assert opendnp3.AnalogOutputInt16(
         1, opendnp3.CommandStatus.TIMEOUT) is not None
     assert opendnp3.AnalogOutputInt32(
         1, opendnp3.CommandStatus.FORMAT_ERROR) is not None
     assert opendnp3.AnalogOutputFloat32(
         1, opendnp3.CommandStatus.ALREADY_ACTIVE) is not None
     assert opendnp3.AnalogOutputDouble64(
         1, opendnp3.CommandStatus.LOCAL) is not None
     assert opendnp3.BinaryCommandEvent(opendnp3.Flags()) is not None
     assert opendnp3.BinaryCommandEvent(opendnp3.Flags(),
                                        opendnp3.DNPTime()) is not None
     assert opendnp3.BinaryCommandEvent(
         True, opendnp3.CommandStatus.TOO_MANY_OPS) is not None
     assert opendnp3.BinaryCommandEvent(
         False, opendnp3.CommandStatus.NOT_AUTHORIZED,
         opendnp3.DNPTime()) is not None
     assert opendnp3.ClassField(opendnp3.PointClass.Class0) is not None
     assert opendnp3.ClassField(1) is not None
     assert opendnp3.ClassField(True, False, True, False) is not None
     assert opendnp3.ControlRelayOutputBlock(
         opendnp3.ControlCode.LATCH_ON, 1, 100, 100,
         opendnp3.CommandStatus.AUTOMATION_INHIBIT) is not None
     assert opendnp3.ControlRelayOutputBlock(
         0x1, 1, 100, 100,
         opendnp3.CommandStatus.AUTOMATION_INHIBIT) is not None
     assert opendnp3.GroupVariationID(0x10, 0x1) is not None
     assert opendnp3.IINField(opendnp3.IINBit.ALL_STATIONS) is not None
     assert opendnp3.IndexedBinary(opendnp3.Binary(), 1) is not None
     assert opendnp3.IndexedDoubleBitBinary(opendnp3.DoubleBitBinary(),
                                            1) is not None
     assert opendnp3.IndexedAnalog(opendnp3.Analog(), 1) is not None
     assert opendnp3.IndexedCounter(opendnp3.Counter(), 1) is not None
     assert opendnp3.IndexedFrozenCounter(opendnp3.FrozenCounter(),
                                          1) is not None
     assert opendnp3.IndexedBinaryOutputStatus(
         opendnp3.BinaryOutputStatus(), 1) is not None
     assert opendnp3.IndexedAnalogOutputStatus(
         opendnp3.AnalogOutputStatus(), 1) is not None
     assert opendnp3.IndexedOctetString(opendnp3.OctetString(),
                                        1) is not None
     assert opendnp3.IndexedTimeAndInterval(opendnp3.TimeAndInterval(),
                                            1) is not None
     assert opendnp3.IndexedBinaryCommandEvent(
         opendnp3.BinaryCommandEvent(), 1) is not None
     assert opendnp3.IndexedAnalogCommandEvent(
         opendnp3.AnalogCommandEvent(), 1) is not None
     assert opendnp3.IndexedSecurityStat(opendnp3.SecurityStat(),
                                         1) is not None
     assert opendnp3.IndexedControlRelayOutputBlock(
         opendnp3.ControlRelayOutputBlock(), 1) is not None
     assert opendnp3.IndexedAnalogOutputInt16(opendnp3.AnalogOutputInt16(),
                                              1) is not None
     assert opendnp3.IndexedAnalogOutputInt32(opendnp3.AnalogOutputInt32(),
                                              1) is not None
     assert opendnp3.IndexedAnalogOutputFloat32(
         opendnp3.AnalogOutputFloat32(), 1) is not None
     assert opendnp3.IndexedAnalogOutputDouble64(
         opendnp3.AnalogOutputDouble64(), 1) is not None
     assert opendnp3.Binary(True) is not None
     assert opendnp3.Binary(opendnp3.Flags()) is not None
     assert opendnp3.Binary(opendnp3.Flags(),
                            opendnp3.DNPTime()) is not None
     assert opendnp3.Binary(False, opendnp3.Flags()) is not None
     assert opendnp3.Binary(True, opendnp3.Flags(),
                            opendnp3.DNPTime()) is not None
     assert opendnp3.DoubleBitBinary(opendnp3.DoubleBit(1),
                                     opendnp3.Flags(),
                                     opendnp3.DNPTime()) is not None
     assert opendnp3.BinaryOutputStatus(False, opendnp3.Flags(),
                                        opendnp3.DNPTime()) is not None
     assert opendnp3.Analog(1.2, opendnp3.Flags(),
                            opendnp3.DNPTime()) is not None
     assert opendnp3.Counter(100, opendnp3.Flags(),
                             opendnp3.DNPTime()) is not None
     assert opendnp3.FrozenCounter(2000, opendnp3.Flags(),
                                   opendnp3.DNPTime()) is not None
     assert opendnp3.AnalogOutputStatus(109.68, opendnp3.Flags(),
                                        opendnp3.DNPTime()) is not None
     assert opendnp3.TimeAndInterval(opendnp3.DNPTime(), 10,
                                     0x1) is not None
     assert opendnp3.TimeAndInterval(
         opendnp3.DNPTime(), 10, opendnp3.IntervalUnits.Seconds) is not None
     assert opendnp3.OctetData(openpal.RSlice()) is not None
     assert opendnp3.OctetString(openpal.RSlice()) is not None
     assert opendnp3.SecurityStat(opendnp3.SecurityStatValue(), 0x1,
                                  opendnp3.DNPTime()) is not None
     assert opendnp3.SecurityStat(0x1, 10, 100) is not None
     assert opendnp3.SecurityStat(0x1, 10, 100,
                                  opendnp3.DNPTime()) is not None
     assert opendnp3.LinkConfig(True, True) is not None
     assert opendnp3.LinkConfig(True, False, 100, 10, 10,
                                openpal.TimeDuration(),
                                openpal.TimeDuration()) is not None
     assert opendnp3.LinkHeaderFields(opendnp3.LinkFunction.INVALID, False,
                                      True, False, 10, 10) is not None
     assert opendnp3.LinkStatistics(
         opendnp3.LinkStatisticsChannel(),
         opendnp3.LinkStatisticsParser()) is not None
     assert opendnp3.CommandPointResult(
         100, 10, opendnp3.CommandPointState.INIT,
         opendnp3.CommandStatus.PROCESSING_LIMITED) is not None
     assert opendnp3.HeaderInfo(opendnp3.GroupVariation.Group10Var0,
                                opendnp3.QualifierCode.UINT8_CNT,
                                opendnp3.TimestampMode.SYNCHRONIZED,
                                100) is not None
     assert opendnp3.RestartOperationResult(
         opendnp3.TaskCompletion.SUCCESS,
         openpal.TimeDuration()) is not None
     assert opendnp3.DatabaseSizes(0, 1, 2, 3, 4, 5, 6, 7) is not None
     assert opendnp3.EventBufferConfig(0, 1, 2, 3, 4, 5, 6, 7) is not None
     assert opendnp3.OutstationConfig(
         opendnp3.OutstationParams(),
         opendnp3.EventBufferConfig()) is not None
     assert opendnp3.OutstationParams(opendnp3.IndexMode.Contiguous, 0x3,
                                      openpal.TimeDuration(),
                                      openpal.TimeDuration(),
                                      openpal.TimeDuration(),
                                      openpal.TimeDuration(), 10, 20, True,
                                      opendnp3.StaticTypeBitField(),
                                      opendnp3.ClassField()) is not None
     assert opendnp3.SimpleCommandHandler(
         opendnp3.CommandStatus.SUCCESS) is not None
     assert opendnp3.StaticTypeBitField(1) is not None
     assert opendnp3.StackStatistics(
         opendnp3.StackStatisticsLink(),
         opendnp3.StackStatisticsTransport()) is not None
     assert openpal.ArrayBinaryConfig(1) is not None
     assert openpal.ArrayDoubleBitBinaryConfig(1) is not None
     assert openpal.ArrayAnalogConfig(1) is not None
     assert openpal.ArrayCounterConfig(1) is not None
     assert openpal.ArrayFrozenCounterConfig(1) is not None
     assert openpal.ArrayBOStatusConfig(1) is not None
     assert openpal.ArrayAOStatusConfig(1) is not None
     assert openpal.ArrayTimeAndIntervalConfig(1) is not None
     assert openpal.ArrayBuffer(10) is not None
     assert openpal.Buffer(27) is not None
     assert openpal.Buffer(openpal.RSlice()) is not None
     assert openpal.LinkedListInt(5) is not None
     assert openpal.PairInt(5, 10) is not None
     assert openpal.RSlice(0xFF, 100) is not None
     assert openpal.SecureBuffer(10) is not None
     assert openpal.SecureBuffer(openpal.RSlice()) is not None
     assert openpal.WSlice(0x30, 20) is not None
     assert openpal.MonotonicTimestamp(100) is not None
     assert openpal.UTCTimestamp(900) is not None
     assert openpal.LogEntry("123", openpal.LogFilters(), "location 1",
                             "test") is not None
     assert openpal.LogFilters(20) is not None
     assert openpal.LoggerSettings("234", openpal.LogFilters())
Esempio n. 10
0
        # must be declared.
        pass

    def End(self):
        # This is implementing an interface, so this function
        # must be declared.
        pass


values = {'analog': [], 'binary': []}

print("Starting")

# Create the manager for DNP3. This is always the first thing you
# need to do for OpenDNP3.
log_handler = asiodnp3.ConsoleLogger().Create()
manager = asiodnp3.DNP3Manager(1, log_handler)
retry = asiopal.ChannelRetry().Default()
listener = asiodnp3.PrintingChannelListener().Create()
channel = manager.AddTCPClient('client', opendnp3.levels.NOTHING, retry,
                               '192.168.69.166', '0.0.0.0', 20000, listener)

soe_handler = SOEHandler()
soe_handler.values = values

master_application = asiodnp3.DefaultMasterApplication().Create()
stack_config = asiodnp3.MasterStackConfig()
stack_config.master.responseTimeout = openpal.TimeDuration().Seconds(2)
stack_config.link.RemoteAddr = 10
master = channel.AddMaster('master', soe_handler, master_application,
                           stack_config)