bool HandleMeasurementValuesChange(MeasurementValuesChanged msg) { measurements.Update(msg); NetworkModel model = this.Model; foreach (KeyValuePair <long, int> dInput in msg.DiscreteInputs) { IdentifiedObject io = model.Get(dInput.Key); Discrete d = io as Discrete; if (d == null) { continue; } if (d.MeasurementType == MeasurementType.SwitchState) { Notify(new ObservableMessage(EObservableMessageType.SwitchStatusChanged)); break; } } Notify(new ObservableMessage(EObservableMessageType.MeasurementValuesChanged)); return(true); }
bool DownloadMeasurements() { NetworkModel model = this.Model; List <long> analogs = new List <long>(model.GetGIDsByType(DMSType.Analog)); List <long> discretes = new List <long>(model.GetGIDsByType(DMSType.Discrete)); List <KeyValuePair <long, float> > analogValues = null; List <KeyValuePair <long, int> > discreteValues = null; Client <ISCADAServiceContract> client = new Client <ISCADAServiceContract>("endpointSCADA"); client.Connect(); if (!client.Call <bool>(scada => { analogValues = scada.ReadAnalog(analogs); discreteValues = scada.ReadDiscrete(discretes); return(true); }, out _)) { client.Disconnect(); return(false); } client.Disconnect(); measurements.Update(new MeasurementValuesChanged() { AnalogInputs = analogValues, AnalogOutputs = new List <KeyValuePair <long, float> >(0), DiscreteInputs = discreteValues, DiscreteOutputs = new List <KeyValuePair <long, int> >(0) }); Notify(new ObservableMessage(EObservableMessageType.MeasurementValuesChanged)); return(true); }
bool HandleNetworkModelChange(NetworkModelChanged msg) { NetworkModelDownload download = new NetworkModelDownload(); if (!download.Download()) { return(false); } NetworkModel tModel = new NetworkModel(download); Interlocked.Exchange(ref model, tModel); Notify(new ObservableMessage(EObservableMessageType.NetworkModelChanged)); return(true); }