Ejemplo n.º 1
0
        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);
        }
        Brush GetNodeColor(IdentifiedObject io)
        {
            ModelCode mc;

            if (!dmsTypeToModelCodeMap.TryGetValue(ModelCodeHelper.GetTypeFromGID(io.GID), out mc))
            {
                return(Brushes.SlateGray);
            }

            if (!ModelCodeHelper.ModelCodeClassIsSubClassOf(mc, ModelCode.SWITCH))
            {
                return(GetColor(topology.GetNodeEnergization(io.GID)));
            }

            Switch s = (Switch)io;

            foreach (long measGID in s.Measurements)
            {
                Measurement m = (Measurement)networkModel.Get(measGID);

                if (m == null)
                {
                    continue;
                }

                if (m.MeasurementType == MeasurementType.SwitchState)
                {
                    int value;

                    if (!measurements.GetDiscreteInput(m.GID, out value))
                    {
                        continue;
                    }

                    if (value == 0)
                    {
                        return(Brushes.Green);                          //closed
                    }
                    else
                    {
                        return(Brushes.Blue);                           //open
                    }
                }
            }

            return(Brushes.SlateGray);
        }