示例#1
0
        private float GetCurrentFluidLevel()
        {
            ScadaExportProxy proxy = new ScadaExportProxy();
            var point = (proxy.GetData()["FluidLevel_Tank"] as AnalogPoint);

            return(point.Value);
        }
示例#2
0
        private void SendCommand(CeForecast forecastResult)
        {
            commands = new List <List <ScadaCommandingEvent> >();
            ScadaExportProxy proxy = new ScadaExportProxy();
            var points             = proxy.GetData();

            foreach (var item in forecastResult.Results.Take(24))
            {
                var cmds = new List <ScadaCommandingEvent>();
                for (int i = 0; i < item.Pumps.Count(); i++)
                {
                    var onOff = item.Pumps[i];
                    var time  = item.Times[i];
                    var flow  = item.Flows[i];

                    if (points.ContainsKey($"Breaker_2{i + 1}Status"))
                    {
                        var breaker2 = points[$"Breaker_2{i + 1}Status"];
                        if (onOff != 0)
                        {
                            var command1 = new ScadaCommandingEvent()
                            {
                                Index        = (uint)breaker2.Index,
                                RegisterType = breaker2.RegisterType,
                                Milliseconds = 0,
                                Value        = (uint)onOff
                            };
                            cmds.Add(command1);
                        }
                    }

                    if (points.ContainsKey($"Discrete_Tap{i + 1}") && onOff == 1)
                    {
                        var tap = points[$"Discrete_Tap{i + 1}"];

                        var command2 = new ScadaCommandingEvent()
                        {
                            Index        = (uint)tap.Index,
                            RegisterType = tap.RegisterType,
                            Milliseconds = 0,
                            Value        = (uint)(flow / 100)
                        };
                        cmds.Add(command2);
                    }
                }
                commands.Add(cmds);
            }
        }
示例#3
0
        private void TurnOffPumps()
        {
            ScadaExportProxy proxy = new ScadaExportProxy();
            var points             = proxy.GetData();

            if (points.ContainsKey("Breaker_21Status"))
            {
                var breaker1 = points["Breaker_21Status"] as DiscretePoint;
                var command1 = new ScadaCommandingEvent()
                {
                    Index        = (uint)breaker1.Index,
                    RegisterType = breaker1.RegisterType,
                    Value        = 0,
                    Milliseconds = 0
                };
                endpoint.Publish(command1).ConfigureAwait(false);
            }

            if (points.ContainsKey("Breaker_22Status"))
            {
                var breaker2 = points["Breaker_22Status"] as DiscretePoint;
                var command2 = new ScadaCommandingEvent()
                {
                    Index        = (uint)breaker2.Index,
                    RegisterType = breaker2.RegisterType,
                    Value        = 0,
                    Milliseconds = 0
                };

                endpoint.Publish(command2).ConfigureAwait(false);
            }

            if (points.ContainsKey("Breaker_23Status"))
            {
                var breaker3 = points["Breaker_23Status"] as DiscretePoint;
                var command3 = new ScadaCommandingEvent()
                {
                    Index        = (uint)breaker3.Index,
                    RegisterType = breaker3.RegisterType,
                    Value        = 0,
                    Milliseconds = 0
                };
                endpoint.Publish(command3).ConfigureAwait(false);
            }
        }
示例#4
0
        private void CheckState()
        {
            ScadaExportProxy proxy = new ScadaExportProxy();
            var measurements       = proxy.GetData();

            if (!measurements.ContainsKey("FluidLevel_Tank"))
            {
                return;
            }
            var fluidLevel = measurements["FluidLevel_Tank"] as AnalogPoint;

            if (points == 1)
            {
                var flows = 2 * ((measurements["Flow_AM2"] != null ? ((AnalogPoint)(measurements["Flow_AM2"])).Value / 4 : 0));
                if (LevelIsOptimal(fluidLevel.Value - flows))
                {
                    TurnOffPumps();
                }
            }
            else if (points == 2)
            {
                var flows = 2 * ((measurements["Flow_AM1"] != null ? ((AnalogPoint)(measurements["Flow_AM1"])).Value / 4 : 0) +
                                 (measurements["Flow_AM2"] != null ? ((AnalogPoint)(measurements["Flow_AM2"])).Value / 4 : 0));
                if (LevelIsOptimal(fluidLevel.Value - flows))
                {
                    TurnOffPumps();
                }
            }
            else if (points == 3)
            {
                var flows = 2 * ((measurements["Flow_AM1"] != null ? ((AnalogPoint)(measurements["Flow_AM1"])).Value / 4 : 0) +
                                 (measurements["Flow_AM2"] != null ? ((AnalogPoint)(measurements["Flow_AM2"])).Value / 4 : 0) +
                                 (measurements["Flow_AM3"] != null ? ((AnalogPoint)(measurements["Flow_AM3"])).Value / 4 : 0));
                if (LevelIsOptimal(fluidLevel.Value - flows))
                {
                    TurnOffPumps();
                }
            }
        }
示例#5
0
        private void OffSequence()
        {
            var clearCommand = new ScadaCommandingEvent()
            {
                Index        = 1,
                Milliseconds = 1,
                RegisterType = RegisterType.BINARY_INPUT,
                Value        = 0
            };

            endpoint.Publish(clearCommand).ConfigureAwait(false).GetAwaiter().GetResult();

            var proxy    = new ScadaExportProxy();
            var points   = proxy.GetData();
            var commands = new List <ScadaCommandingEvent>();

            foreach (var item in points)
            {
                if (item.Key.Contains("Breaker_21Status") || item.Key.Contains("Breaker_22Status") || item.Key.Contains("Breaker_23Status") || item.Key.Contains("Discrete_Tap"))
                {
                    var command = new ScadaCommandingEvent()
                    {
                        Index        = (uint)item.Value.Index,
                        RegisterType = item.Value.RegisterType,
                        Milliseconds = 0,
                        Value        = 0
                    };
                    commands.Add(command);
                }
            }

            foreach (var item in commands)
            {
                endpoint.Publish(item).ConfigureAwait(false);
            }
        }