예제 #1
0
        private async Task OpenIsolationPoints(Dictionary <long, DiscreteModbusData> isolationPoints)
        {
            var scadaCommandingClient     = ScadaCommandingClient.CreateClient();
            var enumerableCommandedValues = await CommandedValues.GetEnumerableDictionaryAsync();

            foreach (long measurementGid in isolationPoints.Keys)
            {
                await UpdateCommandedValues(measurementGid, enumerableCommandedValues);

                var value = (ushort)DiscreteCommandingType.OPEN;

                if (isolationPoints[measurementGid].Value == (ushort)DiscreteCommandingType.CLOSE && await GetCommandedValuesCondition(measurementGid, value))
                {
                    await scadaCommandingClient.SendSingleDiscreteCommand(measurementGid,
                                                                          value,
                                                                          CommandOriginType.OUTAGE_SIMULATOR);

                    var commandedValue = new CommandedValue()
                    {
                        MeasurementGid = measurementGid,
                        Value          = value,
                        TimeOfCreation = DateTime.UtcNow,
                    };

                    await CommandedValues.SetAsync(measurementGid, commandedValue);
                }
            }
        }
예제 #2
0
        private async Task <bool> GetCommandedValuesCondition(long measurementGid, ushort commandValue)
        {
            var result = true;
            var enumerableCommandedValues = await CommandedValues.GetEnumerableDictionaryAsync();

            if (enumerableCommandedValues.ContainsKey(measurementGid))
            {
                var commandedValue = enumerableCommandedValues[measurementGid];

                if (commandedValue.Value == commandValue)
                {
                    result = false;
                }
            }

            return(result);
        }