Esempio n. 1
0
 public Simulator(ISimulatorConfiguration simulatorConfiguration)
 {
     prevList        = new List <Point>();
     operateCallback = new dnp3_protocol.dnp3types.DNP3ControlOperateCallback(cbOperate);
     debugCallback   = new dnp3_protocol.dnp3types.DNP3DebugMessageCallback(cbDebug);
     interval        = Int32.Parse(ConfigurationManager.AppSettings["interval"]);
     db = new dnp3_protocol.dnp3types.sDNPServerDatabase();
     this.simulatorConfiguration = simulatorConfiguration;
     simLogic = new SimulationLogic(this);
 }
Esempio n. 2
0
 private void DoWork()
 {
     if (Prepare())
     {
         while (executionFlag)
         {
             try
             {
                 dnp3_protocol.dnp3types.sDNPServerDatabase db = new dnp3_protocol.dnp3types.sDNPServerDatabase();
                 dnp3_protocol.dnp3api.DNP3GetServerDatabaseValue(DNP3serverhandle, ref db, ref ptErrorValue);
                 MarshalUnmananagedArray2Struct(db.psServerDatabasePoint, (int)db.u32TotalPoints, out List <dnp3_protocol.dnp3types.sServerDatabasePoint> points);
                 var result = ConvertToPoints(points);
                 foreach (var item in result)
                 {
                     if (item.GroupId == dnp3_protocol.dnp3types.eDNP3GroupID.ANALOG_INPUT || item.GroupId == dnp3_protocol.dnp3types.eDNP3GroupID.ANALOG_OUTPUTS)
                     {
                         var point = item as AnalogPoint;
                     }
                     else
                     {
                         var point = item as BinaryPoint;
                     }
                 }
                 updateEvent?.Invoke(this, new UpdateEventArgs()
                 {
                     Points = result
                 });
                 Simulation();
                 prevList = result;
                 if (configChange)
                 {
                     LoadConfifg(config);
                 }
                 Thread.Sleep(interval);
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }