Ejemplo n.º 1
0
        private float GetCurrentFluidLevel()
        {
            SF.Common.Proxies.ScadaExportProxy proxy = new SF.Common.Proxies.ScadaExportProxy(ConfigurationManager.AppSettings["Scada"]);
            var data = proxy.GetData().GetAwaiter().GetResult();

            if (data != null)
            {
                var point = (data["FluidLevel_Tank"] as AnalogPoint);
                return(point.Value);
            }
            return(0);
        }
Ejemplo n.º 2
0
        private void SendCommand(CeForecast forecastResult)
        {
            commands = new List <List <ScadaCommandingEvent> >();
            var proxy      = new SF.Common.Proxies.ScadaExportProxy(ConfigurationManager.AppSettings["Scada"]);
            var commanding = new CommandingProxy(ConfigurationManager.AppSettings["Command"]);
            var points     = proxy.GetData().GetAwaiter().GetResult();

            if (points == null)
            {
                return;
            }
            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);
            }
        }
Ejemplo n.º 3
0
        private void TurnOffPumps()
        {
            var commanding = new CommandingProxy(ConfigurationManager.AppSettings["Command"]);
            var proxy      = new SF.Common.Proxies.ScadaExportProxy(ConfigurationManager.AppSettings["Scada"]);
            var points     = proxy.GetData().GetAwaiter().GetResult();

            if (points == null)
            {
                return;
            }
            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
                };
                commanding.Commmand(new SCADA.Common.ScadaCommand(command1.RegisterType, command1.Index, command1.Value, command1.Milliseconds)).GetAwaiter().GetResult();
            }

            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
                };
                commanding.Commmand(new SCADA.Common.ScadaCommand(command2.RegisterType, command2.Index, command2.Value, command2.Milliseconds)).GetAwaiter().GetResult();
            }

            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
                };
                commanding.Commmand(new SCADA.Common.ScadaCommand(command3.RegisterType, command3.Index, command3.Value, command3.Milliseconds)).GetAwaiter().GetResult();
            }
        }
Ejemplo n.º 4
0
        private void OffSequence()
        {
            var commanding   = new CommandingProxy(ConfigurationManager.AppSettings["Command"]);
            var clearCommand = new ScadaCommandingEvent()
            {
                Index        = 1,
                Milliseconds = 1,
                RegisterType = RegisterType.BINARY_INPUT,
                Value        = 0
            };

            commanding.Commmand(new SCADA.Common.ScadaCommand(clearCommand.RegisterType, clearCommand.Index, clearCommand.Value, clearCommand.Milliseconds)).GetAwaiter().GetResult();

            var proxy  = new SF.Common.Proxies.ScadaExportProxy(ConfigurationManager.AppSettings["Scada"]);
            var points = proxy.GetData().GetAwaiter().GetResult();

            if (points == null)
            {
                return;
            }
            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)
            {
                commanding.Commmand(new SCADA.Common.ScadaCommand(item.RegisterType, item.Index, item.Value, item.Milliseconds)).GetAwaiter().GetResult();
            }
        }
Ejemplo n.º 5
0
        private void CheckState()
        {
            var proxy        = new SF.Common.Proxies.ScadaExportProxy(ConfigurationManager.AppSettings["Scada"]);
            var measurements = proxy.GetData().GetAwaiter().GetResult();

            if (measurements == null || !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();
                }
            }
        }