示例#1
0
        private static void RegisterTransformers(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
        {
            foreach (var powerTransformer in command.PowerTransformers)
            {
                equipmentByGid[powerTransformer.GID] = new EquipmentNodeItem(powerTransformer.GetType(),
                                                                             powerTransformer,
                                                                             connectedTo: powerTransformer.TransformerWindings,
                                                                             hidden: true);
            }

            foreach (var ratioTapChanger in command.RatioTapChangers)
            {
                equipmentByGid[ratioTapChanger.GID] = new EquipmentNodeItem(ratioTapChanger.GetType(),
                                                                            ratioTapChanger,
                                                                            connectedTo: new[] { ratioTapChanger.TransformerWinding },
                                                                            hidden: true);
            }

            foreach (var winding in command.TransformerWindings)
            {
                var tapChanger       = equipmentByGid[winding.RatioTapChanger].Item as RatioTapChangerDto;
                var powerTransformer = equipmentByGid[winding.PowerTransformer].Item as PowerTransformerDto;
                var transformer      = new TransformerModel(winding, tapChanger, powerTransformer);

                equipmentByGid[winding.GID] = new EquipmentNodeItem(transformer.GetType(),
                                                                    transformer,
                                                                    connectedTo: winding.Terminals);
            }
        }
示例#2
0
 private static void RegisterDisconnectors(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var disconnector in command.Disconnectors)
     {
         equipmentByGid[disconnector.GID] = new EquipmentNodeItem(disconnector.GetType(),
                                                                  disconnector,
                                                                  connectedTo: disconnector.Terminals);
     }
 }
示例#3
0
 private static void RegisterAsynchronousMachines(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var item in command.AsynchronousMachines)
     {
         equipmentByGid[item.GID] = new EquipmentNodeItem(item.GetType(),
                                                          item,
                                                          connectedTo: item.Terminals);
     }
 }
示例#4
0
 private static void RegisterBreakers(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var breaker in command.Breakers)
     {
         equipmentByGid[breaker.GID] = new EquipmentNodeItem(breaker.GetType(),
                                                             breaker,
                                                             connectedTo: breaker.Terminals);
     }
 }
示例#5
0
 private static void RegisterConnectivityNodes(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var connectivityNode in command.ConnectivityNodes)
     {
         equipmentByGid[connectivityNode.GID] = new EquipmentNodeItem(connectivityNode.GetType(),
                                                                      connectivityNode,
                                                                      connectedTo: connectivityNode.Terminals,
                                                                      hidden: true);
     }
 }
示例#6
0
 private static void RegisterTerminals(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var terminal in command.Terminals)
     {
         equipmentByGid[terminal.GID] = new EquipmentNodeItem(terminal.GetType(),
                                                              terminal,
                                                              connectedTo: new[] { terminal.ConnectivityNode, terminal.ConductingEquipment },
                                                              hidden: true);
     }
 }
        public void Update(object sender, ModelUpdateCommand e)
        {
            EquipmentTreeNode root   = EquipmentTreeFactory.CreateFrom(e);
            var fastNodeLookupByMrid = new FastLookupByMrid(root);

            App.Current.Dispatcher.Invoke((System.Action) delegate
            {
                measurementUpdater = new MeasurementUpdater(fastNodeLookupByMrid);
                DisplayTree(root);
                UpdateTransfomerList(root);
            });
        }
示例#8
0
        public static Dictionary <long, EquipmentNodeItem> Convert(ModelUpdateCommand command)
        {
            var equipmentByGid = new Dictionary <long, EquipmentNodeItem>();

            RegisterConnectivityNodes(command, equipmentByGid);
            RegisterTerminals(command, equipmentByGid);
            RegisterAsynchronousMachines(command, equipmentByGid);
            RegisterBreakers(command, equipmentByGid);
            RegisterDisconnectors(command, equipmentByGid);
            RegisterTransformers(command, equipmentByGid);
            RegisterMeasurements(command, equipmentByGid);

            return(equipmentByGid);
        }
        public static EquipmentTreeNode CreateFrom(ModelUpdateCommand command)
        {
            Debug.WriteLine("Creating tree from command...");

            Dictionary <long, EquipmentNodeItem> equipmentNodeByGid = EquipmentByGidConverter.Convert(command);

            var nodes = GetTreeNodes(equipmentNodeByGid, command.SourceGid);

            foreach (var item in nodes)
            {
                item.TurnedOn = false;
            }
            return(nodes.FirstOrDefault());
        }
示例#10
0
 private static void RegisterMeasurements(ModelUpdateCommand command, Dictionary <long, EquipmentNodeItem> equipmentByGid)
 {
     foreach (var analogMeasurement in command.Analogs)
     {
         equipmentByGid[analogMeasurement.GID] = new EquipmentNodeItem(analogMeasurement.GetType(),
                                                                       analogMeasurement,
                                                                       connectedTo: new[] { analogMeasurement.Terminals },
                                                                       hidden: true);
     }
     foreach (var discreteMeasurement in command.Discretes)
     {
         equipmentByGid[discreteMeasurement.GID] = new EquipmentNodeItem(discreteMeasurement.GetType(),
                                                                         discreteMeasurement,
                                                                         connectedTo: new[] { discreteMeasurement.Terminals },
                                                                         hidden: true);
     }
 }
示例#11
0
        private bool TryApplyTransaction()
        {
            TransactionManagerProxy proxyForTM = new TransactionManagerProxy();

            //Zapocni transakciju i prijavi se na nju
            bool pom = false;

            while (!pom)
            {
                pom = proxyForTM.StartEnlist();
            }

            proxyForTM.Enlist();

            //Posalji Scadi i CEu novi model
            NMSSCADAProxy             proxyForScada = new NMSSCADAProxy();
            NMSCalculationEngineProxy proxyForCE    = new NMSCalculationEngineProxy();

            bool success = false;

            if (proxyForScada.ModelUpdate(affectedEntities))
            {
                success = true;
            }

            if (proxyForCE.ModelUpdate(affectedEntities))
            {
                success = true;
            }

            proxyForTM.EndEnlist(success);
            try
            {
                var instance = NMSServiceBus.StartInstance().GetAwaiter().GetResult();
                var dtos     = DtoConverter.Convert(networkDataModelCopy);
                var command  = new ModelUpdateCommand(dtos);
                instance.Send(command).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            catch { }

            return(success);
        }
示例#12
0
    // private ModelUpdateCommand _command;

    public ViewModel()
    {
        _model        = new Model();
        UpdateCommand = new ModelUpdateCommand();
    }
 public Task Handle(ModelUpdateCommand message, IMessageHandlerContext context)
 {
     modelUpdate.Invoke(this, message);
     return(Task.CompletedTask);
 }