public void OnPointUpdate(int tPoints) { pointUpdateOccures = true; if (points > 0) { skip = true; } points = tPoints; Stop(); OffSequence(); SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(false); indexGraph = indexUpdate = 0; seconds = 0; simulation = false; Start(); }
public async Task <bool> Commit() { ServiceEventSource.Current.ServiceMessage(_context, "SCADA Transaction - Commit!"); ScadaStorageProxy proxy = new ScadaStorageProxy(ConfigurationReader.ReadValue(_context, "Settings", "Storage")); await proxy.SetModel(await proxy.GetTransactionModel()); var model = await proxy.GetModel(); ushort aiCount = (ushort)(model.Values.Where(x => !String.IsNullOrEmpty(x.Mrid) && x.RegisterType == SCADA.Common.DataModel.RegisterType.ANALOG_INPUT).Count()); ushort aoCount = (ushort)(model.Values.Where(x => !String.IsNullOrEmpty(x.Mrid) && x.RegisterType == SCADA.Common.DataModel.RegisterType.ANALOG_OUTPUT).Count()); ushort biCount = (ushort)(model.Values.Where(x => !String.IsNullOrEmpty(x.Mrid) && x.RegisterType == SCADA.Common.DataModel.RegisterType.BINARY_INPUT).Count()); ushort boCount = (ushort)(model.Values.Where(x => !String.IsNullOrEmpty(x.Mrid) && x.RegisterType == SCADA.Common.DataModel.RegisterType.BINARY_OUTPUT).Count()); try { SimulatorProxy sim = new SimulatorProxy(); sim.UpdateConfig(Tuple.Create <ushort, ushort, ushort, ushort>(biCount, boCount, aiCount, aoCount), result.MridIndexPairs); } catch { } DomServiceProxy dom = new DomServiceProxy(ConfigurationReader.ReadValue(_context, "Settings", "Dom")); await dom.Add((await proxy.GetModel()).Values.ToList().ToDbModel()); return(true); }
private void DoWorkNew() { Thread.Sleep(10000); graph = new CeGraphicalEvent(); graph.PumpsValues = new Core.Common.ServiceBus.Events.CeGraph(); while (endFlag) { try { if (points <= 0 || points > 3) { continue; } CheckState(); if (hourIndexChanged == 3600) { hourIndex++; } if (seconds == 10800 || seconds == 0 || pointUpdateOccures) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(false); indexGraph = indexUpdate = 0; Calculations(); if (seconds == 10800) { seconds = 0; } } if (points > 0 && commands != null && graph != null) { if (!simulation) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(true); simulation = true; } if (seconds % 45 == 0) { if (indexUpdate < 24) { Command(); } indexUpdate++; if (indexGraph < 24) { UpdateGraph(); } indexGraph++; if (indexGraph == 23) { SimulatorProxy invoker = new SimulatorProxy(); invoker.SimulatorSettings(false); } } } Thread.Sleep(TimeSpan.FromSeconds(1)); seconds += 1; hourIndexChanged += 1; } catch (Exception e) { Console.WriteLine(e.Message); } } }