├── .gitignore ├── AUTHORS ├── CHANGELOG.markdown ├── COPYING ├── ChangeLog ├── FILE_LICENSE ├── INSTALL ├── Makefile.am ├── NEWS ├── NOTICE ├── README ├── config ├── JNI_INCLUDES.props ├── JNI_INCLUDES.vsprops ├── astyle.cfg ├── autotools │ ├── m4 │ │ ├── ax_boost_asio.m4 │ │ ├── ax_boost_base.m4 │ │ ├── ax_boost_date_time.m4 │ │ ├── ax_boost_filesystem.m4 │ │ ├── ax_boost_iostreams.m4 │ │ ├── ax_boost_program_options.m4 │ │ ├── ax_boost_python.m4 │ │ ├── ax_boost_regex.m4 │ │ ├── ax_boost_serialization.m4 │ │ ├── ax_boost_signals.m4 │ │ ├── ax_boost_system.m4 │ │ ├── ax_boost_test_exec_monitor.m4 │ │ ├── ax_boost_thread.m4 │ │ ├── ax_boost_unit_test_framework.m4 │ │ ├── ax_boost_wave.m4 │ │ ├── ax_boost_wserialization.m4 │ │ ├── ax_cxx_check_lib.m4 │ │ ├── ax_cxx_have_sstream.m4 │ │ ├── ax_cxx_have_std.m4 │ │ ├── ax_cxx_have_stl.m4 │ │ ├── ax_cxx_ldflags_std_lang.m4 │ │ ├── ax_cxx_namespaces.m4 │ │ ├── ax_lang_compiler_ms.m4 │ │ ├── ax_libtoolize_cflags.m4 │ │ ├── ax_pkg_swig.m4 │ │ ├── ax_prog_doxygen.m4 │ │ ├── ax_python_devel.m4 │ │ ├── ax_swig_enable_cxx.m4 │ │ ├── ax_swig_multi_module_support.m4 │ │ └── ax_swig_python.m4 │ └── mk │ │ ├── doxygen.mak │ │ └── lcov.mak ├── boost_includes.props ├── boost_includes.vsprops ├── boost_lib.props ├── boost_lib.vsprops ├── boost_lib_64.props ├── boost_lib_64.vsprops ├── common_boost_defines.props ├── common_boost_defines.vsprops ├── disable_specific_warnings.props ├── disable_specific_warnings.vsprops ├── doxygen.config.in ├── local_dir.props ├── local_dir.vsprops ├── output_dirs.props ├── output_dirs.vsprops ├── src-footer.inc └── src-header.inc ├── configure.ac ├── demos ├── master-cpp │ ├── DemoMain.cpp │ ├── MasterDemo.cpp │ └── MasterDemo.h └── slave-cpp │ ├── DemoMain.cpp │ ├── SlaveDemo.cpp │ └── SlaveDemo.h ├── docs ├── .gitignore ├── ChapterAPIs.xml ├── ChapterAboutDNP3.xml ├── ChapterExamples.xml ├── ChapterTheoryOfOperation.xml ├── ChapterUserApplications.xml ├── TestSetUserManual.docx ├── app1.xml ├── bibliography.xml ├── fdl.xml ├── glossary.xml └── main.xml ├── java ├── pom.xml └── src │ └── test │ └── scala │ └── org │ └── totalgrid │ └── dnp3 │ ├── DNP3BindingTest.scala │ └── mock │ ├── CachingResponseAcceptor.scala │ ├── CountingPublisher.scala │ ├── InstantCommandAcceptor.scala │ ├── MockCommandAcceptor.scala │ └── MockDataObserver.scala ├── profile ├── DNP3DeviceProfileJan2010.xslt ├── README ├── UserData.xslt ├── dnp_logo.jpg ├── open_dnp3_slave.xml └── output │ └── profile.html ├── schema ├── APL.xsd ├── CSToCppXMLBinder.exe ├── DNP.xsd ├── MasterTestSet.xsd ├── ReBuildCSharpFromSchema.bat └── SlaveTestSet.xsd ├── src ├── opendnp3 │ ├── APL │ │ ├── ASIOSerialHelpers.cpp │ │ ├── ASIOSerialHelpers.h │ │ ├── AsyncLayerInterfaces.cpp │ │ ├── AsyncLayerInterfaces.h │ │ ├── AsyncResult.cpp │ │ ├── AsyncResult.h │ │ ├── AsyncTaskBase.cpp │ │ ├── AsyncTaskBase.h │ │ ├── AsyncTaskContinuous.cpp │ │ ├── AsyncTaskContinuous.h │ │ ├── AsyncTaskGroup.cpp │ │ ├── AsyncTaskGroup.h │ │ ├── AsyncTaskInterfaces.h │ │ ├── AsyncTaskNonPeriodic.cpp │ │ ├── AsyncTaskNonPeriodic.h │ │ ├── AsyncTaskPeriodic.cpp │ │ ├── AsyncTaskPeriodic.h │ │ ├── AsyncTaskScheduler.cpp │ │ ├── AsyncTaskScheduler.h │ │ ├── BaseDataTypes.cpp │ │ ├── BaseDataTypes.h │ │ ├── BoundNotifier.h │ │ ├── CRC.cpp │ │ ├── CRC.h │ │ ├── CachedLogVariable.h │ │ ├── ChangeBuffer.h │ │ ├── CommandInterfaces.h │ │ ├── CommandManager.cpp │ │ ├── CommandManager.h │ │ ├── CommandQueue.cpp │ │ ├── CommandQueue.h │ │ ├── CommandResponseQueue.cpp │ │ ├── CommandResponseQueue.h │ │ ├── CommandTypes.cpp │ │ ├── CommandTypes.h │ │ ├── Configure.h │ │ ├── CopyableBuffer.cpp │ │ ├── CopyableBuffer.h │ │ ├── DataInterfaces.h │ │ ├── DataTypes.h │ │ ├── DeleteAny.h │ │ ├── EventLock.cpp │ │ ├── EventLock.h │ │ ├── EventLockBase.h │ │ ├── EventSet.h │ │ ├── Exception.cpp │ │ ├── Exception.h │ │ ├── FlexibleDataObserver.cpp │ │ ├── FlexibleDataObserver.h │ │ ├── Function.h │ │ ├── GetKeys.h │ │ ├── IEventLock.h │ │ ├── IHandlerAsync.cpp │ │ ├── IHandlerAsync.h │ │ ├── INotifier.h │ │ ├── IOService.cpp │ │ ├── IOService.h │ │ ├── IOServiceThread.cpp │ │ ├── IOServiceThread.h │ │ ├── IPhysicalLayerAsync.h │ │ ├── IPhysicalLayerObserver.h │ │ ├── IPhysicalLayerSource.h │ │ ├── ISubject.h │ │ ├── ITimeSource.h │ │ ├── ITimer.h │ │ ├── ITimerSource.cpp │ │ ├── ITimerSource.h │ │ ├── ITransactable.h │ │ ├── Lock.h │ │ ├── LockBase.cpp │ │ ├── LockBase.h │ │ ├── LockBoost.cpp │ │ ├── LockBoost.h │ │ ├── Log.cpp │ │ ├── Log.h │ │ ├── LogBase.h │ │ ├── LogEntry.cpp │ │ ├── LogEntry.h │ │ ├── LogEntryCircularBuffer.cpp │ │ ├── LogEntryCircularBuffer.h │ │ ├── LogToFile.cpp │ │ ├── LogToFile.h │ │ ├── LogToStdio.cpp │ │ ├── LogToStdio.h │ │ ├── LogTypes.cpp │ │ ├── LogTypes.h │ │ ├── LogVar.h │ │ ├── Loggable.cpp │ │ ├── Loggable.h │ │ ├── Logger.cpp │ │ ├── Logger.h │ │ ├── LowerLayerToPhysAdapter.cpp │ │ ├── LowerLayerToPhysAdapter.h │ │ ├── MetricBuffer.cpp │ │ ├── MetricBuffer.h │ │ ├── MultiplexingDataObserver.cpp │ │ ├── MultiplexingDataObserver.h │ │ ├── Notifier.h │ │ ├── PackingTemplates.h │ │ ├── PackingUnpacking.cpp │ │ ├── PackingUnpacking.h │ │ ├── Parsing.cpp │ │ ├── Parsing.h │ │ ├── PhysLayerSettings.h │ │ ├── PhysLoopback.cpp │ │ ├── PhysLoopback.h │ │ ├── PhysicalLayerAsyncASIO.h │ │ ├── PhysicalLayerAsyncBase.cpp │ │ ├── PhysicalLayerAsyncBase.h │ │ ├── PhysicalLayerAsyncBaseTCP.cpp │ │ ├── PhysicalLayerAsyncBaseTCP.h │ │ ├── PhysicalLayerAsyncSerial.cpp │ │ ├── PhysicalLayerAsyncSerial.h │ │ ├── PhysicalLayerAsyncTCPClient.cpp │ │ ├── PhysicalLayerAsyncTCPClient.h │ │ ├── PhysicalLayerAsyncTCPServer.cpp │ │ ├── PhysicalLayerAsyncTCPServer.h │ │ ├── PhysicalLayerFactory.cpp │ │ ├── PhysicalLayerFactory.h │ │ ├── PhysicalLayerFunctors.h │ │ ├── PhysicalLayerInstance.cpp │ │ ├── PhysicalLayerInstance.h │ │ ├── PhysicalLayerManager.cpp │ │ ├── PhysicalLayerManager.h │ │ ├── PhysicalLayerMap.cpp │ │ ├── PhysicalLayerMap.h │ │ ├── PhysicalLayerMonitor.cpp │ │ ├── PhysicalLayerMonitor.h │ │ ├── PhysicalLayerMonitorStates.cpp │ │ ├── PhysicalLayerMonitorStates.h │ │ ├── PhysicalLayerStates.cpp │ │ ├── PhysicalLayerStates.h │ │ ├── PostingNotifier.cpp │ │ ├── PostingNotifier.h │ │ ├── PostingNotifierSource.cpp │ │ ├── PostingNotifierSource.h │ │ ├── ProtocolUtil.cpp │ │ ├── ProtocolUtil.h │ │ ├── QualityConverter.cpp │ │ ├── QualityConverter.h │ │ ├── QualityMasks.h │ │ ├── QueueingFDO.h │ │ ├── Random.h │ │ ├── RandomDouble.h │ │ ├── RandomizedBuffer.cpp │ │ ├── RandomizedBuffer.h │ │ ├── SerialTypes.h │ │ ├── ShiftableBuffer.cpp │ │ ├── ShiftableBuffer.h │ │ ├── Singleton.h │ │ ├── SubjectBase.h │ │ ├── SuspendTimerSource.cpp │ │ ├── SuspendTimerSource.h │ │ ├── SyncVar.h │ │ ├── Thread.h │ │ ├── ThreadBase.cpp │ │ ├── ThreadBase.h │ │ ├── ThreadBoost.cpp │ │ ├── ThreadBoost.h │ │ ├── Threadable.cpp │ │ ├── Threadable.h │ │ ├── TimeBase.cpp │ │ ├── TimeBase.h │ │ ├── TimeBoost.cpp │ │ ├── TimeBoost.h │ │ ├── TimeSource.cpp │ │ ├── TimeSource.h │ │ ├── TimeTypes.h │ │ ├── Timeout.cpp │ │ ├── Timeout.h │ │ ├── TimerASIO.cpp │ │ ├── TimerASIO.h │ │ ├── TimerSourceASIO.cpp │ │ ├── TimerSourceASIO.h │ │ ├── TimingTools.cpp │ │ ├── TimingTools.h │ │ ├── ToHex.cpp │ │ ├── ToHex.h │ │ ├── TrackingTaskGroup.cpp │ │ ├── TrackingTaskGroup.h │ │ ├── Types.h │ │ ├── Uncopyable.h │ │ ├── Util.cpp │ │ ├── Util.h │ │ └── test │ │ │ ├── AsyncPhysBaseTest.cpp │ │ │ ├── AsyncPhysBaseTest.h │ │ │ ├── AsyncSerialTestObject.cpp │ │ │ ├── AsyncSerialTestObject.h │ │ │ ├── TestASIO.cpp │ │ │ ├── TestAsyncTask.cpp │ │ │ ├── TestCastLongLongDouble.cpp │ │ │ ├── TestCommandQueue.cpp │ │ │ ├── TestCommandTypes.cpp │ │ │ ├── TestLocks.cpp │ │ │ ├── TestLog.cpp │ │ │ ├── TestMisc.cpp │ │ │ ├── TestPackingUnpacking.cpp │ │ │ ├── TestParsing.cpp │ │ │ ├── TestPhysicalLayerAsyncBase.cpp │ │ │ ├── TestPhysicalLayerAsyncSerial.cpp │ │ │ ├── TestPhysicalLayerAsyncTCP.cpp │ │ │ ├── TestPhysicalLayerLoopback.cpp │ │ │ ├── TestPhysicalLayerMonitor.cpp │ │ │ ├── TestQualityMasks.cpp │ │ │ ├── TestShiftableBuffer.cpp │ │ │ ├── TestSyncVar.cpp │ │ │ ├── TestThreading.cpp │ │ │ ├── TestTime.cpp │ │ │ ├── TestTimers.cpp │ │ │ ├── TestTypes.cpp │ │ │ ├── TestUtil.cpp │ │ │ ├── TestXmlBinding.cpp │ │ │ └── util │ │ │ ├── AsyncPhysTestObject.cpp │ │ │ ├── AsyncPhysTestObject.h │ │ │ ├── AsyncTestObject.cpp │ │ │ ├── AsyncTestObject.h │ │ │ ├── AsyncTestObjectASIO.cpp │ │ │ ├── AsyncTestObjectASIO.h │ │ │ ├── BufferHelpers.cpp │ │ │ ├── BufferHelpers.h │ │ │ ├── BufferTestObject.cpp │ │ │ ├── BufferTestObject.h │ │ │ ├── FanoutDataObserver.h │ │ │ ├── LogTester.cpp │ │ │ ├── LogTester.h │ │ │ ├── LoopbackPhysicalLayerAsync.cpp │ │ │ ├── LoopbackPhysicalLayerAsync.h │ │ │ ├── MockCommandAcceptor.h │ │ │ ├── MockCommandHandler.h │ │ │ ├── MockLogSubscriber.h │ │ │ ├── MockLowerLayer.cpp │ │ │ ├── MockLowerLayer.h │ │ │ ├── MockNodeSaver.h │ │ │ ├── MockNotifier.h │ │ │ ├── MockPhysicalLayerAsync.cpp │ │ │ ├── MockPhysicalLayerAsync.h │ │ │ ├── MockPhysicalLayerAsyncTS.cpp │ │ │ ├── MockPhysicalLayerAsyncTS.h │ │ │ ├── MockPhysicalLayerMonitor.cpp │ │ │ ├── MockPhysicalLayerMonitor.h │ │ │ ├── MockPhysicalLayerSource.cpp │ │ │ ├── MockPhysicalLayerSource.h │ │ │ ├── MockResponseAcceptor.cpp │ │ │ ├── MockResponseAcceptor.h │ │ │ ├── MockTimerSource.cpp │ │ │ ├── MockTimerSource.h │ │ │ ├── MockUpperLayer.cpp │ │ │ ├── MockUpperLayer.h │ │ │ ├── PhysicalLayerWrapper.cpp │ │ │ ├── PhysicalLayerWrapper.h │ │ │ ├── PhysicalLayerWrapperFactory.h │ │ │ ├── TestHelpers.h │ │ │ ├── TestTypedefs.h │ │ │ ├── WrappedTcpPipe.cpp │ │ │ └── WrappedTcpPipe.h │ ├── DNP3 │ │ ├── APDU.cpp │ │ ├── APDU.h │ │ ├── APDUConstants.cpp │ │ ├── APDUConstants.h │ │ ├── AlwaysOpeningVtoRouter.cpp │ │ ├── AlwaysOpeningVtoRouter.h │ │ ├── AppChannelStates.cpp │ │ ├── AppChannelStates.h │ │ ├── AppConfig.h │ │ ├── AppHeader.cpp │ │ ├── AppHeader.h │ │ ├── AppInterfaces.cpp │ │ ├── AppInterfaces.h │ │ ├── AppLayer.cpp │ │ ├── AppLayer.h │ │ ├── AppLayerChannel.cpp │ │ ├── AppLayerChannel.h │ │ ├── AsyncStackManager.cpp │ │ ├── AsyncStackManager.h │ │ ├── BufferSetTypes.h │ │ ├── BufferTypes.cpp │ │ ├── BufferTypes.h │ │ ├── CTOHistory.h │ │ ├── ClassCounter.cpp │ │ ├── ClassCounter.h │ │ ├── ClassMask.h │ │ ├── ControlTasks.cpp │ │ ├── ControlTasks.h │ │ ├── DNPCommandMaster.cpp │ │ ├── DNPCommandMaster.h │ │ ├── DNPConstants.h │ │ ├── DNPCrc.cpp │ │ ├── DNPCrc.h │ │ ├── DNPDatabaseTypes.h │ │ ├── DNPExceptions.h │ │ ├── DNPFromStream.h │ │ ├── DNPToStream.h │ │ ├── DataPoll.cpp │ │ ├── DataPoll.h │ │ ├── Database.cpp │ │ ├── Database.h │ │ ├── DatabaseInterfaces.h │ │ ├── DeviceTemplate.cpp │ │ ├── DeviceTemplate.h │ │ ├── DeviceTemplateTypes.h │ │ ├── EnhancedVto.cpp │ │ ├── EnhancedVto.h │ │ ├── EnhancedVtoRouter.cpp │ │ ├── EnhancedVtoRouter.h │ │ ├── EventBufferBase.h │ │ ├── EventBuffers.h │ │ ├── EventTypes.h │ │ ├── HeaderReadIterator.cpp │ │ ├── HeaderReadIterator.h │ │ ├── IFrameSink.h │ │ ├── ILinkContext.h │ │ ├── ILinkRouter.h │ │ ├── IStackObserver.cpp │ │ ├── IStackObserver.h │ │ ├── IVtoEventAcceptor.h │ │ ├── IndexedWriteIterator.cpp │ │ ├── IndexedWriteIterator.h │ │ ├── LinkChannel.cpp │ │ ├── LinkChannel.h │ │ ├── LinkConfig.h │ │ ├── LinkFrame.cpp │ │ ├── LinkFrame.h │ │ ├── LinkHeader.cpp │ │ ├── LinkHeader.h │ │ ├── LinkLayer.cpp │ │ ├── LinkLayer.h │ │ ├── LinkLayerConstants.cpp │ │ ├── LinkLayerConstants.h │ │ ├── LinkLayerReceiver.cpp │ │ ├── LinkLayerReceiver.h │ │ ├── LinkLayerRouter.cpp │ │ ├── LinkLayerRouter.h │ │ ├── LinkReceiverStates.cpp │ │ ├── LinkReceiverStates.h │ │ ├── LinkRoute.cpp │ │ ├── LinkRoute.h │ │ ├── Master.cpp │ │ ├── Master.h │ │ ├── MasterConfig.h │ │ ├── MasterConfigTypes.h │ │ ├── MasterSchedule.cpp │ │ ├── MasterSchedule.h │ │ ├── MasterStack.cpp │ │ ├── MasterStack.h │ │ ├── MasterStackConfig.h │ │ ├── MasterStates.cpp │ │ ├── MasterStates.h │ │ ├── MasterTaskBase.cpp │ │ ├── MasterTaskBase.h │ │ ├── ObjectHeader.cpp │ │ ├── ObjectHeader.h │ │ ├── ObjectInterfaces.cpp │ │ ├── ObjectInterfaces.h │ │ ├── ObjectReadIterator.cpp │ │ ├── ObjectReadIterator.h │ │ ├── ObjectWriteIterator.cpp │ │ ├── ObjectWriteIterator.h │ │ ├── Objects.cpp │ │ ├── Objects.h │ │ ├── PointClass.cpp │ │ ├── PointClass.h │ │ ├── PriLinkLayerStates.cpp │ │ ├── PriLinkLayerStates.h │ │ ├── ResponseContext.cpp │ │ ├── ResponseContext.h │ │ ├── ResponseLoader.cpp │ │ ├── ResponseLoader.h │ │ ├── SecLinkLayerStates.cpp │ │ ├── SecLinkLayerStates.h │ │ ├── Slave.cpp │ │ ├── Slave.h │ │ ├── SlaveConfig.cpp │ │ ├── SlaveConfig.h │ │ ├── SlaveEventBuffer.cpp │ │ ├── SlaveEventBuffer.h │ │ ├── SlaveResponseTypes.cpp │ │ ├── SlaveResponseTypes.h │ │ ├── SlaveStack.cpp │ │ ├── SlaveStack.h │ │ ├── SlaveStackConfig.h │ │ ├── SlaveStates.cpp │ │ ├── SlaveStates.h │ │ ├── SolicitedChannel.cpp │ │ ├── SolicitedChannel.h │ │ ├── Stack.cpp │ │ ├── Stack.h │ │ ├── StackManager.cpp │ │ ├── StackManager.h │ │ ├── StartupTasks.cpp │ │ ├── StartupTasks.h │ │ ├── TLS_Base.cpp │ │ ├── TLS_Base.h │ │ ├── TransportConstants.h │ │ ├── TransportLayer.cpp │ │ ├── TransportLayer.h │ │ ├── TransportRx.cpp │ │ ├── TransportRx.h │ │ ├── TransportStates.cpp │ │ ├── TransportStates.h │ │ ├── TransportTx.cpp │ │ ├── TransportTx.h │ │ ├── UnsolicitedChannel.cpp │ │ ├── UnsolicitedChannel.h │ │ ├── VtoConfig.h │ │ ├── VtoData.cpp │ │ ├── VtoData.h │ │ ├── VtoDataInterface.h │ │ ├── VtoEventBufferAdapter.h │ │ ├── VtoReader.cpp │ │ ├── VtoReader.h │ │ ├── VtoRouter.cpp │ │ ├── VtoRouter.h │ │ ├── VtoRouterManager.cpp │ │ ├── VtoRouterManager.h │ │ ├── VtoRouterSettings.cpp │ │ ├── VtoRouterSettings.h │ │ ├── VtoTransmitTask.cpp │ │ ├── VtoTransmitTask.h │ │ ├── VtoWriter.cpp │ │ ├── VtoWriter.h │ │ └── test │ │ │ ├── AppLayerTest.cpp │ │ │ ├── AppLayerTest.h │ │ │ ├── ComparingDataObserver.cpp │ │ │ ├── ComparingDataObserver.h │ │ │ ├── DNPHelpers.cpp │ │ │ ├── DNPHelpers.h │ │ │ ├── DatabaseTestObject.h │ │ │ ├── IntegrationTest.cpp │ │ │ ├── IntegrationTest.h │ │ │ ├── LinkLayerRouterTest.cpp │ │ │ ├── LinkLayerRouterTest.h │ │ │ ├── LinkLayerTest.cpp │ │ │ ├── LinkLayerTest.h │ │ │ ├── LinkReceiverTest.h │ │ │ ├── MasterTestObject.cpp │ │ │ ├── MasterTestObject.h │ │ │ ├── MockAppLayer.cpp │ │ │ ├── MockAppLayer.h │ │ │ ├── MockAppUser.cpp │ │ │ ├── MockAppUser.h │ │ │ ├── MockFrameSink.cpp │ │ │ ├── MockFrameSink.h │ │ │ ├── QueueingStackObserver.h │ │ │ ├── ReadableVtoWriter.h │ │ │ ├── ResponseLoaderTestObject.cpp │ │ │ ├── ResponseLoaderTestObject.h │ │ │ ├── SlaveTestObject.cpp │ │ │ ├── SlaveTestObject.h │ │ │ ├── StartupTeardownTest.cpp │ │ │ ├── StartupTeardownTest.h │ │ │ ├── TestAPDU.cpp │ │ │ ├── TestAPDUWriting.cpp │ │ │ ├── TestAppLayer.cpp │ │ │ ├── TestCRC.cpp │ │ │ ├── TestDatabase.cpp │ │ │ ├── TestEnhancedVtoRouter.cpp │ │ │ ├── TestEventBufferBase.cpp │ │ │ ├── TestEventBuffers.cpp │ │ │ ├── TestIntegration.cpp │ │ │ ├── TestLinkFrameDNP.cpp │ │ │ ├── TestLinkLayer.cpp │ │ │ ├── TestLinkLayerRouter.cpp │ │ │ ├── TestLinkReceiver.cpp │ │ │ ├── TestLinkRoute.cpp │ │ │ ├── TestMaster.cpp │ │ │ ├── TestObjects.cpp │ │ │ ├── TestResponseLoader.cpp │ │ │ ├── TestSlave.cpp │ │ │ ├── TestSlaveEventBuffer.cpp │ │ │ ├── TestStackManager.cpp │ │ │ ├── TestStartBoostUTF.cpp │ │ │ ├── TestStartupTeardown.cpp │ │ │ ├── TestTransportLayer.cpp │ │ │ ├── TestTransportLoopback.cpp │ │ │ ├── TestTransportScalability.cpp │ │ │ ├── TestVtoInterface.cpp │ │ │ ├── TestVtoLoopbackIntegration.cpp │ │ │ ├── TestVtoOnewayIntegration.cpp │ │ │ ├── TestVtoRouter.cpp │ │ │ ├── TestVtoRouterManager.cpp │ │ │ ├── TestVtoWriter.cpp │ │ │ ├── TransportIntegrationStack.cpp │ │ │ ├── TransportIntegrationStack.h │ │ │ ├── TransportLoopbackTestObject.cpp │ │ │ ├── TransportLoopbackTestObject.h │ │ │ ├── TransportScalabilityTestObject.cpp │ │ │ ├── TransportScalabilityTestObject.h │ │ │ ├── TransportStackPair.cpp │ │ │ ├── TransportStackPair.h │ │ │ ├── TransportTestObject.cpp │ │ │ ├── TransportTestObject.h │ │ │ ├── VtoIntegrationTestBase.cpp │ │ │ └── VtoIntegrationTestBase.h │ ├── terminal │ │ ├── ControlResponseTE.cpp │ │ ├── ControlResponseTE.h │ │ ├── ControlTerminalExtension.cpp │ │ ├── ControlTerminalExtension.h │ │ ├── DOTerminalExtension.cpp │ │ ├── DOTerminalExtension.h │ │ ├── FlexibleObserverTerminalExtension.cpp │ │ ├── FlexibleObserverTerminalExtension.h │ │ ├── LineReader.cpp │ │ ├── LineReader.h │ │ ├── LogTerminalExtension.cpp │ │ ├── LogTerminalExtension.h │ │ ├── PhysicalLayerIOStreamAsync.cpp │ │ ├── PhysicalLayerIOStreamAsync.h │ │ ├── PhysicalLayerSyncProxy.cpp │ │ ├── PhysicalLayerSyncProxy.h │ │ ├── Terminal.cpp │ │ ├── Terminal.h │ │ ├── TerminalInterfaces.cpp │ │ ├── TerminalInterfaces.h │ │ ├── TokenNode.h │ │ └── test │ │ │ ├── TestPhysicalLayerSyncProxy.cpp │ │ │ └── TestTerminal.cpp │ ├── testset │ │ ├── AddressScanner.cpp │ │ ├── AddressScanner.h │ │ ├── StackHelpers.cpp │ │ ├── StackHelpers.h │ │ └── main.cpp │ └── xml │ │ ├── APL │ │ ├── INodeSaver.h │ │ ├── PhysicalLayerManagerXML.cpp │ │ ├── PhysicalLayerManagerXML.h │ │ ├── PhysicalLayerXMLFactory.cpp │ │ ├── PhysicalLayerXMLFactory.h │ │ ├── SingleNodeSaver.h │ │ ├── XMLConversion.cpp │ │ ├── XMLConversion.h │ │ ├── XML_APL.cpp │ │ ├── XML_APL.h │ │ ├── tinybinding.cpp │ │ └── tinybinding.h │ │ ├── DNP3 │ │ ├── XML_DNP3.cpp │ │ ├── XML_DNP3.h │ │ ├── XML_TestSet.cpp │ │ ├── XML_TestSet.h │ │ ├── XmlToConfig.cpp │ │ └── XmlToConfig.h │ │ └── binding │ │ ├── APLXML_Base.cpp │ │ ├── APLXML_Base.h │ │ ├── APLXML_DNP.cpp │ │ ├── APLXML_DNP.h │ │ ├── APLXML_MTS.cpp │ │ ├── APLXML_MTS.h │ │ ├── APLXML_STS.cpp │ │ └── APLXML_STS.h └── tinyxml │ ├── tinystr.cpp │ ├── tinystr.h │ ├── tinyxml.cpp │ ├── tinyxml.h │ ├── tinyxmlerror.cpp │ └── tinyxmlparser.cpp ├── swig └── swigDNP3.i ├── teamcity ├── teamcity_boost.cpp ├── teamcity_messages.cpp └── teamcity_messages.h ├── tools └── install_scripts │ ├── boost │ ├── 1_43 │ │ ├── install-boost.bat │ │ └── install-boost.sh │ ├── 1_46_1 │ │ ├── install-boost.bat │ │ └── install-boost.sh │ └── 1_47_0 │ │ ├── install-boost-64.bat │ │ ├── install-boost.bat │ │ └── install-boost.sh │ └── crosstool │ └── install-crosstool.sh ├── version.hpp ├── vstudio10 ├── APL.vcxproj ├── APL.vcxproj.filters ├── APLTestTools.vcxproj ├── APLTestTools.vcxproj.filters ├── APLXML.vcxproj ├── APLXML.vcxproj.filters ├── DNP.sln ├── DNP3.vcxproj ├── DNP3.vcxproj.filters ├── DNP3Java.vcxproj ├── DNP3Java.vcxproj.filters ├── DNP3Test.vcxproj ├── DNP3Test.vcxproj.filters ├── DNP3XML.vcxproj ├── DNP3XML.vcxproj.filters ├── MasterDemo.vcxproj ├── MasterDemo.vcxproj.filters ├── SlaveDemo.vcxproj ├── SlaveDemo.vcxproj.filters ├── Terminal.vcxproj ├── Terminal.vcxproj.filters ├── TerminalTest.vcxproj ├── TerminalTest.vcxproj.filters ├── TestAPL.vcxproj ├── TestAPL.vcxproj.filters ├── TestSet.vcxproj ├── TestSet.vcxproj.filters ├── XMLBindings.vcxproj ├── XMLBindings.vcxproj.filters ├── tinyxml.vcxproj └── tinyxml.vcxproj.filters └── windows ├── BoostLibs └── x86 │ ├── boost_date_time-vc100-mt-1_47.dll │ ├── boost_system-vc100-mt-1_47.dll │ └── boost_thread-vc100-mt-1_47.dll ├── CSToCppXMLBinder ├── Bind.cs ├── CSToCppXMLBinder.csproj └── CppBinder.cs ├── DotNetAdapter ├── AssemblyInfo.cpp ├── CommandAcceptorAdapter.cpp ├── CommandAcceptorAdapter.h ├── Conversions.cpp ├── Conversions.h ├── DotNetAdapter.vcxproj ├── DotNetAdapter.vcxproj.filters ├── FilterLevel.h ├── LogAdapter.cpp ├── LogAdapter.h ├── MasterDataObserverAdapter.cpp ├── MasterDataObserverAdapter.h ├── ReadMe.txt ├── SlaveCommandAcceptorAdapter.cpp ├── SlaveCommandAcceptorAdapter.h ├── SlaveDataObserverAdapter.cpp ├── SlaveDataObserverAdapter.h ├── StackManager.cpp ├── StackManager.h ├── Stdafx.cpp ├── Stdafx.h ├── app.aps ├── app.ico ├── app.rc └── resource.h ├── DotNetInterface ├── CommandTypes.cs ├── ConfigObjects.cs ├── Conversions.cs ├── DataTypes.cs ├── DotNetInterface.csproj ├── ICommandAcceptor.cs ├── IDataObserver.cs ├── IFuture.cs ├── ILogHandler.cs ├── LogTypes.cs ├── Properties │ └── AssemblyInfo.cs ├── SerialSettings.cs └── Tests │ └── ConfigSerializationTestSuite.cs ├── DotNetMasterDemo ├── DotNetMasterDemo.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── DotNetSlaveDemo ├── DotNetSlaveDemo.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── DotNetTestSet ├── DisplayAdapterDataObserver.cs ├── DotNetTestSet.csproj ├── LogControlAdapter.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── TestSetForm.Designer.cs ├── TestSetForm.cs └── TestSetForm.resx ├── DotNetTestSetInstaller └── DotNetTestSetInstaller.vdproj ├── TestSetControlLibrary ├── FilterLevelComboBox.cs ├── FlickerFreeListView.cs ├── IMeasurementSource.cs ├── LinkLayerSettingsControl.Designer.cs ├── LinkLayerSettingsControl.cs ├── LinkLayerSettingsControl.resx ├── LogControl.Designer.cs ├── LogControl.cs ├── LogControl.resx ├── MasterDataDisplay.Designer.cs ├── MasterDataDisplay.cs ├── MasterDataDisplay.resx ├── MasterSettingsForm.Designer.cs ├── MasterSettingsForm.cs ├── MasterSettingsForm.resx ├── Properties │ └── AssemblyInfo.cs ├── SerialSettingsForm.Designer.cs ├── SerialSettingsForm.cs ├── SerialSettingsForm.resx ├── SetpointForm.Designer.cs ├── SetpointForm.cs ├── SetpointForm.resx ├── StackBrowser.Designer.cs ├── StackBrowser.cs ├── StackBrowser.resx ├── StackDisplayControl.Designer.cs ├── StackDisplayControl.cs ├── StackDisplayControl.resx ├── TcpClientSettings.cs ├── TcpSettingsForm.Designer.cs ├── TcpSettingsForm.cs ├── TcpSettingsForm.resx ├── TestSetControlLibrary.csproj ├── TimeSeriesChartForm.Designer.cs ├── TimeSeriesChartForm.cs └── TimeSeriesChartForm.resx └── TestSetInstaller ├── EULA.RTF ├── TestSetInstaller.vdproj └── icons ├── dnp_banner.bmp ├── square_dnp_16.ico ├── square_dnp_32.ico └── square_dnp_48.ico /.gitignore: -------------------------------------------------------------------------------- 1 | dnp3testset 2 | test-apl 3 | test-dnp3 4 | test-terminal 5 | demo-master-cpp 6 | demo-slave-cpp 7 | 8 | *.a 9 | *.gcda 10 | *.gcno 11 | *.iml 12 | *.la 13 | *.lo 14 | *.log 15 | *.map 16 | *.o 17 | *.opensdf 18 | *.sdf 19 | *.so 20 | *.user 21 | *~ 22 | .*.swp 23 | *.ncb 24 | *.suo 25 | .DS_Store 26 | .deps 27 | .dirstamp 28 | .idea 29 | .libs 30 | .DS_Store 31 | 32 | JavaDNP3.cpp 33 | JavaDNP3.h 34 | PythonDNP3.cpp 35 | PythonDNP3.h 36 | 37 | /maven/ 38 | /swig/.java-built 39 | 40 | /*/pc_linux_arm 41 | /schema/*.cs 42 | /schema/*.xsx 43 | /TestSet/*.xml 44 | /coverage-* 45 | /doc 46 | /lcov 47 | /org 48 | /tools/boostlib 49 | /tools/install_scripts/boost/*/temp 50 | Debug 51 | Release 52 | TestAPL/TestSingle.tiny.xml 53 | TestSingle.tiny.xml 54 | ipch 55 | pc_cygwin 56 | 57 | 58 | __init__.py 59 | __init__.pyc 60 | pyopendnp3.py 61 | pyopendnp3.pyc 62 | 63 | /autom4te.cache 64 | /build-aux 65 | /config/autotools/m4/libtool.m4 66 | /config/autotools/m4/ltoptions.m4 67 | /config/autotools/m4/ltsugar.m4 68 | /config/autotools/m4/ltversion.m4 69 | /config/autotools/m4/lt~obsolete.m4 70 | /configure 71 | Makefile 72 | Makefile.in 73 | aclocal.m4 74 | compile.log 75 | config.h 76 | config.h.in 77 | config.log 78 | config.status 79 | configure 80 | configure.in 81 | libtool 82 | stamp-h1 83 | 84 | *target* 85 | 86 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/AUTHORS -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | See CHANGELOG.markdown. 2 | -------------------------------------------------------------------------------- /FILE_LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Licensed to Green Energy Corp (www.greenenergycorp.com) under one or 3 | more contributor license agreements. See the NOTICE file distributed 4 | with this work for additional information regarding copyright ownership. 5 | Green Energy Corp licenses this file to you under the Apache License, 6 | Version 2.0 (the "License"); you may not use this file except in 7 | compliance with the License. You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/NEWS -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file corresponding to the section 4 d of == 3 | == the Apache License, Version 2.0, == 4 | == in this case for the Green Energy Corp DNP3 distribution. == 5 | ========================================================================= 6 | 7 | This product includes software developed by Green Energy Corp 8 | (http://www.greenenergycorp.com/). 9 | 10 | Please read the LICENSE file present in the root directory of this 11 | distribution. 12 | 13 | Aside from contributions to the Green Energy Corporation DNP3 distribution, this software also 14 | includes: 15 | tinyxml (http://sourceforge.net/projects/tinyxml/) 16 | - Modified source distribution derived from release 2.5.3 17 | - http://www.opensource.org/licenses/zlib-license.php 18 | 19 | Project requires, not packaged: 20 | * boost version 1.43 or later under the Boost Software License, and 21 | can be downloaded from http://www.boost.org 22 | 23 | 24 | -------------------------------------------------------------------------------- /config/JNI_INCLUDES.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | $(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/JNI_INCLUDES.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/astyle.cfg: -------------------------------------------------------------------------------- 1 | # don't create backup files 2 | --style=linux 3 | --suffix=none 4 | --indent=tab 5 | #--lineend=linux 6 | --indent-cases 7 | --pad-oper 8 | --keep-one-line-statements 9 | --keep-one-line-blocks 10 | --align-pointer=type 11 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_cxx_have_sstream.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_have_sstream.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_HAVE_SSTREAM 8 | # 9 | # DESCRIPTION 10 | # 11 | # If the C++ library has a working stringstream, define HAVE_SSTREAM. 12 | # 13 | # LICENSE 14 | # 15 | # Copyright (c) 2008 Ben Stanley 16 | # 17 | # Copying and distribution of this file, with or without modification, are 18 | # permitted in any medium without royalty provided the copyright notice 19 | # and this notice are preserved. This file is offered as-is, without any 20 | # warranty. 21 | 22 | #serial 6 23 | 24 | AU_ALIAS([AC_CXX_HAVE_SSTREAM], [AX_CXX_HAVE_SSTREAM]) 25 | AC_DEFUN([AX_CXX_HAVE_SSTREAM], 26 | [AC_CACHE_CHECK(whether the compiler has stringstream, 27 | ax_cv_cxx_have_sstream, 28 | [AC_REQUIRE([AX_CXX_NAMESPACES]) 29 | AC_LANG_SAVE 30 | AC_LANG_CPLUSPLUS 31 | AC_TRY_COMPILE([#include 32 | #ifdef HAVE_NAMESPACES 33 | using namespace std; 34 | #endif],[stringstream message; message << "Hello"; return 0;], 35 | ax_cv_cxx_have_sstream=yes, ax_cv_cxx_have_sstream=no) 36 | AC_LANG_RESTORE 37 | ]) 38 | if test "$ax_cv_cxx_have_sstream" = yes; then 39 | AC_DEFINE(HAVE_SSTREAM,,[define if the compiler has stringstream]) 40 | fi 41 | ]) 42 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_cxx_have_std.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_have_std.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_HAVE_STD 8 | # 9 | # DESCRIPTION 10 | # 11 | # If the compiler supports ISO C++ standard library (i.e., can include the 12 | # files iostream, map, iomanip and cmath), define HAVE_STD. 13 | # 14 | # LICENSE 15 | # 16 | # Copyright (c) 2008 Todd Veldhuizen 17 | # Copyright (c) 2008 Luc Maisonobe 18 | # 19 | # Copying and distribution of this file, with or without modification, are 20 | # permitted in any medium without royalty provided the copyright notice 21 | # and this notice are preserved. This file is offered as-is, without any 22 | # warranty. 23 | 24 | #serial 6 25 | 26 | AU_ALIAS([AC_CXX_HAVE_STD], [AX_CXX_HAVE_STD]) 27 | AC_DEFUN([AX_CXX_HAVE_STD], 28 | [AC_CACHE_CHECK(whether the compiler supports ISO C++ standard library, 29 | ax_cv_cxx_have_std, 30 | [AC_REQUIRE([AX_CXX_NAMESPACES]) 31 | AC_LANG_SAVE 32 | AC_LANG_CPLUSPLUS 33 | AC_TRY_COMPILE([#include 34 | #include 35 | #include 36 | #include 37 | #ifdef HAVE_NAMESPACES 38 | using namespace std; 39 | #endif],[return 0;], 40 | ax_cv_cxx_have_std=yes, ax_cv_cxx_have_std=no) 41 | AC_LANG_RESTORE 42 | ]) 43 | if test "$ax_cv_cxx_have_std" = yes; then 44 | AC_DEFINE(HAVE_STD,,[define if the compiler supports ISO C++ standard library]) 45 | fi 46 | ]) 47 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_cxx_have_stl.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_have_stl.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_HAVE_STL 8 | # 9 | # DESCRIPTION 10 | # 11 | # If the compiler supports the Standard Template Library, define HAVE_STL. 12 | # 13 | # LICENSE 14 | # 15 | # Copyright (c) 2008 Todd Veldhuizen 16 | # Copyright (c) 2008 Luc Maisonobe 17 | # 18 | # Copying and distribution of this file, with or without modification, are 19 | # permitted in any medium without royalty provided the copyright notice 20 | # and this notice are preserved. This file is offered as-is, without any 21 | # warranty. 22 | 23 | #serial 6 24 | 25 | AU_ALIAS([AC_CXX_HAVE_STL], [AX_CXX_HAVE_STL]) 26 | AC_DEFUN([AX_CXX_HAVE_STL], 27 | [AC_CACHE_CHECK(whether the compiler supports Standard Template Library, 28 | ax_cv_cxx_have_stl, 29 | [AC_REQUIRE([AX_CXX_NAMESPACES]) 30 | AC_LANG_SAVE 31 | AC_LANG_CPLUSPLUS 32 | AC_TRY_COMPILE([#include 33 | #include 34 | #ifdef HAVE_NAMESPACES 35 | using namespace std; 36 | #endif],[list x; x.push_back(5); 37 | list::iterator iter = x.begin(); if (iter != x.end()) ++iter; return 0;], 38 | ax_cv_cxx_have_stl=yes, ax_cv_cxx_have_stl=no) 39 | AC_LANG_RESTORE 40 | ]) 41 | if test "$ax_cv_cxx_have_stl" = yes; then 42 | AC_DEFINE(HAVE_STL,,[define if the compiler supports Standard Template Library]) 43 | fi 44 | ]) 45 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_cxx_ldflags_std_lang.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_ldflags_std_lang.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_LDFLAGS_STD_LANG(LD-FLAGS) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Append to LD-FLAGS the set of link-time flags that should be passed to 12 | # the C++ compiler in order to enable use of C++ features as defined in 13 | # the ANSI C++ standard (eg. use of standard iostream classes in the `std' 14 | # namespace, etc.). Note that if you use GNU Libtool you may need to 15 | # prefix each of those switches with `-Xlinker' so that Libtool doesn't 16 | # discard them (see Libtool's manual and `AC_LIBTOOLIZE_LDFLAGS'). 17 | # 18 | # LICENSE 19 | # 20 | # Copyright (c) 2008 Ludovic Courtes 21 | # 22 | # Copying and distribution of this file, with or without modification, are 23 | # permitted in any medium without royalty provided the copyright notice 24 | # and this notice are preserved. This file is offered as-is, without any 25 | # warranty. 26 | 27 | #serial 7 28 | 29 | AU_ALIAS([AC_CXX_LDFLAGS_STD_LANG], [AX_CXX_LDFLAGS_STD_LANG]) 30 | AC_DEFUN([AX_CXX_LDFLAGS_STD_LANG], 31 | [AC_LANG_ASSERT([C++]) 32 | AC_REQUIRE([AX_COMPILER_VENDOR]) 33 | case "$ax_cv_cxx_compiler_vendor" in 34 | sgi) $1="$$1 -LANG:std -exceptions";; 35 | hp) $1="$$1 -AA";; 36 | esac]) 37 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_cxx_namespaces.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_namespace_std.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_NAMESPACE_STD 8 | # 9 | # DESCRIPTION 10 | # 11 | # If the compiler supports namespace std, define HAVE_NAMESPACE_STD. 12 | # 13 | # LICENSE 14 | # 15 | # Copyright (c) 2009 Todd Veldhuizen 16 | # Copyright (c) 2009 Luc Maisonobe 17 | # 18 | # Copying and distribution of this file, with or without modification, are 19 | # permitted in any medium without royalty provided the copyright notice 20 | # and this notice are preserved. This file is offered as-is, without any 21 | # warranty. 22 | 23 | #serial 6 24 | 25 | AU_ALIAS([AC_CXX_NAMESPACE_STD], [AX_CXX_NAMESPACE_STD]) 26 | AC_DEFUN([AX_CXX_NAMESPACE_STD], [ 27 | AC_CACHE_CHECK(if g++ supports namespace std, 28 | ax_cv_cxx_have_std_namespace, 29 | [AC_LANG_SAVE 30 | AC_LANG_CPLUSPLUS 31 | AC_TRY_COMPILE([#include 32 | std::istream& is = std::cin;],, 33 | ax_cv_cxx_have_std_namespace=yes, ax_cv_cxx_have_std_namespace=no) 34 | AC_LANG_RESTORE 35 | ]) 36 | if test "$ax_cv_cxx_have_std_namespace" = yes; then 37 | AC_DEFINE(HAVE_NAMESPACE_STD,,[Define if g++ supports namespace std. ]) 38 | fi 39 | ]) 40 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_lang_compiler_ms.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_lang_compiler_ms.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_LANG_COMPILER_MS 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the compiler for the current language is Microsoft. 12 | # 13 | # This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU Autoconf 14 | # implementation. 15 | # 16 | # LICENSE 17 | # 18 | # Copyright (c) 2009 Braden McDaniel 19 | # 20 | # Copying and distribution of this file, with or without modification, are 21 | # permitted in any medium without royalty provided the copyright notice 22 | # and this notice are preserved. This file is offered as-is, without any 23 | # warranty. 24 | 25 | #serial 8 26 | 27 | AC_DEFUN([AX_LANG_COMPILER_MS], 28 | [AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler], 29 | [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms], 30 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER 31 | choke me 32 | #endif 33 | ]])], 34 | [ax_compiler_ms=yes], 35 | [ax_compiler_ms=no]) 36 | ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms 37 | ])]) 38 | -------------------------------------------------------------------------------- /config/autotools/m4/ax_libtoolize_cflags.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_libtoolize_cflags.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_LIBTOOLIZE_CFLAGS(COMPILER-FLAGS-VAR) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Change the contents of variable COMPILER-FLAGS-VAR so that they are 12 | # Libtool friendly, ie. prefix each of them with `-Xcompiler' so that 13 | # Libtool doesn't remove them. 14 | # 15 | # LICENSE 16 | # 17 | # Copyright (c) 2008 Ludovic Courtes 18 | # 19 | # Copying and distribution of this file, with or without modification, are 20 | # permitted in any medium without royalty provided the copyright notice 21 | # and this notice are preserved. This file is offered as-is, without any 22 | # warranty. 23 | 24 | #serial 5 25 | 26 | AU_ALIAS([AC_LIBTOOLIZE_CFLAGS], [AX_LIBTOOLIZE_CFLAGS]) 27 | AC_DEFUN([AX_LIBTOOLIZE_CFLAGS], 28 | [ac_libtoolize_ldflags_temp="" 29 | for i in $$1 30 | do 31 | ac_libtoolize_ldflags_temp="$ac_libtoolize_ldflags_temp -Xcompiler $i" 32 | done 33 | $1="$ac_libtoolize_ldflags_temp"])dnl 34 | -------------------------------------------------------------------------------- /config/autotools/mk/lcov.mak: -------------------------------------------------------------------------------- 1 | lcov-reset: 2 | @rm -Rf lcov 3 | @find . -iname "*.gcda" -exec rm {} \; 4 | @lcov --directory . --zerocounters 5 | 6 | clean-lcov: 7 | @find . -iname "*.gcno" -exec rm {} \; 8 | 9 | if LCOV 10 | lcov-report: 11 | @rm -Rf lcov 12 | @mkdir -p lcov 13 | @touch lcov/all.out 14 | lcov --compat-libtool --directory src --base-directory $(srcdir) --capture --output-file lcov/all.out 15 | genhtml -o lcov/html lcov/all.out 16 | 17 | lcov: lcov-report 18 | 19 | else 20 | lcov-report lcov: 21 | @echo "" 22 | @echo "Package not configured with --enable-lcov support! Please re-run:" 23 | @echo "" 24 | @echo " ./configure --enable-lcov" 25 | @echo " make clean" 26 | @echo " make lcov" 27 | @echo "" 28 | endif 29 | 30 | -------------------------------------------------------------------------------- /config/boost_includes.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | $(TOOLS_HOME)\boostlib\boost_1_47_0\include;%(AdditionalIncludeDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/boost_includes.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/boost_lib.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | $(TOOLS_HOME)\boostlib\boost_1_47_0\windows;%(AdditionalLibraryDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/boost_lib.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/boost_lib_64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | $(TOOLS_HOME)\boostlib\boost_1_47_0\wow64;%(AdditionalLibraryDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/boost_lib_64.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/common_boost_defines.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | _WIN32_WINNT=0x0501;BOOST_ASIO_ENABLE_CANCELIO;BOOST_REGEX_NO_LIB;BOOST_ALL_DYN_LINK;%(PreprocessorDefinitions) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/common_boost_defines.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/disable_specific_warnings.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | /wd4355 %(AdditionalOptions) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/disable_specific_warnings.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/local_dir.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | 6 | 7 | 8 | $(SolutionDir)\..\src\;$(SolutionDir);%(AdditionalIncludeDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /config/local_dir.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /config/output_dirs.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | $(ProjectName)\$(Configuration)\ 6 | $(ProjectName)\$(Configuration)\ 7 | 8 | -------------------------------------------------------------------------------- /config/output_dirs.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /config/src-footer.inc: -------------------------------------------------------------------------------- 1 | 2 | /* vim: set ts=4 sw=4: */ 3 | -------------------------------------------------------------------------------- /config/src-header.inc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. Green Enery 5 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the 7 | * License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | html/ 2 | pdf/ 3 | -------------------------------------------------------------------------------- /docs/ChapterAPIs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Application Programmer Interfaces 4 | 5 | 6 | Core API 7 | 8 | TBD 9 | 10 | 11 | 12 | Using Virtual Terminal Objects 13 | 14 | TBD 15 | 16 | 17 | 18 | Routing Virtual Terminal Objects with IP Daemons 19 | 20 | TBD 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/ChapterAboutDNP3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | About DNP3 4 | 5 | 6 | What is a telemetry protocol? 7 | 8 | 9 | DNP3 is classified as a telemetry protocol. As such, it is used in SCADA systems to acquire measurements from field devices and perform supervisory control operations on these devices. It is primarily concerned with the reliable delivery of measurement data from an outstation to a master. 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/ChapterExamples.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Examples 4 | 5 | 6 | Using testset 7 | 8 | 9 | 10 | 11 | 12 | HelloWorldApp 13 | 14 | TBD 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/ChapterTheoryOfOperation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Theory of Operation 4 | 5 | 6 | Conformance to DNP3 Standard 7 | 8 | 9 | Table of DNP3 features + OpenDNP3 extensions as rows, and levels 1-4 as 10 | columns. 11 | 12 | 13 | 14 | 15 | Standard Application Architecture 16 | 17 | TBD 18 | 19 | 20 | 21 | Ports, Masters, and Outstations 22 | 23 | TBD 24 | 25 | 26 | 27 | Point Maps 28 | 29 | TBD 30 | 31 | 32 | 33 | Virtual Terminal Objects 34 | 35 | TBD 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/TestSetUserManual.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/docs/TestSetUserManual.docx -------------------------------------------------------------------------------- /docs/app1.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/docs/app1.xml -------------------------------------------------------------------------------- /docs/bibliography.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | References and Resources 4 | 5 | 6 | 21 | 22 | 23 | Standards 24 | 25 | 26 | IEEE Std 1815™-2010: IEEE Standard for Electric 27 | Power Systems Communications - Distributed Network Protocol 28 | (DNP3) 29 | 30 | 31 | 2010 32 | The Institute of Electrical and Electronics 33 | Engineers, Inc. 34 | 35 | 978-0-7381-6313-0 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/glossary.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Glossary 4 | 5 | 6 | This is a glossary. 7 | 8 | 9 | D 10 | 11 | 12 | DNP3 13 | 14 | The Distributed Network Protocol version 3, as defined in IEEE Std 1815™-2010 15 | 16 | 17 | 18 | 19 | SCADA 20 | 21 | Supervisory Control and Data Aquistion 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /java/src/test/scala/org/totalgrid/dnp3/mock/CachingResponseAcceptor.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Green Energy Corp. 3 | * 4 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 5 | * contributor license agreements. See the NOTICE file distributed with this 6 | * work for additional information regarding copyright ownership. Green Energy 7 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 | * License for the specific language governing permissions and limitations under 17 | * the License. 18 | */ 19 | package org.totalgrid.dnp3.mock 20 | 21 | import net.agileautomata.commons.testing.SynchronizedList 22 | import org.totalgrid.dnp3.{CommandResponse, IResponseAcceptor} 23 | 24 | class CachingResponseAcceptor extends IResponseAcceptor { 25 | 26 | val responses = new SynchronizedList[Response] 27 | case class Response(response: CommandResponse, sequence: Int) 28 | 29 | override def AcceptResponse(response: CommandResponse, sequence: Int) = responses.append(Response(response, sequence)) 30 | 31 | } -------------------------------------------------------------------------------- /java/src/test/scala/org/totalgrid/dnp3/mock/InstantCommandAcceptor.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Green Energy Corp. 3 | * 4 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 5 | * contributor license agreements. See the NOTICE file distributed with this 6 | * work for additional information regarding copyright ownership. Green Energy 7 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 | * License for the specific language governing permissions and limitations under 17 | * the License. 18 | */ 19 | package org.totalgrid.dnp3.mock 20 | 21 | import org.totalgrid.dnp3._ 22 | 23 | class InstantCommandResponder(status: CommandStatus) extends ICommandAcceptor { 24 | 25 | private val response = new CommandResponse(status) 26 | 27 | final override def AcceptCommand(obj: BinaryOutput, index: Long, seq: Int, accept: IResponseAcceptor) = 28 | accept.AcceptResponse(response, seq) 29 | 30 | final override def AcceptCommand(obj: Setpoint, index: Long, seq: Int, accept: IResponseAcceptor) = 31 | accept.AcceptResponse(response, seq) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /java/src/test/scala/org/totalgrid/dnp3/mock/MockCommandAcceptor.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Green Energy Corp. 3 | * 4 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 5 | * contributor license agreements. See the NOTICE file distributed with this 6 | * work for additional information regarding copyright ownership. Green Energy 7 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 | * License for the specific language governing permissions and limitations under 17 | * the License. 18 | */ 19 | package org.totalgrid.dnp3.mock 20 | 21 | import org.totalgrid.dnp3._ 22 | import scala.collection.mutable 23 | 24 | class MockCommandAcceptor extends ICommandAcceptor { 25 | val commands = new mutable.Queue[Tuple3[BinaryOutput, Long, Int]] 26 | val setpoints = new mutable.Queue[Tuple3[Setpoint, Long, Int]] 27 | 28 | override def AcceptCommand(obj: BinaryOutput, index: Long, seq: Int, accept: IResponseAcceptor) { 29 | commands += Tuple3(obj, index, seq) 30 | } 31 | override def AcceptCommand(obj: Setpoint, index: Long, seq: Int, accept: IResponseAcceptor) { 32 | setpoints += Tuple3(obj, index, seq) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /profile/README: -------------------------------------------------------------------------------- 1 | 1. Fill in all of the sections marked VENDOR_SPECIFIC for your device. 2 | 2. Fill in your device database table at the bottom of the file. 3 | 4 | Examples, the xsd, etc can be found here: 5 | 6 | http://www.dnp.org/Shared%20Documents/6.%20Software%20Tools/DNP3%20Device%20Profile%20XML%20Schema%20XSLT%20v2_07%202010-02-23.zip 7 | 8 | Use the freely xsltproc to generate the html output, i.e. from a linux shell: 9 | 10 | xsltproc DNP3DeviceProfileJan2010.xslt open_dnp3_slave.xml > open_dnp3_slave.html 11 | -------------------------------------------------------------------------------- /profile/dnp_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/profile/dnp_logo.jpg -------------------------------------------------------------------------------- /profile/output/profile.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/profile/output/profile.html -------------------------------------------------------------------------------- /schema/CSToCppXMLBinder.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/schema/CSToCppXMLBinder.exe -------------------------------------------------------------------------------- /schema/MasterTestSet.xsd: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /schema/ReBuildCSharpFromSchema.bat: -------------------------------------------------------------------------------- 1 | %TOOLS_HOME%\XSDObjectGenerator\xsdobjectgen.exe "%CD%\SlaveTestSet.xsd" /d "/y:APLXML.STS|APLXML.DNP|APLXML.Base" /n:ignored "/z:%CD%\APLXML.STS.cs|%CD%\APLXML.DNP.cs|%CD%\APLXML.Base.cs" 2 | %TOOLS_HOME%\XSDObjectGenerator\xsdobjectgen.exe "%CD%\MasterTestSet.xsd" /d "/y:APLXML.DNP|APLXML.Base|APLXML.MTS" /n:ignored "/z:%CD%\APLXML.DNP.cs|%CD%\APLXML.Base.cs|%CD%\APLXML.MTS.cs" 3 | %TOOLS_HOME%\XSDObjectGenerator\xsdobjectgen.exe "%CD%\DNP.xsd" /d /y:"APLXML.DNP|APLXML.Base" /n:ignored "/z:%CD%\APLXML.DNP.cs|%CD%\APLXML.Base.cs" 4 | %TOOLS_HOME%\XSDObjectGenerator\xsdobjectgen.exe "%CD%\APL.xsd" /d /n:"APLXML.Base" 5 | 6 | call "%VS80COMNTOOLS%vsvars32.bat" 7 | csc /t:module /out:Bindings.netmodule APLXML.DNP.cs APLXML.Base.cs APLXML.MTS.cs APLXML.STS.cs 8 | al /t:lib /out:Bindings.assembly Bindings.netmodule 9 | CSToCppXMLBinder.exe APLXML.Base Bindings.assembly ../XMLBindings XMLBindings 10 | CSToCppXMLBinder.exe APLXML.DNP Bindings.assembly ../XMLBindings XMLBindings 11 | CSToCppXMLBinder.exe APLXML.MTS Bindings.assembly ../XMLBindings XMLBindings 12 | CSToCppXMLBinder.exe APLXML.STS Bindings.assembly ../XMLBindings XMLBindings 13 | 14 | 15 | del Bindings.assembly 16 | del Bindings.netmodule 17 | pause 18 | -------------------------------------------------------------------------------- /schema/SlaveTestSet.xsd: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ASIOSerialHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef _ASIO_SERIAL_HELPERS_H_ 20 | #define _ASIO_SERIAL_HELPERS_H_ 21 | 22 | #include 23 | 24 | #include "SerialTypes.h" 25 | 26 | namespace boost 27 | { 28 | namespace asio 29 | { 30 | typedef basic_serial_port<> serial_port; 31 | } 32 | } 33 | 34 | namespace apl 35 | { 36 | namespace asio_serial 37 | { 38 | 39 | // Serial port configuration functions "free" to keep the classes simple. 40 | void Configure(SerialSettings& arSettings, boost::asio::serial_port& arPort, boost::system::error_code& ec); 41 | void Configure(SerialSettings& arSettings, boost::asio::serial_port& arPort); 42 | 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/opendnp3/APL/AsyncResult.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __ASYNC_RESULT_H_ 20 | #define __ASYNC_RESULT_H_ 21 | 22 | #include "Lock.h" 23 | #include "Exception.h" 24 | #include "Function.h" 25 | 26 | namespace apl 27 | { 28 | 29 | class AsyncResult 30 | { 31 | 32 | public: 33 | AsyncResult(); 34 | 35 | void Success(); 36 | void Failure(const FunctionVoidZero& arFun); 37 | void Wait(); 38 | 39 | private: 40 | void Complete(); 41 | 42 | FunctionVoidZero mRethrow; 43 | bool mIsComplete; 44 | SigLock mLock; 45 | }; 46 | 47 | } 48 | 49 | #endif 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/opendnp3/APL/AsyncTaskContinuous.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "AsyncTaskContinuous.h" 20 | 21 | #include "AsyncTaskGroup.h" 22 | #include "Exception.h" 23 | 24 | #include 25 | 26 | using namespace boost::posix_time; 27 | 28 | namespace apl 29 | { 30 | 31 | AsyncTaskContinuous::AsyncTaskContinuous(int aPriority, const TaskHandler& arCallback, AsyncTaskGroup* apGroup, const std::string& arName) : 32 | AsyncTaskBase(aPriority, arCallback, apGroup, min_date_time, arName) 33 | { 34 | 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/opendnp3/APL/AsyncTaskInterfaces.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __ASYNC_TASK_INTERFACES_H_ 20 | #define __ASYNC_TASK_INTERFACES_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | class ITask 28 | { 29 | public: 30 | 31 | virtual void OnComplete(bool aSuccess) = 0; 32 | 33 | // Enable the task and notify the task group which might execute another task 34 | virtual void Enable() = 0; 35 | 36 | // Disable '' 37 | virtual void Disable() = 0; 38 | 39 | // Enable without notifying the task group 40 | virtual void SilentEnable() = 0; 41 | 42 | // Diable '' 43 | virtual void SilentDisable() = 0; 44 | }; 45 | 46 | typedef boost::function TaskHandler; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/opendnp3/APL/BoundNotifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __BOUND_NOTIFIER_H_ 20 | #define __BOUND_NOTIFIER_H_ 21 | 22 | #include "INotifier.h" 23 | #include 24 | 25 | namespace apl 26 | { 27 | 28 | class BoundNotifier : public INotifier 29 | { 30 | public: 31 | BoundNotifier(boost::function aFunc) : mFunc(aFunc) {} 32 | virtual ~BoundNotifier() {} 33 | 34 | void Notify() { 35 | mFunc(); 36 | } 37 | 38 | private: 39 | boost::function mFunc; 40 | }; 41 | } 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /src/opendnp3/APL/CRC.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __CRC_H_ 20 | #define __CRC_H_ 21 | 22 | #include "Types.h" 23 | #include 24 | 25 | namespace apl 26 | { 27 | 28 | class CRC 29 | { 30 | public: 31 | static unsigned int CalcCRC(const boost::uint8_t* aInput, size_t aLength, const unsigned int* apTable, unsigned int aStart, bool aInvert); 32 | static void PrecomputeCRC(unsigned int* apTable, unsigned int aPolynomial); 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/CachedLogVariable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __CachedLogVariable_H_ 20 | #define __CachedLogVariable_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | #include "Logger.h" 26 | 27 | 28 | namespace apl 29 | { 30 | class CachedLogVariable 31 | { 32 | public: 33 | CachedLogVariable(Logger* apLogger, const std::string& arName) 34 | : mVar(apLogger, arName), 35 | mCurrent(0), 36 | mSet(false) { 37 | } 38 | 39 | void Set(int aVal) { 40 | if ( aVal != mCurrent || !mSet) { 41 | mVar.Set(aVal); 42 | mCurrent = aVal; 43 | mSet = true; 44 | } 45 | } 46 | 47 | private: 48 | LogVariable mVar; 49 | int mCurrent; 50 | bool mSet; 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/opendnp3/APL/DeleteAny.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #ifndef __DELETE_ANY_H_ 21 | #define __DELETE_ANY_H_ 22 | 23 | #include 24 | 25 | namespace apl 26 | { 27 | 28 | /** Useful for posting to a timer source */ 29 | template 30 | void DeleteAny(const T* apType) 31 | { 32 | delete apType; 33 | } 34 | 35 | } 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Function.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __FUNCTION_H_ 20 | #define __FUNCTION_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | template 28 | class FunctionZero 29 | { 30 | public: 31 | typedef boost::function Fun; 32 | }; 33 | 34 | typedef FunctionZero::Fun FunctionVoidZero; 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/opendnp3/APL/GetKeys.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #ifndef __KEY_KEYS_H_ 21 | #define __KEY_KEYS_H_ 22 | 23 | #include 24 | 25 | namespace apl 26 | { 27 | 28 | template 29 | static std::vector GetKeys(const T& arMap) 30 | { 31 | std::vector ret; 32 | for(typename T::const_iterator i = arMap.begin(); i != arMap.end(); ++i) { 33 | ret.push_back(i->first); 34 | } 35 | return ret; 36 | } 37 | 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IEventLock.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_EVENT_LOCK_H_ 20 | #define __I_EVENT_LOCK_H_ 21 | 22 | namespace apl 23 | { 24 | template 25 | class IEventLock 26 | { 27 | public: 28 | virtual ~IEventLock() {} 29 | 30 | virtual void SignalEvent(const T& arEvent) = 0; 31 | virtual void BroadcastEvent(const T& arEvent) = 0; 32 | }; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IHandlerAsync.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "IHandlerAsync.h" 20 | 21 | namespace apl 22 | { 23 | 24 | IHandlerAsync::IHandlerAsync(Logger* apLogger) : 25 | Loggable(apLogger), 26 | IUpperLayer(apLogger) 27 | { 28 | 29 | } 30 | 31 | // For consistency sake, use NVII pattern in case we want pre/post conditions in the future 32 | void IHandlerAsync::OnOpenFailure() 33 | { 34 | this->_OnOpenFailure(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IHandlerAsync.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_HANDLER_ASYNC_H_ 20 | #define __I_HANDLER_ASYNC_H_ 21 | 22 | #include "AsyncLayerInterfaces.h" 23 | 24 | namespace apl 25 | { 26 | 27 | class IHandlerAsync : public IUpperLayer 28 | { 29 | public: 30 | IHandlerAsync(Logger*); 31 | virtual ~IHandlerAsync() {} 32 | 33 | // In addition to all of the IUpperLayer functions, provide a mechanism to receive open failures 34 | // For consistency sake, use NVII pattern in case we want pre/post conditions in the future 35 | void OnOpenFailure(); 36 | 37 | private: 38 | 39 | // called when the layer didn't make a connection and has given up trying, safe to delete. 40 | virtual void _OnOpenFailure() = 0; 41 | }; 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IOService.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #include "IOService.h" 21 | #include 22 | 23 | namespace apl 24 | { 25 | 26 | IOService::IOService() : mpService(new boost::asio::io_service()) 27 | { 28 | 29 | } 30 | 31 | IOService::~IOService() 32 | { 33 | delete mpService; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IOService.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __IO_SERVICE_H_ 20 | #define __IO_SERVICE_H_ 21 | 22 | namespace boost 23 | { 24 | namespace asio 25 | { 26 | class io_service; 27 | } 28 | } 29 | 30 | 31 | namespace apl 32 | { 33 | 34 | class IOService 35 | { 36 | 37 | public: 38 | IOService(); 39 | ~IOService(); 40 | boost::asio::io_service* Get() { 41 | return mpService; 42 | } 43 | 44 | private: 45 | boost::asio::io_service* mpService; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IPhysicalLayerObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_PHYSICAL_LAYER_OBSERVER_H_ 20 | #define __I_PHYSICAL_LAYER_OBSERVER_H_ 21 | 22 | #include 23 | 24 | #include "PhysicalLayerStates.h" 25 | 26 | namespace apl 27 | { 28 | 29 | class IPhysicalLayerObserver 30 | { 31 | public: 32 | 33 | virtual ~IPhysicalLayerObserver() {} 34 | 35 | virtual void OnStateChange(PhysicalLayerState) = 0; 36 | 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/opendnp3/APL/IPhysicalLayerSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #ifndef __I_PHYSICAL_LAYER_SOURCE_H_ 21 | #define __I_PHYSICAL_LAYER_SOURCE_H_ 22 | 23 | #include 24 | 25 | namespace apl 26 | { 27 | class IPhysicalLayerAsync; 28 | 29 | class IPhysicalLayerSource 30 | { 31 | public: 32 | virtual ~IPhysicalLayerSource() {} 33 | 34 | virtual IPhysicalLayerAsync* AcquireLayer(const std::string& arName) = 0; 35 | virtual void ReleaseLayer(const std::string& arName) = 0; 36 | }; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ISubject.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_SUBJECT_H_ 20 | #define __I_SUBJECT_H_ 21 | 22 | namespace apl 23 | { 24 | class INotifier; 25 | 26 | class ISubject 27 | { 28 | public: 29 | virtual ~ISubject() {} 30 | 31 | virtual void AddObserver(INotifier* apNotifier) = 0; 32 | virtual void RemoveObserver(INotifier* apNotifer) = 0; 33 | }; 34 | } 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ITimeSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_TIME_SOURCE_H_ 20 | #define __I_TIME_SOURCE_H_ 21 | 22 | #include "Types.h" 23 | 24 | namespace boost 25 | { 26 | namespace posix_time 27 | { 28 | 29 | class ptime; 30 | 31 | } 32 | } 33 | 34 | namespace apl 35 | { 36 | class ITimeManager 37 | { 38 | public: 39 | virtual millis_t GetTime() = 0; 40 | virtual void SetTime(millis_t aTime) = 0; 41 | }; 42 | class ITimeSource 43 | { 44 | public: 45 | virtual boost::posix_time::ptime GetUTC() = 0; 46 | virtual TimeStamp_t GetTimeStampUTC() = 0; 47 | }; 48 | } 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ITimerSource.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "ITimerSource.h" 20 | 21 | #include 22 | 23 | namespace apl 24 | { 25 | 26 | ITimer* ITimerSource::StartInfinite() 27 | { 28 | boost::posix_time::ptime t(boost::date_time::max_date_time); 29 | return this->Start(t, boost::bind(&ITimerSource::NullAction)); 30 | } 31 | 32 | void ITimerSource::Sync() 33 | { 34 | this->PostSync(boost::bind(&ITimerSource::NullAction)); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Lock.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LOCK_H_ 20 | #define __LOCK_H_ 21 | 22 | #include "LockBoost.h" 23 | 24 | namespace apl 25 | { 26 | typedef SigLock_Boost SigLock; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/opendnp3/APL/LockBase.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "LockBase.h" 20 | 21 | namespace apl 22 | { 23 | 24 | CriticalSection::CriticalSection(ILockBase* apLock) : mIsLocked(true), mpLock(apLock) 25 | { 26 | mpLock->Lock(); 27 | } 28 | 29 | CriticalSection::~CriticalSection() 30 | { 31 | if(mIsLocked) mpLock->Unlock(); 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/opendnp3/APL/LogBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LOG_BASE_H_ 20 | #define __LOG_BASE_H_ 21 | 22 | #include "LogEntry.h" 23 | 24 | namespace apl 25 | { 26 | class ILogBase 27 | { 28 | public: 29 | virtual ~ILogBase() {} 30 | 31 | // logging error messages, etc 32 | virtual void Log( const apl::LogEntry& arEntry ) = 0; 33 | 34 | // updating a variable/metric in the system 35 | virtual void SetVar(const std::string& aSource, const std::string& aVarName, int aValue) = 0; 36 | }; 37 | 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/opendnp3/APL/LogToStdio.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "LogToStdio.h" 20 | 21 | #include "LogEntry.h" 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | LogToStdio LogToStdio::mInstance; 28 | 29 | LogToStdio::LogToStdio() : mPrintLocation(false) 30 | {} 31 | 32 | void LogToStdio::SetPrintLocation(bool aPrintLocation) 33 | { 34 | mPrintLocation = aPrintLocation; 35 | } 36 | 37 | void LogToStdio::Log(const LogEntry& arEntry) 38 | { 39 | CriticalSection cs(&mLock); 40 | std::cout << arEntry.LogString(mPrintLocation) << std::endl; 41 | } 42 | 43 | } //end ns 44 | -------------------------------------------------------------------------------- /src/opendnp3/APL/LogToStdio.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LOG_TO_STDIO_H_ 20 | #define __LOG_TO_STDIO_H_ 21 | 22 | #include "Lock.h" 23 | #include "LogBase.h" 24 | 25 | namespace apl 26 | { 27 | 28 | class LogToStdio : public ILogBase 29 | { 30 | 31 | public: 32 | static LogToStdio* Inst() { 33 | return &mInstance; 34 | } 35 | 36 | void Log( const LogEntry& arEntry ); 37 | void SetVar(const std::string& aSource, const std::string& aVarName, int aValue) {} 38 | 39 | void SetPrintLocation(bool aPrintLocation); 40 | 41 | protected: 42 | LogToStdio(); 43 | 44 | private: 45 | static LogToStdio mInstance; 46 | bool mPrintLocation; 47 | SigLock mLock; 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/opendnp3/APL/LogVar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LOG_VAR_H_ 20 | #define __LOG_VAR_H_ 21 | 22 | #include 23 | 24 | 25 | namespace apl 26 | { 27 | 28 | /** Stores the state of a variable 29 | */ 30 | template 31 | class LogVar 32 | { 33 | public: 34 | LogVar() : mValue(0) {} 35 | LogVar(T aValue) : mValue(aValue) {} 36 | 37 | void Set(T aValue) { 38 | mValue = aValue; 39 | } 40 | T Get() { 41 | return mValue; 42 | } 43 | T Add(T aValue) { 44 | return (mValue += aValue); 45 | } 46 | 47 | private: 48 | T mValue; 49 | }; 50 | 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Loggable.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "Loggable.h" 20 | 21 | 22 | #include 23 | #include "Log.h" 24 | #include "Logger.h" 25 | 26 | namespace apl 27 | { 28 | 29 | Loggable::Loggable( Logger* apLogger ) 30 | : mpLogger(apLogger) 31 | { 32 | assert(apLogger != NULL); 33 | } 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/opendnp3/APL/MetricBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "MetricBuffer.h" 20 | 21 | 22 | namespace apl 23 | { 24 | 25 | void MetricBuffer::SetVar(const std::string& aSource, const std::string& aVarName, int aValue) 26 | { 27 | CriticalSection cs(&mLock); 28 | mValues[aSource + "." + aVarName] = Var(aSource, aVarName, aValue); 29 | } 30 | 31 | void MetricBuffer::Read(std::vector& v) 32 | { 33 | CriticalSection cs(&mLock); 34 | for(std::map::iterator i = mValues.begin(); i != mValues.end(); ++i) { 35 | v.push_back(i->second); 36 | } 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PhysLayerSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __PHYS_LAYER_SETTINGS_H_ 20 | #define __PHYS_LAYER_SETTINGS_H_ 21 | 22 | #include "Types.h" 23 | #include "LogTypes.h" 24 | 25 | namespace apl 26 | { 27 | 28 | class IPhysicalLayerObserver; 29 | 30 | struct PhysLayerSettings { 31 | public: 32 | PhysLayerSettings() : LogLevel(LEV_INFO), RetryTimeout(5000), mpObserver(NULL) {} 33 | 34 | 35 | PhysLayerSettings(FilterLevel aLevel, millis_t aRetryTimeout, IPhysicalLayerObserver* apObserver = NULL) : 36 | LogLevel(aLevel), 37 | RetryTimeout(aRetryTimeout), 38 | mpObserver(apObserver) 39 | {} 40 | 41 | FilterLevel LogLevel; 42 | millis_t RetryTimeout; 43 | IPhysicalLayerObserver* mpObserver; 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PhysicalLayerFunctors.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __PHYSICAL_LAYER_FUNCTORS_H_ 20 | #define __PHYSICAL_LAYER_FUNCTORS_H_ 21 | 22 | #include 23 | 24 | namespace boost 25 | { 26 | namespace asio 27 | { 28 | class io_service; 29 | } 30 | } 31 | 32 | namespace apl 33 | { 34 | 35 | class Logger; 36 | class IPhysicalLayerAsync; 37 | 38 | typedef boost::function IPhysicalLayerAsyncFactory; 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PhysicalLayerStates.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __PHYSICAL_LAYER_STATES_H_ 20 | #define __PHYSICAL_LAYER_STATES_H_ 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace apl 27 | { 28 | 29 | enum PhysicalLayerState { 30 | PLS_CLOSED, // layer is offline and idle 31 | PLS_OPENING, // layer is trying to open 32 | PLS_WAITING, // layer is waiting to open 33 | PLS_OPEN, // layer is open 34 | PLS_SHUTDOWN // stopped and will never do anything again 35 | }; 36 | 37 | std::string ConvertPhysicalLayerStateToString(PhysicalLayerState aState); 38 | 39 | std::ostream& operator<<(std::ostream& output, PhysicalLayerState aState); 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PostingNotifier.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "PostingNotifier.h" 20 | 21 | namespace apl 22 | { 23 | 24 | PostingNotifier::PostingNotifier(ITimerSource* apTimerSrc, const FunctionVoidZero& arHandler) : 25 | mpTimerSrc(apTimerSrc), 26 | mHandler(arHandler) 27 | { 28 | 29 | } 30 | 31 | void PostingNotifier::Notify() 32 | { 33 | mpTimerSrc->Post(mHandler); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PostingNotifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __POSTING_NOTIFIER_H_ 20 | #define __POSTING_NOTIFIER_H_ 21 | 22 | #include "INotifier.h" 23 | #include "ITimerSource.h" 24 | 25 | namespace apl 26 | { 27 | 28 | class PostingNotifier : public INotifier 29 | { 30 | public: 31 | 32 | PostingNotifier(ITimerSource* apTimerSrc, const FunctionVoidZero& arHandler); 33 | 34 | virtual ~PostingNotifier() {} 35 | 36 | void Notify(); 37 | 38 | private: 39 | ITimerSource* mpTimerSrc; 40 | FunctionVoidZero mHandler; 41 | }; 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PostingNotifierSource.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "PostingNotifierSource.h" 20 | 21 | #include "PostingNotifier.h" 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | PostingNotifierSource::~PostingNotifierSource() 28 | { 29 | 30 | } 31 | 32 | INotifier* PostingNotifierSource::Get(const FunctionVoidZero& arHandler, ITimerSource* apTimerSrc) 33 | { 34 | boost::shared_ptr pRet(new PostingNotifier(apTimerSrc, arHandler)); 35 | mNotifiers.push_back(pRet); 36 | return pRet.get(); 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/opendnp3/APL/PostingNotifierSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __POSTING_NOTIFIER_SOURCE_H_ 20 | #define __POSTING_NOTIFIER_SOURCE_H_ 21 | 22 | #include "ITimerSource.h" 23 | 24 | #include 25 | #include 26 | 27 | namespace apl 28 | { 29 | 30 | class INotifier; 31 | class PostingNotifier; 32 | 33 | class PostingNotifierSource 34 | { 35 | public: 36 | ~PostingNotifierSource(); 37 | 38 | INotifier* Get(const FunctionVoidZero&, ITimerSource*); 39 | 40 | private: 41 | std::vector< boost::shared_ptr > mNotifiers; 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ProtocolUtil.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "ProtocolUtil.h" 20 | 21 | namespace apl 22 | { 23 | 24 | // Given a buffer and max packet size, calculcate the 25 | // maximum number of packets the buffer can hold 26 | size_t CalcMaxPackets(size_t aBuffer, size_t aPayload) 27 | { 28 | size_t remain = aBuffer % aPayload; 29 | size_t num = aBuffer / aPayload; 30 | return (remain == 0) ? num : num + 1; 31 | } 32 | 33 | size_t CalcLastPacketSize(size_t aBuffer, size_t aPayload) 34 | { 35 | size_t remain = aBuffer % aPayload; 36 | return (remain == 0) ? aPayload : remain; 37 | } 38 | 39 | } //end namespace 40 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ProtocolUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __PROTOCOL_UTIL_H_ 20 | #define __PROTOCOL_UTIL_H_ 21 | 22 | #include 23 | 24 | 25 | namespace apl 26 | { 27 | 28 | // Given a buffer and max packet size, calculcate the 29 | // maximum number of packets the buffer can hold 30 | size_t CalcMaxPackets(size_t aBuffer, size_t aPayload); 31 | 32 | 33 | // Given a buffer and max packet size, calculcate the 34 | // size of the last packet. 35 | size_t CalcLastPacketSize(size_t aBuffer, size_t aPayload); 36 | 37 | 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/opendnp3/APL/RandomizedBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #include "RandomizedBuffer.h" 21 | 22 | namespace apl 23 | { 24 | 25 | RandomizedBuffer::RandomizedBuffer(size_t aSize) : 26 | CopyableBuffer(aSize), 27 | rand() 28 | { 29 | Randomize(); 30 | } 31 | 32 | void RandomizedBuffer::Randomize() 33 | { 34 | for(size_t i = 0; i < this->Size(); ++i) mpBuff[i] = rand.Next(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/RandomizedBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __RANDOMIZED_BUFFER_H_ 20 | #define __RANDOMIZED_BUFFER_H_ 21 | 22 | #include "CopyableBuffer.h" 23 | #include "Random.h" 24 | 25 | namespace apl 26 | { 27 | 28 | class RandomizedBuffer : public CopyableBuffer 29 | { 30 | 31 | public: 32 | 33 | RandomizedBuffer(size_t aSize); 34 | 35 | void Randomize(); 36 | 37 | private: 38 | Random rand; 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/opendnp3/APL/SerialTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __SERIAL_TYPES_H_ 20 | #define __SERIAL_TYPES_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | enum ParityType { 28 | PAR_NONE, 29 | PAR_EVEN, 30 | PAR_ODD 31 | }; 32 | 33 | enum FlowType { 34 | FLOW_NONE, 35 | FLOW_HARDWARE, 36 | FLOW_XONXOFF 37 | }; 38 | 39 | struct SerialSettings { 40 | std::string mDevice; 41 | int mBaud; 42 | int mDataBits; 43 | int mStopBits; 44 | ParityType mParity; 45 | FlowType mFlowType; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Singleton.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __STATE_SINGLETON_H_ 20 | #define __STATE_SINGLETON_H_ 21 | 22 | #define MACRO_SINGLETON_INSTANCE(type) \ 23 | private:\ 24 | static type mInstance;\ 25 | protected: \ 26 | type(){}; \ 27 | public:\ 28 | static type* Inst(){ return &mInstance; } 29 | 30 | #define MACRO_NAME_SINGLETON_INSTANCE(type) \ 31 | MACRO_SINGLETON_INSTANCE(type) \ 32 | std::string Name() const { return #type; } 33 | 34 | #define MACRO_STATE_SINGLETON_INSTANCE(type) MACRO_NAME_SINGLETON_INSTANCE(type) 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Thread.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __THREAD_H_ 20 | #define __THREAD_H_ 21 | 22 | 23 | #include "Threadable.h" 24 | #include "ThreadBase.h" 25 | 26 | #include "ThreadBoost.h" 27 | 28 | namespace apl 29 | { 30 | typedef ThreadBoost Thread; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ThreadBase.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "ThreadBase.h" 20 | 21 | 22 | namespace apl 23 | { 24 | 25 | ThreadBase::ThreadBase(Threadable* apThreadable) : 26 | mpThreadable(apThreadable) 27 | { 28 | 29 | } 30 | 31 | ThreadBase::~ThreadBase() 32 | { 33 | 34 | } 35 | void ThreadBase::RequestStop() 36 | { 37 | mpThreadable->RequestStop(); 38 | } 39 | 40 | }//end namespace 41 | 42 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ThreadBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __THREAD_BASE_H_ 20 | #define __THREAD_BASE_H_ 21 | 22 | 23 | #include "Threadable.h" 24 | 25 | namespace apl 26 | { 27 | 28 | class ThreadBase 29 | { 30 | public: 31 | 32 | ThreadBase(Threadable* apThreadable); 33 | virtual ~ThreadBase(); 34 | 35 | virtual void Start() = 0; 36 | virtual void RequestStop(); 37 | virtual void WaitForStop() = 0; 38 | 39 | protected: 40 | 41 | //pointer to obejct that conforms to the IThreadable interface 42 | Threadable* mpThreadable; 43 | 44 | bool mIsExitRequested; 45 | 46 | }; 47 | 48 | }//end namespace 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ThreadBoost.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __THREAD_BOOST_H_ 20 | #define __THREAD_BOOST_H_ 21 | 22 | #include "ThreadBase.h" 23 | #include "Types.h" 24 | #include 25 | #include 26 | 27 | namespace apl 28 | { 29 | 30 | class ThreadBoost : public ThreadBase 31 | { 32 | 33 | public: 34 | ThreadBoost(Threadable* apObj); 35 | virtual ~ThreadBoost (); 36 | 37 | void Start(); 38 | void WaitForStop(); 39 | static void SleepFor(millis_t millis, bool ensureSleepForCorrectTime = false); 40 | 41 | private: 42 | 43 | boost::function0 mEntryPoint; 44 | boost::thread* mpThread; 45 | 46 | }; 47 | 48 | }//end namespace 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/opendnp3/APL/TimeTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __TIME_TYPES_H_ 20 | #define __TIME_TYPES_H_ 21 | 22 | #include "TimeBoost.h" 23 | 24 | namespace apl 25 | { 26 | typedef TimeBoost Time; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/opendnp3/APL/TimerASIO.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "TimerASIO.h" 20 | 21 | namespace apl 22 | { 23 | 24 | TimerASIO::TimerASIO(boost::asio::io_service& arService) : 25 | mCanceled(false), 26 | mTimer(arService) 27 | { 28 | 29 | } 30 | 31 | /** 32 | * Return the timer's expiry time as an absolute time. 33 | */ 34 | boost::posix_time::ptime TimerASIO::ExpiresAt() 35 | { 36 | return mTimer.expires_at(); 37 | } 38 | 39 | void TimerASIO::Cancel() 40 | { 41 | assert(!mCanceled); 42 | mTimer.cancel(); 43 | mCanceled = true; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/opendnp3/APL/ToHex.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "ToHex.h" 20 | 21 | 22 | 23 | namespace apl 24 | { 25 | 26 | char toHex(char c) 27 | { 28 | if(c > 9) return 'A' + (c - 10); 29 | return '0' + c; 30 | } 31 | 32 | std::string ByteToHex(boost::uint8_t b) 33 | { 34 | std::ostringstream oss; 35 | oss << toHex((b & 0xf0) >> 4) << toHex(b & 0xf); 36 | return oss.str(); 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/opendnp3/APL/Uncopyable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __UNCOPYABLE_H_ 20 | #define __UNCOPYABLE_H_ 21 | 22 | namespace apl 23 | { 24 | 25 | /** Inherited classes will not have default copy/assignment. 26 | */ 27 | class Uncopyable 28 | { 29 | protected: 30 | Uncopyable() {} //allow construction/destruction 31 | ~Uncopyable() {} 32 | 33 | private: 34 | Uncopyable(const Uncopyable&); //prevent copy constructor 35 | Uncopyable& operator=(const Uncopyable&); //prevent assignment 36 | }; 37 | 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/AsyncPhysBaseTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "AsyncPhysBaseTest.h" 20 | 21 | 22 | 23 | namespace apl 24 | { 25 | 26 | AsyncPhysBaseTest::AsyncPhysBaseTest(FilterLevel aLevel, bool aImmediate) : 27 | LogTester(aImmediate), 28 | phys(mLog.GetLogger(aLevel, "phys")), 29 | adapter(mLog.GetLogger(aLevel, "adapter"), &phys, false), 30 | upper(mLog.GetLogger(aLevel, "upper")) 31 | { 32 | adapter.SetUpperLayer(&upper); 33 | } 34 | 35 | 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/AsyncPhysBaseTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __ASYNC_PHYS_BASE_TEST_H_ 20 | #define __ASYNC_PHYS_BASE_TEST_H_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace apl 29 | { 30 | 31 | class AsyncPhysBaseTest : public LogTester 32 | { 33 | public: 34 | AsyncPhysBaseTest(FilterLevel aLevel = LEV_INFO, bool aImmediate = false); 35 | 36 | MockPhysicalLayerAsync phys; 37 | LowerLayerToPhysAdapter adapter; 38 | MockUpperLayer upper; 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/AsyncSerialTestObject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #include "AsyncSerialTestObject.h" 21 | #include 22 | 23 | namespace apl 24 | { 25 | 26 | AsyncSerialTestObject::AsyncSerialTestObject(SerialSettings cfg, FilterLevel aLevel, bool aImmediate) : 27 | AsyncTestObjectASIO(), 28 | LogTester(aImmediate), 29 | mPort(mLog.GetLogger(aLevel, "Serial"), this->GetService(), cfg), 30 | mAdapter(mLog.GetLogger(aLevel, "Adapter"), &mPort, true), 31 | mUpper(mLog.GetLogger(aLevel, "MockUpper")) 32 | { 33 | mAdapter.SetUpperLayer(&mUpper); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/LogTester.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LOG_TESTER_H_ 20 | #define __LOG_TESTER_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | class LogTester 28 | { 29 | public: 30 | LogTester(bool aImmediate = false); 31 | 32 | void Log(const std::string& aLocation, const std::string& aMessage); 33 | 34 | int ClearLog(); 35 | int NextErrorCode(); 36 | bool GetNextEntry(LogEntry& arEntry); 37 | bool IsLogErrorFree(); 38 | 39 | EventLog mLog; 40 | 41 | protected: 42 | Logger* mpTestLogger; 43 | LogEntryCircularBuffer mBuffer; 44 | 45 | 46 | }; 47 | 48 | 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/MockCommandHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __MOCK_COMMAND_HANDLER_H_ 20 | #define __MOCK_COMMAND_HANDLER_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | class MockCommandHandler : public ICommandHandler 28 | { 29 | public: 30 | 31 | MockCommandHandler() : num_bo(0), num_sp(0) {} 32 | 33 | CommandStatus HandleControl(BinaryOutput& aControl, size_t aIndex) { 34 | ++num_bo; 35 | return CS_SUCCESS; 36 | } 37 | CommandStatus HandleControl(Setpoint& aControl, size_t aIndex) { 38 | ++num_sp; 39 | return CS_SUCCESS; 40 | } 41 | 42 | size_t num_bo; 43 | size_t num_sp; 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/MockLogSubscriber.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __MOCK_LOG_SUBSCRIBER_H_ 20 | #define __MOCK_LOG_SUBSCRIBER_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace apl 26 | { 27 | 28 | class MockLogSubscriber : public ILogBase 29 | { 30 | public: 31 | 32 | void Log( const apl::LogEntry& arEntry ) { 33 | mEntries.push(arEntry); 34 | } 35 | 36 | // updating a variable/metric in the system 37 | void SetVar(const std::string& aSource, const std::string& aVarName, int aValue) {} 38 | 39 | std::queue mEntries; 40 | }; 41 | 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/MockNodeSaver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | 21 | #ifndef _MOCK_NODE_SAVER_H_ 22 | #define _MOCK_NODE_SAVER_H_ 23 | 24 | #include 25 | 26 | namespace apl 27 | { 28 | 29 | template 30 | class MockNodeSaver : public INodeSaver 31 | { 32 | public: 33 | MockNodeSaver(): mFailLoad(false), mFailSave(false) {} 34 | protected: 35 | bool _LoadNode(RootNode& aNode) { 36 | aNode = mLocalCopy; //copy 37 | return !mFailLoad; 38 | } 39 | bool _SaveNode(RootNode& aNode) { 40 | mLocalCopy = aNode; //copy 41 | return !mFailSave; 42 | } 43 | 44 | public: 45 | RootNode mLocalCopy; 46 | bool mFailLoad; 47 | bool mFailSave; 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/MockNotifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef _MOCK_NOTIFIER_H_ 20 | #define _MOCK_NOTIFIER_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | 27 | class MockNotifier : public INotifier 28 | { 29 | public: 30 | MockNotifier() { 31 | Reset(); 32 | } 33 | 34 | void Notify() { 35 | mNotifications++; 36 | } 37 | 38 | void Reset() { 39 | mNotifications = 0; 40 | } 41 | 42 | size_t GetNotifications() { 43 | return mNotifications; 44 | }; 45 | 46 | private: 47 | size_t mNotifications; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/TestHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __TEST_HELPERS_H_ 20 | #define __TEST_HELPERS_H_ 21 | 22 | #define BOOST_REQUIRE_FLOAT_EQUAL_TOL(a,b,tol) BOOST_REQUIRE(apl::FloatEqual(a,b,tol)) 23 | 24 | #define BOOST_REQUIRE_FLOAT_EQUAL(a,b) BOOST_REQUIRE(apl::FloatEqual(a,b,1e-6)) 25 | 26 | #define BOOST_REQUIRE_NOT_EQUAL(a,b) BOOST_REQUIRE(a != b) 27 | 28 | #define BOOST_REQUIRE_FALSE(a) BOOST_REQUIRE(!a) 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/TestTypedefs.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __TEST_TYPEDEFS_H_ 20 | #define __TEST_TYPEDEFS_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace apl 26 | { 27 | class FlexibleDataObserver; 28 | } 29 | 30 | namespace apl 31 | { 32 | const millis_t G_TEST_TIMEOUT = 40000; 33 | 34 | typedef boost::function EvalFunc; 35 | typedef boost::function OutputEvalFunc; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/WrappedTcpPipe.cpp: -------------------------------------------------------------------------------- 1 | #include "WrappedTcpPipe.h" 2 | 3 | #include 4 | 5 | namespace apl 6 | { 7 | 8 | WrappedTcpPipe::WrappedTcpPipe(Logger* apLogger, boost::asio::io_service* apService, boost::uint16_t aPort) : 9 | clientTcp(apLogger->GetSubLogger("clientTcp"), apService, "127.0.0.1", aPort), 10 | serverTcp(apLogger->GetSubLogger("serverTcp"), apService, "127.0.0.1", aPort), 11 | client(apLogger->GetSubLogger("clientWrapper"), &clientTcp), 12 | server(apLogger->GetSubLogger("serverWrapper"), &serverTcp) 13 | { 14 | 15 | } 16 | 17 | 18 | 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/opendnp3/APL/test/util/WrappedTcpPipe.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_TCP_PIPE_H_ 2 | #define __WRAPPED_TCP_PIPE_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "PhysicalLayerWrapper.h" 8 | 9 | namespace boost 10 | { 11 | namespace asio 12 | { 13 | class io_service; 14 | } 15 | } 16 | 17 | namespace apl 18 | { 19 | 20 | class WrappedTcpPipe 21 | { 22 | public: 23 | WrappedTcpPipe(Logger*, boost::asio::io_service*, boost::uint16_t aPort); 24 | 25 | private: 26 | PhysicalLayerAsyncTCPClient clientTcp; 27 | PhysicalLayerAsyncTCPServer serverTcp; 28 | 29 | public: 30 | PhysicalLayerWrapper client; 31 | PhysicalLayerWrapper server; 32 | }; 33 | 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/AlwaysOpeningVtoRouter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. Green Enery 5 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the 7 | * License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | #include "AlwaysOpeningVtoRouter.h" 19 | 20 | namespace apl 21 | { 22 | namespace dnp 23 | { 24 | 25 | AlwaysOpeningVtoRouter::AlwaysOpeningVtoRouter(const VtoRouterSettings& arSettings, Logger* apLogger, IVtoWriter* apWriter, IPhysicalLayerAsync* apPhysLayer, ITimerSource* apTimerSrc) : 26 | Loggable(apLogger), 27 | VtoRouter(arSettings, apLogger, apWriter, apPhysLayer, apTimerSrc) 28 | { 29 | this->Start(); 30 | } 31 | 32 | } 33 | } 34 | 35 | /* vim: set ts=4 sw=4: */ 36 | 37 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/BufferTypes.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 3 | // contributor license agreements. See the NOTICE file distributed with this 4 | // work for additional information regarding copyright ownership. Green Enery 5 | // Corp licenses this file to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance with the 7 | // License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | // License for the specific language governing permissions and limitations 15 | // under the License. 16 | // 17 | 18 | #include 19 | 20 | #include "BufferTypes.h" 21 | 22 | namespace apl 23 | { 24 | namespace dnp 25 | { 26 | 27 | BufferTypes Convert(DataTypes aType) 28 | { 29 | switch(aType) { 30 | case(DT_BINARY): return BT_BINARY; 31 | case(DT_ANALOG): return BT_ANALOG; 32 | case(DT_COUNTER): return BT_COUNTER; 33 | default: 34 | throw ArgumentException("Invalid conversion to BufferType: " + aType); 35 | } 36 | } 37 | 38 | } 39 | } 40 | 41 | /* vim: set ts=4 sw=4: */ 42 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/DNPCrc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __DNP_CRC_H_ 20 | #define __DNP_CRC_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace apl 26 | { 27 | namespace dnp 28 | { 29 | 30 | class DNPCrc 31 | { 32 | public: 33 | 34 | static unsigned int CalcCrc(const boost::uint8_t* aInput, size_t length); 35 | 36 | static void AddCrc(boost::uint8_t* aInput, size_t aLength); 37 | 38 | static bool IsCorrectCRC(const boost::uint8_t* aInput, size_t aLength); 39 | 40 | private: 41 | 42 | static bool mIsInitialized; 43 | 44 | static bool InitCrcTable(); 45 | 46 | static unsigned int mpCrcTable[256]; //Precomputed CRC lookup table 47 | 48 | }; 49 | 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/HeaderReadIterator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "HeaderReadIterator.h" 20 | #include "ObjectReadIterator.h" 21 | 22 | 23 | namespace apl 24 | { 25 | namespace dnp 26 | { 27 | 28 | HeaderReadIterator::HeaderReadIterator(const std::vector* apHeaders, const boost::uint8_t* apBuffer, bool aHasData) : 29 | mpHeaders(apHeaders), 30 | mpBuffer(apBuffer), 31 | mHasData(aHasData), 32 | mIndex(0) 33 | { 34 | 35 | } 36 | 37 | 38 | ObjectReadIterator HeaderReadIterator::BeginRead() 39 | { 40 | return ObjectReadIterator((*mpHeaders)[mIndex], mpBuffer, mHasData); 41 | } 42 | 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/ILinkContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_LINK_CONTEXT_H_ 20 | #define __I_LINK_CONTEXT_H_ 21 | 22 | #include "IFrameSink.h" 23 | 24 | namespace apl 25 | { 26 | namespace dnp 27 | { 28 | 29 | // @section DESCRIPTION Interface from the link router to the link layer 30 | class ILinkContext : public IFrameSink 31 | { 32 | public: 33 | 34 | virtual ~ILinkContext() {} 35 | 36 | virtual void OnLowerLayerUp() = 0; 37 | virtual void OnLowerLayerDown() = 0; 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/ILinkRouter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_LINK_ROUTER_H_ 20 | #define __I_LINK_ROUTER_H_ 21 | 22 | namespace apl 23 | { 24 | namespace dnp 25 | { 26 | 27 | class LinkFrame; 28 | 29 | // @section DESCRIPTION Interface from the link layer to the link router 30 | class ILinkRouter 31 | { 32 | public: 33 | 34 | virtual ~ILinkRouter() {} 35 | 36 | virtual void Transmit(const LinkFrame&) = 0; 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/IStackObserver.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #include "IStackObserver.h" 21 | 22 | namespace apl 23 | { 24 | namespace dnp 25 | { 26 | 27 | std::string ConvertStackStateToString(StackStates aState) 28 | { 29 | switch(aState) { 30 | case(SS_COMMS_UP): 31 | return "COMMS_UP"; 32 | case(SS_COMMS_DOWN): 33 | return "COMMS_DOWN"; 34 | case(SS_UNKNOWN): 35 | return "COMMS_UNKNOWN"; 36 | default: 37 | return "Undefined state"; 38 | } 39 | } 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/IStackObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_STACK_OBSERVER_H_ 20 | #define __I_STACK_OBSERVER_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | namespace dnp 27 | { 28 | 29 | enum StackStates { 30 | SS_COMMS_UP, 31 | SS_COMMS_DOWN, 32 | SS_UNKNOWN 33 | }; 34 | 35 | std::string ConvertStackStateToString(StackStates aState); 36 | 37 | class IStackObserver 38 | { 39 | public: 40 | virtual ~IStackObserver() {}; 41 | 42 | virtual void OnStateChange(StackStates aState) = 0; 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/IVtoEventAcceptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __I_VTO_EVENT_ACCEPTOR_H_ 20 | #define __I_VTO_EVENT_ACCEPTOR_H_ 21 | 22 | #include "VtoData.h" 23 | 24 | namespace apl 25 | { 26 | 27 | namespace dnp 28 | { 29 | 30 | class IVtoEventAcceptor 31 | { 32 | public: 33 | virtual void Update(const VtoData& arEvent, PointClass aClass, size_t aIndex) = 0; 34 | }; 35 | 36 | } 37 | 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/MasterConfigTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __EXCEPTION_SCAN_H_ 20 | #define __EXCEPTION_SCAN_H_ 21 | 22 | #include 23 | 24 | namespace apl 25 | { 26 | namespace dnp 27 | { 28 | 29 | struct ExceptionScan { 30 | int ClassMask; 31 | millis_t ScanRate; 32 | }; 33 | 34 | } 35 | } 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/MasterStack.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __MASTER_STACK_H_ 20 | #define __MASTER_STACK_H_ 21 | 22 | #include "Stack.h" 23 | #include "Master.h" 24 | #include "MasterStackConfig.h" 25 | 26 | namespace apl 27 | { 28 | namespace dnp 29 | { 30 | 31 | /** @section desc A stack object for a master */ 32 | class MasterStack : public Stack 33 | { 34 | public: 35 | 36 | MasterStack( 37 | Logger*, 38 | ITimerSource* apTimerSrc, 39 | IDataObserver* apPublisher, 40 | AsyncTaskGroup* apTaskGroup, 41 | const MasterStackConfig& arCfg); 42 | 43 | IVtoWriter* GetVtoWriter(); 44 | IVtoReader* GetVtoReader(); 45 | 46 | Master mMaster; 47 | }; 48 | 49 | } 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/MasterStackConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __MASTER_STACK_CONFIG_H_ 20 | #define __MASTER_STACK_CONFIG_H_ 21 | 22 | #include "MasterConfig.h" 23 | #include "AppConfig.h" 24 | #include "LinkConfig.h" 25 | #include "VtoConfig.h" 26 | 27 | namespace apl 28 | { 29 | namespace dnp 30 | { 31 | 32 | /** A composite configuration struct that contains all the config 33 | information for a dnp3 master stack 34 | */ 35 | struct MasterStackConfig { 36 | MasterStackConfig() : 37 | link(true, false) 38 | {} 39 | 40 | MasterConfig master; // Master config 41 | AppConfig app; // Application layer config 42 | LinkConfig link; // Link layer config 43 | VtoConfig vto; 44 | 45 | }; 46 | 47 | } 48 | } 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/PointClass.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "PointClass.h" 20 | 21 | namespace apl 22 | { 23 | namespace dnp 24 | { 25 | 26 | PointClass IntToPointClass(int aClass) 27 | { 28 | switch(aClass) { 29 | case(1): 30 | return PC_CLASS_1; 31 | case(2): 32 | return PC_CLASS_2; 33 | case(3): 34 | return PC_CLASS_3; 35 | default: 36 | return PC_CLASS_0; 37 | } 38 | } 39 | 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/PointClass.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __POINT_CLASS_H_ 20 | #define __POINT_CLASS_H_ 21 | 22 | namespace apl 23 | { 24 | namespace dnp 25 | { 26 | 27 | enum PointClass { 28 | PC_CLASS_0 = 0x01, 29 | PC_CLASS_1 = 0x02, 30 | PC_CLASS_2 = 0x04, 31 | PC_CLASS_3 = 0x08, 32 | PC_ALL_EVENTS = PC_CLASS_1 | PC_CLASS_2 | PC_CLASS_3, 33 | PC_INVALID = 0x10 34 | }; 35 | 36 | PointClass IntToPointClass(int aClass); 37 | 38 | } 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/Stack.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "Stack.h" 20 | 21 | #include 22 | 23 | namespace apl 24 | { 25 | namespace dnp 26 | { 27 | 28 | Stack::Stack(Logger* apLogger, ITimerSource* apTimerSrc, AppConfig aAppCfg, LinkConfig aCfg) : 29 | mLink(apLogger->GetSubLogger("link"), apTimerSrc, aCfg), 30 | mTransport(apLogger->GetSubLogger("transport")), 31 | mApplication(apLogger->GetSubLogger("app"), apTimerSrc, aAppCfg) 32 | { 33 | mLink.SetUpperLayer(&mTransport); 34 | mTransport.SetUpperLayer(&mApplication); 35 | } 36 | 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/TransportConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __TRANSPORT_CONSTANTS_H_ 20 | #define __TRANSPORT_CONSTANTS_H_ 21 | 22 | 23 | #include "DNPConstants.h" 24 | 25 | namespace apl 26 | { 27 | namespace dnp 28 | { 29 | 30 | enum TransportHeader { 31 | TL_HDR_FIN = 0x80, 32 | TL_HDR_FIR = 0x40, 33 | TL_HDR_SEQ = 0x3F 34 | }; 35 | 36 | // The macro MACRO_DNP_MAX_FRAG_SIZE controls the maximum size of application layer frames 37 | const size_t TL_MAX_TPDU_LENGTH = 250; 38 | const size_t TL_MAX_TPDU_PAYLOAD = 249; 39 | 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/VtoConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __VTO_CONFIG_H_ 20 | #define __VTO_CONFIG_H_ 21 | 22 | #include "VtoRouterSettings.h" 23 | 24 | namespace apl 25 | { 26 | namespace dnp 27 | { 28 | 29 | struct VtoRouterConfig { 30 | VtoRouterConfig() {} 31 | 32 | std::string mPhysicalLayerName; 33 | 34 | VtoRouterSettings mSettings; 35 | }; 36 | 37 | struct VtoConfig { 38 | VtoConfig() {} 39 | 40 | void AddVtoRouterConfig(VtoRouterConfig& arSetting) { 41 | mRouterConfigs.push_back(arSetting); 42 | } 43 | 44 | std::vector mRouterConfigs; 45 | }; 46 | 47 | 48 | 49 | 50 | } 51 | } 52 | 53 | /* vim: set ts=4 sw=4: */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/VtoEventBufferAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. Green Enery 5 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the 7 | * License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | #ifndef __VTO_EVENT_BUFFER_ADAPTER_H_ 19 | #define __VTO_EVENT_BUFFER_ADAPTER_H_ 20 | 21 | #include "EventBufferBase.h" 22 | #include "IVtoEventAcceptor.h" 23 | 24 | namespace apl 25 | { 26 | 27 | namespace dnp 28 | { 29 | 30 | class VtoEventBufferAdapter : public IVtoEventAcceptor 31 | { 32 | public: 33 | 34 | VtoEventBufferAdapter(EventAcceptor* apBuffer) : mpBuffer(apBuffer) 35 | {} 36 | 37 | void Update(const VtoData& arEvent, PointClass aClass, size_t aIndex) { 38 | mpBuffer->Update(arEvent, aClass, aIndex); 39 | } 40 | 41 | private: 42 | EventAcceptor* mpBuffer; 43 | }; 44 | 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/VtoRouterSettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. Green Enery 5 | * Corp licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the 7 | * License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | #include "VtoRouterSettings.h" 19 | 20 | namespace apl 21 | { 22 | namespace dnp 23 | { 24 | 25 | VtoRouterSettings::VtoRouterSettings(boost::uint8_t aChannelId, bool aStartLocal, bool aDisableExtensions, millis_t aOpenRetryMs) : 26 | CHANNEL_ID(aChannelId), 27 | OPEN_RETRY_MS(aOpenRetryMs), 28 | START_LOCAL(aStartLocal), 29 | DISABLE_EXTENSIONS(aDisableExtensions) 30 | {} 31 | 32 | } 33 | } 34 | 35 | /* vim: set ts=4 sw=4: */ 36 | 37 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/DNPHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __DNP_HELPERS_H_ 20 | #define __DNP_HELPERS_H_ 21 | 22 | #include 23 | 24 | 25 | namespace apl 26 | { 27 | namespace dnp 28 | { 29 | 30 | class LinkFrame; 31 | 32 | std::string RepairCRC(const std::string& arData); 33 | bool IsFrameEqual(apl::dnp::LinkFrame& frame, const std::string& arData); 34 | 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/LinkLayerRouterTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "LinkLayerRouterTest.h" 20 | 21 | namespace apl 22 | { 23 | namespace dnp 24 | { 25 | 26 | LinkLayerRouterTest::LinkLayerRouterTest(FilterLevel aLevel, bool aImmediate) : 27 | LogTester(aImmediate), 28 | mts(), 29 | phys(mLog.GetLogger(aLevel, "Physical")), 30 | router(mLog.GetLogger(aLevel, "Router"), &phys, &mts, 100) 31 | { 32 | 33 | } 34 | 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/LinkLayerRouterTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __LINK_LAYER_ROUTER_TEST_H_ 20 | #define __LINK_LAYER_ROUTER_TEST_H_ 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | 30 | namespace apl 31 | { 32 | namespace dnp 33 | { 34 | 35 | class LinkLayerRouterTest : public LogTester 36 | { 37 | public: 38 | LinkLayerRouterTest(FilterLevel aLevel = LEV_WARNING, bool aImmediate = false); 39 | 40 | MockTimerSource mts; 41 | MockPhysicalLayerAsync phys; 42 | LinkLayerRouter router; 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/LinkLayerTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "LinkLayerTest.h" 20 | 21 | namespace apl 22 | { 23 | namespace dnp 24 | { 25 | 26 | LinkLayerTest::LinkLayerTest(LinkConfig arCfg, FilterLevel aLevel, bool aImmediate) : 27 | LogTester(aImmediate), 28 | mts(), 29 | upper(mLog.GetLogger(aLevel, "MockUpperLayer")), 30 | link(mLog.GetLogger(aLevel, "LinkLayer"), &mts, arCfg), 31 | mNumSend(0) 32 | { 33 | link.SetUpperLayer(&upper); 34 | link.SetRouter(this); 35 | } 36 | 37 | void LinkLayerTest::Transmit(const LinkFrame& arFrame) 38 | { 39 | mLastSend = arFrame; 40 | ++mNumSend; 41 | } 42 | 43 | LinkConfig LinkLayerTest::DefaultConfig() 44 | { 45 | LinkConfig cfg(true, false); 46 | return cfg; 47 | } 48 | 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/QueueingStackObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __QUEUEING_STACK_OBSERVER_H_ 20 | #define __QUEUEING_STACK_OBSERVER_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace apl 26 | { 27 | namespace dnp 28 | { 29 | 30 | class QueueingStackObserver : public IStackObserver 31 | { 32 | public: 33 | void OnStateChange(StackStates aState) { 34 | mQueue.push_back(aState); 35 | } 36 | 37 | std::deque mQueue; 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/TestCRC.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | using namespace std; 33 | using namespace apl; 34 | using namespace apl::dnp; 35 | 36 | 37 | BOOST_AUTO_TEST_SUITE(CRC) 38 | 39 | BOOST_AUTO_TEST_CASE(CrcTest) 40 | { 41 | HexSequence hs("05 64 05 C0 01 00 00 04 E9 21"); 42 | BOOST_REQUIRE_EQUAL(hs.Size(), 10); 43 | BOOST_REQUIRE_EQUAL(DNPCrc::CalcCrc(hs, 8), 0x21E9); 44 | } 45 | 46 | BOOST_AUTO_TEST_SUITE_END() 47 | -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/TestStartBoostUTF.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | /* 21 | * Define the Boost UTF module name 22 | */ 23 | #define BOOST_TEST_MODULE dnp3 24 | 25 | /* 26 | * If we aren't using dynamic linking, make sure a main() function 27 | * is created anyway. 28 | */ 29 | #ifndef BOOST_TEST_DYN_LINK 30 | #define BOOST_TEST_MAIN 31 | #endif 32 | 33 | /* 34 | * Include the Boost UTF subsystem. The rest is automagic. 35 | */ 36 | #include -------------------------------------------------------------------------------- /src/opendnp3/DNP3/test/TransportIntegrationStack.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "TransportIntegrationStack.h" 20 | 21 | #include 22 | 23 | namespace apl 24 | { 25 | namespace dnp 26 | { 27 | 28 | TransportIntegrationStack::TransportIntegrationStack(Logger* apLogger, ITimerSource* apTimerSrc, IPhysicalLayerAsync* apPhys, LinkConfig aCfg) : 29 | mRouter(apLogger, apPhys, apTimerSrc, 1000), 30 | mLink(apLogger, apTimerSrc, aCfg), 31 | mTransport(apLogger), 32 | mUpper(apLogger) 33 | { 34 | LinkRoute route(aCfg.RemoteAddr, aCfg.LocalAddr); 35 | mRouter.AddContext(&mLink, route); 36 | mLink.SetUpperLayer(&mTransport); 37 | mTransport.SetUpperLayer(&mUpper); 38 | mLink.SetRouter(&mRouter); 39 | } 40 | 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/opendnp3/terminal/ControlTerminalExtension.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONTROL_TERMINAL_EXTENSION_H_ 2 | #define __CONTROL_TERMINAL_EXTENSION_H_ 3 | 4 | #include "TerminalInterfaces.h" 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace apl 12 | { 13 | class ICommandAcceptor; 14 | 15 | 16 | class ControlTerminalExtension : public ITerminalExtension 17 | { 18 | public: 19 | 20 | ControlTerminalExtension(ICommandAcceptor* apCmdAcceptor) : 21 | mSequence(0), 22 | mpCmdAcceptor(apCmdAcceptor), 23 | mRspQueue() { 24 | 25 | } 26 | 27 | std::string Name() { 28 | return "ControlTerminalExtension"; 29 | } 30 | 31 | virtual ~ControlTerminalExtension() {} 32 | 33 | static ControlCode ParseControlCode( const std::string& arString ); 34 | 35 | private: 36 | 37 | int mSequence; 38 | 39 | ICommandAcceptor* mpCmdAcceptor; 40 | CommandResponseQueue mRspQueue; 41 | 42 | void WaitForResponse(); 43 | retcode HandleIssueBO(std::vector& arArgs); 44 | retcode HandleIssueST(std::vector& arArgs); 45 | 46 | //implement from ITerminalExtension 47 | void _BindToTerminal(ITerminal* apTerminal); 48 | 49 | 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/opendnp3/terminal/LineReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINE_READER_H_ 2 | #define __LINE_READER_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace apl 10 | { 11 | 12 | class IPhysicalLayerAsync; 13 | class ITimerSource; 14 | 15 | /** Abstracts the process of reading line from a physical layer. 16 | */ 17 | class LineReader : public PhysicalLayerMonitor, private Uncopyable 18 | { 19 | public: 20 | LineReader(Logger* apLogger, IPhysicalLayerAsync* apPhysical, ITimerSource* apTimerSrc, size_t aBuffSize); 21 | 22 | virtual void AcceptLine(const std::string&) = 0; 23 | virtual void _Up() = 0; 24 | virtual void _Down() = 0; 25 | 26 | private: 27 | CopyableBuffer mBuffer; 28 | size_t mNumBytes; 29 | bool mHasCR; 30 | 31 | void Read(); 32 | void OnPhysicalLayerOpenSuccessCallback(); 33 | void OnPhysicalLayerOpenFailureCallback() {} 34 | void OnPhysicalLayerCloseCallback(); 35 | void Reset(); 36 | 37 | void _OnReceive(const boost::uint8_t*, size_t aNum); 38 | void ReadBuffer(); 39 | }; 40 | 41 | 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/opendnp3/terminal/PhysicalLayerIOStreamAsync.cpp: -------------------------------------------------------------------------------- 1 | #include "PhysicalLayerIOStreamAsync.h" 2 | 3 | #include 4 | 5 | using namespace boost::system; 6 | using namespace std; 7 | 8 | namespace apl 9 | { 10 | 11 | PhysicalLayerIOStreamAsync::PhysicalLayerIOStreamAsync(Logger* apLogger, boost::asio::io_service* apService) : 12 | PhysicalLayerSyncProxy(apLogger, apService) 13 | {} 14 | 15 | std::string PhysicalLayerIOStreamAsync::Read() 16 | { 17 | string input; 18 | getline(cin, input); 19 | input.append("\r\n"); 20 | return input; 21 | } 22 | 23 | void PhysicalLayerIOStreamAsync::Write(const std::string& arString) 24 | { 25 | cout << arString; 26 | cout.flush(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/opendnp3/terminal/PhysicalLayerIOStreamAsync.h: -------------------------------------------------------------------------------- 1 | #ifndef __PHYSICAL_LAYER_IOSTREAM_ASYNC_H_ 2 | #define __PHYSICAL_LAYER_IOSTREAM_ASYNC_H_ 3 | 4 | 5 | #include "PhysicalLayerSyncProxy.h" 6 | 7 | namespace boost 8 | { 9 | namespace asio 10 | { 11 | class io_service; 12 | } 13 | } 14 | 15 | namespace apl 16 | { 17 | 18 | class Logger; 19 | 20 | /** Simple thread object that allows for non-blocking read of std input. 21 | */ 22 | class PhysicalLayerIOStreamAsync : public PhysicalLayerSyncProxy 23 | { 24 | public: 25 | PhysicalLayerIOStreamAsync(Logger*, boost::asio::io_service*); 26 | 27 | private: 28 | 29 | 30 | //implement virtual members of PhysicalLayerSyncProxy 31 | 32 | std::string Read(); 33 | void Write(const std::string&); 34 | }; 35 | } 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/opendnp3/terminal/TerminalInterfaces.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "TerminalInterfaces.h" 3 | 4 | #include 5 | 6 | namespace apl 7 | { 8 | const char ITerminal::CLEAR_SRC[2] = "\f"; 9 | const char ITerminal::EOL[3] = "\r\n"; 10 | 11 | std::string CommandNode::ToString() const 12 | { 13 | std::ostringstream oss; 14 | oss << "Command: " << mName << "\r\n"; 15 | oss << mDesc << "\r\nUsage: " << mUsage; 16 | return oss.str(); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/opendnp3/xml/APL/XMLConversion.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #include "XMLConversion.h" 20 | 21 | using namespace APLXML_Base; 22 | 23 | namespace apl 24 | { 25 | namespace xml 26 | { 27 | 28 | FilterLevel Convert(APLXML_Base::LogLevelEnum aEnum) 29 | { 30 | switch(aEnum) { 31 | case(APLXML_Base::LOG_DEBUG): return LEV_DEBUG; 32 | case(APLXML_Base::LOG_COMM): return LEV_COMM; 33 | case(APLXML_Base::LOG_INTERPRET): return LEV_INTERPRET; 34 | case(APLXML_Base::LOG_INFO): return LEV_INFO; 35 | case(APLXML_Base::LOG_WARNING): return LEV_WARNING; 36 | case(APLXML_Base::LOG_ERROR): return LEV_ERROR; 37 | case(APLXML_Base::LOG_EVENT): return LEV_EVENT; 38 | default: return LEV_WARNING; 39 | } 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/opendnp3/xml/APL/XMLConversion.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef __XML_CONVERSION_H_ 20 | #define __XML_CONVERSION_H_ 21 | 22 | #include 23 | #include 24 | 25 | namespace apl 26 | { 27 | namespace xml 28 | { 29 | 30 | FilterLevel Convert(APLXML_Base::LogLevelEnum aEnum); 31 | } 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/opendnp3/xml/DNP3/XML_TestSet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to Green Energy Corp (www.greenenergycorp.com) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. Green Enery Corp licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | #ifndef _XML_TESTSET_H_ 20 | #define _XML_TESTSET_H_ 21 | 22 | namespace APLXML_MTS 23 | { 24 | class MasterTestSet_t; 25 | } 26 | namespace APLXML_STS 27 | { 28 | class SlaveTestSet_t; 29 | } 30 | 31 | namespace apl 32 | { 33 | 34 | class XML_TestSet 35 | { 36 | public: 37 | static void Configure(APLXML_MTS::MasterTestSet_t& arMasterTest, bool aUseUnsol = false); 38 | static void Configure(APLXML_STS::SlaveTestSet_t& arSlaveTest); 39 | 40 | }; 41 | 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/opendnp3/xml/binding/APLXML_MTS.cpp: -------------------------------------------------------------------------------- 1 | /* ****************************** 2 | GENERATED CONTENT DO NOT ALTER! 3 | ********************************* 4 | */ 5 | #include "APLXML_MTS.h" 6 | using namespace std; 7 | namespace APLXML_MTS { 8 | void MasterTestSet_t :: fromXml(TiXmlNode* pNode){ 9 | if(pNode == NULL)return; 10 | XML_CHECK("MasterTestSet",pNode->Type() == TiXmlNode::ELEMENT); 11 | TiXmlElement* pEm = pNode->ToElement(); 12 | XML_CHECK("MasterTestSet",pEm != 0); 13 | PhysicalLayer = FromString_string(pEm, pEm->Attribute("PhysicalLayer")); 14 | LogFile = FromString_string(pEm, pEm->Attribute("LogFile")); 15 | Log.fromXml(pNode->FirstChildElement("Log")); 16 | Master.fromXml(pNode->FirstChildElement("Master")); 17 | PhysicalLayerList.fromXml(pNode->FirstChildElement("PhysicalLayerList")); 18 | valid=true; 19 | }; 20 | void MasterTestSet_t :: toXml(TiXmlNode* pParent, bool aCreateNode, bool aIgnoreValid){ 21 | if(!aIgnoreValid && !valid) return; 22 | TiXmlElement * pEm; 23 | if(aCreateNode){ 24 | pEm = new TiXmlElement("MasterTestSet"); 25 | pParent->LinkEndChild(pEm); 26 | }else{ 27 | pEm = pParent->ToElement(); 28 | } 29 | pEm->SetAttribute("PhysicalLayer", ToString_string(PhysicalLayer)); 30 | pEm->SetAttribute("LogFile", ToString_string(LogFile)); 31 | Log.toXml(pEm, true, aIgnoreValid); 32 | Master.toXml(pEm, true, aIgnoreValid); 33 | PhysicalLayerList.toXml(pEm, true, aIgnoreValid); 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/opendnp3/xml/binding/APLXML_MTS.h: -------------------------------------------------------------------------------- 1 | /* ****************************** 2 | GENERATED CONTENT DO NOT ALTER! 3 | ********************************* 4 | */ 5 | #ifndef _APLXML_MTS_H_ 6 | #define _APLXML_MTS_H_ 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | namespace APLXML_MTS { 12 | class MasterTestSet_t : public IXMLDataBound { 13 | public: 14 | void toXml(TiXmlNode* pParent, bool aCreateNode, bool aIgnoreValid); 15 | void fromXml(TiXmlNode* pNode); 16 | string PhysicalLayer; 17 | string LogFile; 18 | #ifdef SWIG 19 | %immutable Log; 20 | #endif 21 | APLXML_Base::Log_t Log; 22 | #ifdef SWIG 23 | %immutable Master; 24 | #endif 25 | APLXML_DNP::Master_t Master; 26 | #ifdef SWIG 27 | %immutable PhysicalLayerList; 28 | #endif 29 | APLXML_Base::PhysicalLayerList_t PhysicalLayerList; 30 | }; 31 | } 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /src/opendnp3/xml/binding/APLXML_STS.h: -------------------------------------------------------------------------------- 1 | /* ****************************** 2 | GENERATED CONTENT DO NOT ALTER! 3 | ********************************* 4 | */ 5 | #ifndef _APLXML_STS_H_ 6 | #define _APLXML_STS_H_ 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | namespace APLXML_STS { 12 | class SlaveTestSet_t : public IXMLDataBound { 13 | public: 14 | void toXml(TiXmlNode* pParent, bool aCreateNode, bool aIgnoreValid); 15 | void fromXml(TiXmlNode* pNode); 16 | string LogFile; 17 | string PhysicalLayer; 18 | bool Remote; 19 | int RemotePort; 20 | bool LinkCommandStatus; 21 | bool StartOnline; 22 | #ifdef SWIG 23 | %immutable Log; 24 | #endif 25 | APLXML_Base::Log_t Log; 26 | #ifdef SWIG 27 | %immutable Slave; 28 | #endif 29 | APLXML_DNP::Slave_t Slave; 30 | #ifdef SWIG 31 | %immutable DeviceTemplate; 32 | #endif 33 | APLXML_DNP::DeviceTemplate_t DeviceTemplate; 34 | #ifdef SWIG 35 | %immutable PhysicalLayerList; 36 | #endif 37 | APLXML_Base::PhysicalLayerList_t PhysicalLayerList; 38 | }; 39 | } 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/tinyxml/tinystr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/src/tinyxml/tinystr.cpp -------------------------------------------------------------------------------- /tools/install_scripts/boost/1_43/install-boost.bat: -------------------------------------------------------------------------------- 1 | call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" 2 | cd temp\boost_1_43_0 3 | 4 | call ./bootstrap.bat 5 | 6 | bjam.exe toolset=msvc --with-program_options --with-system --with-date_time --with-thread --with-filesystem --with-test stage 7 | 8 | set libdir=%TOOLS_HOME%\boostlib\boost_1_43\windows 9 | 10 | echo Installing libs to %libdir% 11 | md %libdir% 12 | copy stage\lib\* %libdir% 13 | 14 | pause 15 | -------------------------------------------------------------------------------- /tools/install_scripts/boost/1_46_1/install-boost.bat: -------------------------------------------------------------------------------- 1 | call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" 2 | cd temp\boost_1_46_1 3 | 4 | call ./bootstrap.bat 5 | 6 | bjam.exe toolset=msvc --with-program_options --with-system --with-date_time --with-thread --with-filesystem --with-test stage 7 | 8 | set libdir=%TOOLS_HOME%\boostlib\boost_1_46_1\windows 9 | 10 | echo Installing libs to %libdir% 11 | md %libdir% 12 | copy stage\lib\* %libdir% 13 | 14 | pause 15 | -------------------------------------------------------------------------------- /tools/install_scripts/boost/1_47_0/install-boost-64.bat: -------------------------------------------------------------------------------- 1 | #call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" 2 | cd temp\boost_1_47_0 3 | 4 | call ./bootstrap.bat 5 | 6 | set STAGE_DIR=stage64 7 | 8 | bjam.exe toolset=msvc link=static,shared address-model=64 --with-program_options --with-system --with-date_time --with-thread --with-filesystem --with-test --stagedir=%STAGE_DIR% stage 9 | 10 | set libdir=%TOOLS_HOME%\boostlib\boost_1_47_0\wow64 11 | 12 | echo Installing libs to %libdir% 13 | md %libdir% 14 | copy %STAGE_DIR%\lib\* %libdir% 15 | 16 | pause 17 | -------------------------------------------------------------------------------- /tools/install_scripts/boost/1_47_0/install-boost.bat: -------------------------------------------------------------------------------- 1 | #call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" 2 | cd temp\boost_1_47_0 3 | 4 | call ./bootstrap.bat 5 | 6 | bjam.exe toolset=msvc link=static,shared --with-program_options --with-system --with-date_time --with-thread --with-filesystem --with-test stage 7 | 8 | set libdir=%TOOLS_HOME%\boostlib\boost_1_47_0\windows 9 | 10 | echo Installing libs to %libdir% 11 | md %libdir% 12 | copy stage\lib\* %libdir% 13 | 14 | pause 15 | -------------------------------------------------------------------------------- /tools/install_scripts/crosstool/install-crosstool.sh: -------------------------------------------------------------------------------- 1 | 2 | if [ "`uname -a | grep CYGWIN_NT`" ] 3 | then 4 | echo "detected cygwin..." 5 | if [ ! -e crosstool-cygwin-gcc-3.3.4-glibc-2.3.2.tar.bz2 ]; then 6 | wget ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7200-linux/cross-toolchains/crosstool-cygwin-gcc-3.3.4-glibc-2.3.2.tar.bz2 7 | fi 8 | tar -xjvf crosstool-cygwin-gcc-3.3.4-glibc-2.3.2.tar.bz2 -C / 9 | else 10 | if [ ! -e crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2 ]; then 11 | wget ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7200-linux/cross-toolchains/crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2 12 | fi 13 | sudo tar -xjvf crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2 -C / 14 | fi 15 | -------------------------------------------------------------------------------- /version.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OPENDNP3_VERSION_HPP 2 | #define OPENDNP3_VERSION_HPP 3 | 4 | // Caution, this is the only header that is guarenteed to change with every 5 | // release, including this header will cause a recompile every time a new 6 | // version is released. 7 | // 8 | // OPENDNP3_VERSION % 100 is the patch level 9 | // OPENDNP3_VERSION / 100 % 1000 is the minor version 10 | // OPENDNP3_VERSION / 100000 is the major version 11 | 12 | #define OPENDNP3_VERSION 100100 13 | 14 | // OPENDNP3_LIB_VERSION must be defined to be the same as OPENDNP3_VERSION 15 | // but as a *string* in the form "x_y[_z]" where x is the major version 16 | // number, y is the minor version number, and z is the patch level if not 0. 17 | 18 | #define OPENDNP3_LIB_VERSION "1_1_0" 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /vstudio10/DNP3Java.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | 15 | 16 | Source Files 17 | 18 | 19 | -------------------------------------------------------------------------------- /vstudio10/DNP3XML.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | -------------------------------------------------------------------------------- /vstudio10/MasterDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c4ed3ae5-b639-401c-9927-a7caaa2e398d} 6 | 7 | 8 | 9 | 10 | Source Files 11 | 12 | 13 | Source Files 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | -------------------------------------------------------------------------------- /vstudio10/SlaveDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {eabaa041-066b-4712-8527-39b58aa952ae} 6 | 7 | 8 | 9 | 10 | Source Files 11 | 12 | 13 | Source Files 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | -------------------------------------------------------------------------------- /vstudio10/TerminalTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | -------------------------------------------------------------------------------- /vstudio10/TestSet.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {b9dd42bf-0135-4d3c-9a45-62f347588e9d} 6 | 7 | 8 | 9 | 10 | Source Files 11 | 12 | 13 | Source Files 14 | 15 | 16 | Source Files 17 | 18 | 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /vstudio10/XMLBindings.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | -------------------------------------------------------------------------------- /vstudio10/tinyxml.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | -------------------------------------------------------------------------------- /windows/BoostLibs/x86/boost_date_time-vc100-mt-1_47.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/BoostLibs/x86/boost_date_time-vc100-mt-1_47.dll -------------------------------------------------------------------------------- /windows/BoostLibs/x86/boost_system-vc100-mt-1_47.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/BoostLibs/x86/boost_system-vc100-mt-1_47.dll -------------------------------------------------------------------------------- /windows/BoostLibs/x86/boost_thread-vc100-mt-1_47.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/BoostLibs/x86/boost_thread-vc100-mt-1_47.dll -------------------------------------------------------------------------------- /windows/CSToCppXMLBinder/Bind.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Reflection; 6 | using System.Xml.Serialization; 7 | using System.Collections.Specialized; 8 | 9 | namespace CSToCppXMLBinder 10 | { 11 | class Bind 12 | { 13 | static void Main(string[] args) 14 | { 15 | if (args.Length != 4) 16 | { 17 | Console.Error.WriteLine("Command line should be:\n\t\tBind.exe [NameSpace] [Assembly] [output]\n\nEx: Bind PSiXML.Common Bindings.netmodule mappings.ini"); 18 | return; 19 | } 20 | try 21 | { 22 | string xml_support_dir = args[3]; 23 | 24 | Assembly asm = Assembly.LoadFrom(Environment.CurrentDirectory+"\\"+args[1]); 25 | CppBinder.BindAssembly(args[2], args[0], asm, xml_support_dir); 26 | Console.WriteLine("Success!"); 27 | } 28 | catch (Exception e) 29 | { 30 | Console.Error.WriteLine(e.ToString()); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /windows/DotNetAdapter/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | using namespace System; 4 | using namespace System::Reflection; 5 | using namespace System::Runtime::CompilerServices; 6 | using namespace System::Runtime::InteropServices; 7 | using namespace System::Security::Permissions; 8 | 9 | // 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | // 14 | [assembly:AssemblyTitleAttribute("DotNetAdapter")]; 15 | [assembly:AssemblyDescriptionAttribute("")]; 16 | [assembly:AssemblyConfigurationAttribute("")]; 17 | [assembly:AssemblyCompanyAttribute("Green Energy Corp")]; 18 | [assembly:AssemblyProductAttribute("DotNetAdapter")]; 19 | [assembly:AssemblyCopyrightAttribute("Copyright (c) Green Energy Corp 2012")]; 20 | [assembly:AssemblyTrademarkAttribute("")]; 21 | [assembly:AssemblyCultureAttribute("")]; 22 | 23 | // 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the value or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | 34 | [assembly:AssemblyVersionAttribute("1.0.*")]; 35 | 36 | [assembly:ComVisible(false)]; 37 | 38 | [assembly:CLSCompliantAttribute(true)]; 39 | 40 | [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; 41 | -------------------------------------------------------------------------------- /windows/DotNetAdapter/FilterLevel.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILTER -------------------------------------------------------------------------------- /windows/DotNetAdapter/StackManager.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DOT_NET_STACK_MANAGER_H_ 3 | #define __DOT_NET_STACK_MANAGER_H_ 4 | 5 | using namespace System; 6 | using namespace DNP3::Interface; 7 | 8 | namespace apl { namespace dnp { 9 | class StackManager; 10 | }} 11 | 12 | namespace DNP3 13 | { 14 | namespace Adapter 15 | { 16 | public ref class StackManager 17 | { 18 | public: 19 | StackManager(); 20 | 21 | void AddTCPClient(System::String^ name, FilterLevel level, System::UInt64 retryMs, System::String^ address, System::UInt16 port); 22 | void AddTCPServer(System::String^ name, FilterLevel level, System::UInt64 retryMs, System::String^ endpoint, System::UInt16 port); 23 | void AddSerial(System::String^ name, FilterLevel level, System::UInt64 retryMs, SerialSettings^ settings); 24 | 25 | ICommandAcceptor^ AddMaster( System::String^ portName, 26 | System::String^ stackName, 27 | FilterLevel level, 28 | IDataObserver^ publisher, 29 | MasterStackConfig^ config); 30 | 31 | IDataObserver^ AddSlave( System::String^ portName, 32 | System::String^ stackName, 33 | FilterLevel level, 34 | ICommandAcceptor^ cmdAcceptor, 35 | DNP3::Interface::SlaveStackConfig^ config); 36 | 37 | void RemovePort(System::String^ portName); 38 | 39 | void RemoveStack(System::String^ stackName); 40 | 41 | void AddLogHandler(ILogHandler^ logHandler); 42 | 43 | private: 44 | apl::dnp::StackManager* pMgr; 45 | }; 46 | 47 | }} 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /windows/DotNetAdapter/Stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DotNetAdapter.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /windows/DotNetAdapter/Stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, 3 | // but are changed infrequently 4 | 5 | #pragma once 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/DotNetAdapter/app.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/DotNetAdapter/app.aps -------------------------------------------------------------------------------- /windows/DotNetAdapter/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/DotNetAdapter/app.ico -------------------------------------------------------------------------------- /windows/DotNetAdapter/app.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/DotNetAdapter/app.rc -------------------------------------------------------------------------------- /windows/DotNetAdapter/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /windows/DotNetInterface/Conversions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DNP3.Interface 7 | { 8 | public class TimeStamp 9 | { 10 | // DNP3 uses different epoch than .NET 11 | private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); 12 | 13 | public static DateTime Convert(Int64 time) 14 | { 15 | return epoch.Add(TimeSpan.FromMilliseconds(time)); 16 | } 17 | 18 | public static Int64 Convert(DateTime time) 19 | { 20 | return (long) time.Subtract(epoch).TotalMilliseconds; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /windows/DotNetInterface/ICommandAcceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DNP3.Interface 7 | { 8 | public interface ICommandAcceptor 9 | { 10 | IFuture AcceptCommand(BinaryOutput command, System.UInt32 index); 11 | IFuture AcceptCommand(Setpoint command, System.UInt32 index); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /windows/DotNetInterface/IDataObserver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DNP3.Interface 7 | { 8 | public interface IDataObserver 9 | { 10 | void Start(); 11 | void Update(Binary update, System.UInt32 index); 12 | void Update(Analog update, System.UInt32 index); 13 | void Update(Counter update, System.UInt32 index); 14 | void Update(ControlStatus update, System.UInt32 index); 15 | void Update(SetpointStatus update, System.UInt32 index); 16 | void End(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /windows/DotNetInterface/ILogHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DNP3.Interface 7 | { 8 | public class LogEntry 9 | { 10 | public LogEntry(FilterLevel filterLevel, String loggerName, String location, string message, DateTime time, int errorCode) 11 | { 12 | this.filterLevel = filterLevel; 13 | this.loggerName = loggerName; 14 | this.location = location; 15 | this.message = message; 16 | this.time = time; 17 | this.errorCode = errorCode; 18 | this.keyValues = new Dictionary(); 19 | } 20 | 21 | public readonly FilterLevel filterLevel; 22 | public readonly String loggerName; 23 | public readonly String location; 24 | public readonly String message; 25 | public readonly DateTime time; 26 | public readonly int errorCode; 27 | public readonly IDictionary keyValues; 28 | } 29 | 30 | public interface ILogHandler 31 | { 32 | /// 33 | /// logging error messages, etc 34 | /// 35 | /// log entry instance 36 | void Log(LogEntry entry); 37 | 38 | /// 39 | /// Updates a variable/metric in the system 40 | /// 41 | /// 42 | /// 43 | /// 44 | void SetVar(String source, String varName, int value); 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /windows/DotNetInterface/LogTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DNP3.Interface 7 | { 8 | public enum FilterLevel { 9 | LEV_EVENT, 10 | LEV_ERROR, 11 | LEV_WARNING, 12 | LEV_INFO, 13 | LEV_INTERPRET, 14 | LEV_COMM, 15 | LEV_DEBUG 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /windows/DotNetInterface/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DotNetInterface")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Green Energy Corp")] 12 | [assembly: AssemblyProduct("DotNetInterface")] 13 | [assembly: AssemblyCopyright("Copyright © Green Energy Corp 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("39818994-c716-46a4-b918-89bfac6ffb11")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /windows/DotNetInterface/Tests/ConfigSerializationTestSuite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | /* 7 | using NUnit.Framework; 8 | using DNP3.Interface; 9 | 10 | namespace DotNetInterface.Tests 11 | { 12 | [TestFixture] 13 | public class ConfigSerializationTestSuite 14 | { 15 | [Test] 16 | public void TestXmlSerializationOfMasterConfig() 17 | { 18 | var mc = new SlaveStackConfig(); 19 | var ser = new System.Xml.Serialization.XmlSerializer(mc.GetType()); 20 | ser.Serialize(Console.Out, mc); 21 | 22 | } 23 | } 24 | } 25 | */ -------------------------------------------------------------------------------- /windows/DotNetTestSet/LogControlAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using DNP3.Interface; 7 | 8 | namespace DotNetTestSet 9 | { 10 | class LogControlAdapter : ILogHandler 11 | { 12 | public LogControlAdapter(LogControl ctrl) 13 | { 14 | this.logControl = ctrl; 15 | } 16 | 17 | private LogControl logControl; 18 | 19 | #region ILogHandler Members 20 | 21 | public void Log(LogEntry entry) 22 | { 23 | this.logControl.BeginInvoke(new Action(() => logControl.AddLogEntry(entry))); 24 | } 25 | 26 | public void SetVar(string source, string varName, int value) 27 | { 28 | 29 | } 30 | 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /windows/DotNetTestSet/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace DotNetTestSet 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new TestSetForm()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /windows/DotNetTestSet/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.235 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DotNetTestSet.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /windows/DotNetTestSet/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/FlickerFreeListView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using System.Windows.Forms; 7 | 8 | namespace TestSetControlLibrary 9 | { 10 | public class FlickerFreeListView : ListView 11 | { 12 | public FlickerFreeListView() 13 | { 14 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 15 | } 16 | 17 | protected override void OnNotifyMessage(Message m) 18 | { 19 | if (m.Msg != 0x14) 20 | { 21 | base.OnNotifyMessage(m); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/IMeasurementSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using DNP3.Interface; 7 | 8 | namespace TestSetControlLibrary 9 | { 10 | public delegate void OnUpdateBinary(Binary meas, UInt32 index, String id); 11 | public delegate void OnUpdateAnalog(Analog meas, UInt32 index, String id); 12 | public delegate void OnUpdateCounter(Counter meas, UInt32 index, String id); 13 | public delegate void OnUpdateControlStatus(ControlStatus meas, UInt32 index, String id); 14 | public delegate void OnUpdateSetpointStatus(SetpointStatus meas, UInt32 index, String id); 15 | 16 | public interface IMeasurementSource 17 | { 18 | event OnUpdateBinary AllBinaryUpdate; 19 | event OnUpdateAnalog AllAnalogUpdate; 20 | event OnUpdateCounter AllCounterUpdate; 21 | event OnUpdateControlStatus AllControlStatusUpdate; 22 | event OnUpdateSetpointStatus AllSetpointStatusUpdate; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/LogControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | using DNP3.Interface; 11 | 12 | namespace DotNetTestSet 13 | { 14 | public partial class LogControl : UserControl 15 | { 16 | public LogControl() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | public void AddLogEntry(LogEntry le) 22 | { 23 | var items = new String[] { le.filterLevel.ToString(), le.time.ToLongTimeString(), le.message }; 24 | this.flickerFreeListView1.Items.Insert(0, new ListViewItem(items)); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/MasterSettingsForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | using DNP3.Interface; 11 | 12 | namespace TestSetControlLibrary 13 | { 14 | public partial class MasterSettingsForm : Form 15 | { 16 | public delegate void AddMaster(String name, FilterLevel level, MasterStackConfig config); 17 | public event AddMaster OnAddMaster; 18 | 19 | public MasterSettingsForm() 20 | { 21 | InitializeComponent(); 22 | } 23 | 24 | private void buttonAdd_Click(object sender, EventArgs e) 25 | { 26 | this.DialogResult = DialogResult.OK; 27 | this.Close(); 28 | } 29 | 30 | private void MasterSettingsForm_FormClosed(object sender, FormClosedEventArgs e) 31 | { 32 | if (DialogResult == DialogResult.OK && OnAddMaster != null) 33 | { 34 | MasterStackConfig config = new MasterStackConfig(); 35 | config.link = this.linkLayerSettingsControl1.Config; 36 | OnAddMaster(this.textBoxName.Text, FilterLevel.LEV_INTERPRET, config); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestSetControlLibrary")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestSetControlLibrary")] 13 | [assembly: AssemblyCopyright("Copyright © 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e7929496-1e02-406c-b475-db183b8ff8ea")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/StackDisplayControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | using DNP3.Interface; 11 | 12 | namespace TestSetControlLibrary 13 | { 14 | public interface IMasterControl 15 | { 16 | ICommandAcceptor CommandAcceptor 17 | { 18 | set; 19 | } 20 | } 21 | 22 | 23 | public partial class StackDisplayControl : UserControl 24 | { 25 | public StackDisplayControl() 26 | { 27 | InitializeComponent(); 28 | } 29 | 30 | public IMasterControl AddMaster(string name, IMeasurementSource source) 31 | { 32 | var display = new MasterDataDisplay(source); 33 | display.Dock = DockStyle.Fill; 34 | TabPage page = new TabPage(name); 35 | this.tabControlStacks.TabPages.Add(page); 36 | page.Controls.Add(display); 37 | return display; 38 | } 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/TcpClientSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using DNP3.Interface; 7 | 8 | namespace TestSetControlLibrary 9 | { 10 | public class TcpSettings 11 | { 12 | public TcpSettings(String name, String address, UInt16 port, FilterLevel level, UInt64 timeout) 13 | { 14 | this.name = name; 15 | this.address = address; 16 | this.port = port; 17 | this.level = level; 18 | this.timeout = timeout; 19 | } 20 | 21 | public readonly String name; 22 | public readonly String address; 23 | public readonly UInt16 port; 24 | public readonly FilterLevel level; 25 | public readonly UInt64 timeout; 26 | 27 | public override string ToString() 28 | { 29 | var lines = new String[] 30 | {"name: " + name, 31 | "address: " + address, 32 | "port: " + port, 33 | "level: " + level, 34 | "timeout: " + timeout 35 | }; 36 | 37 | return String.Join(Environment.NewLine, lines); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /windows/TestSetControlLibrary/TimeSeriesChartForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | using System.Windows.Forms.DataVisualization.Charting; 11 | 12 | namespace TestSetControlLibrary 13 | { 14 | public partial class TimeSeriesChartForm : Form 15 | { 16 | private Timer t1 = new System.Windows.Forms.Timer(); 17 | Series series; 18 | Random r = new Random(); 19 | 20 | public TimeSeriesChartForm() 21 | { 22 | InitializeComponent(); 23 | 24 | series = this.chart1.Series.Add("series 1"); 25 | series.XValueType = ChartValueType.Double; 26 | series.YValueType = ChartValueType.Double; 27 | series.ChartType = SeriesChartType.Spline; 28 | t1.Tick += new EventHandler(t1_Tick); 29 | t1.Interval = 1000; 30 | t1.Start(); 31 | 32 | } 33 | 34 | void t1_Tick(object sender, EventArgs e) 35 | { 36 | series.Points.AddXY(DateTime.Now, r.NextDouble()); 37 | } 38 | 39 | private void TimeSeriesChartForm_FormClosing(object sender, FormClosingEventArgs e) 40 | { 41 | this.t1.Stop(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /windows/TestSetInstaller/EULA.RTF: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} 2 | {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang1033\f0\fs20 Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\par 3 | } 4 | -------------------------------------------------------------------------------- /windows/TestSetInstaller/icons/dnp_banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/TestSetInstaller/icons/dnp_banner.bmp -------------------------------------------------------------------------------- /windows/TestSetInstaller/icons/square_dnp_16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/TestSetInstaller/icons/square_dnp_16.ico -------------------------------------------------------------------------------- /windows/TestSetInstaller/icons/square_dnp_32.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/TestSetInstaller/icons/square_dnp_32.ico -------------------------------------------------------------------------------- /windows/TestSetInstaller/icons/square_dnp_48.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gec/dnp3/6cfd21b1c799321eb544275586079251055a2fc3/windows/TestSetInstaller/icons/square_dnp_48.ico --------------------------------------------------------------------------------