private void DataForSendingToCEandSCADA()
        {
            Dictionary <DMSType, Dictionary <long, IdentifiedObject> > insertCE    = new Dictionary <DMSType, Dictionary <long, IdentifiedObject> >();
            Dictionary <DMSType, Dictionary <long, IdentifiedObject> > updateCE    = new Dictionary <DMSType, Dictionary <long, IdentifiedObject> >();
            Dictionary <DMSType, Dictionary <long, IdentifiedObject> > deleteCE    = new Dictionary <DMSType, Dictionary <long, IdentifiedObject> >();
            Dictionary <int, Dictionary <long, IdentifiedObject> >     insertSCADA = new Dictionary <int, Dictionary <long, IdentifiedObject> >();
            Dictionary <int, Dictionary <long, IdentifiedObject> >     updateSCADA = new Dictionary <int, Dictionary <long, IdentifiedObject> >();
            Dictionary <int, Dictionary <long, IdentifiedObject> >     deleteSCADA = new Dictionary <int, Dictionary <long, IdentifiedObject> >();

            foreach (DMSType dmst in networkModel.networkDataModel.Keys)
            {
                Container container = networkModel.networkDataModel[dmst];

                foreach (long key in container.Entities.Keys)
                {
                    //insert
                    if (networkModel.insert.Contains(key))
                    {
                        if (!insertCE.ContainsKey(dmst))
                        {
                            Dictionary <long, IdentifiedObject> helper = new Dictionary <long, IdentifiedObject>();
                            helper.Add(key, container.Entities[key]);
                            insertCE[dmst] = helper;
                            //if (dmst == DMSType.ANALOG || dmst == DMSType.DISCRETE)
                            if (dmst == DMSType.ANALOG)
                            {
                                insertSCADA[1] = helper;
                            }
                            else if (dmst == DMSType.DISCRETE)
                            {
                                insertSCADA[0] = helper;
                            }
                        }
                        else
                        {
                            insertCE[dmst].Add(key, container.Entities[key]);
                        }
                    }

                    //update
                    if (networkModel.update.Contains(key))
                    {
                        if (!updateCE.ContainsKey(dmst))
                        {
                            Dictionary <long, IdentifiedObject> helper = new Dictionary <long, IdentifiedObject>();
                            helper.Add(key, container.Entities[key]);
                            updateCE[dmst] = helper;
                            if (dmst == DMSType.ANALOG)
                            {
                                updateSCADA[1] = helper;
                            }
                            else if (dmst == DMSType.DISCRETE)
                            {
                                updateSCADA[0] = helper;
                            }
                        }
                        else
                        {
                            updateCE[dmst].Add(key, container.Entities[key]);
                        }
                    }

                    //delete
                    if (networkModel.delete.Contains(key))
                    {
                        if (!deleteCE.ContainsKey(dmst))
                        {
                            Dictionary <long, IdentifiedObject> helper = new Dictionary <long, IdentifiedObject>();
                            helper.Add(key, container.Entities[key]);
                            deleteCE[dmst] = helper;
                            if (dmst == DMSType.ANALOG)
                            {
                                deleteSCADA[1] = helper;
                            }
                            else if (dmst == DMSType.DISCRETE)
                            {
                                deleteSCADA[0] = helper;
                            }
                        }
                        else
                        {
                            deleteCE[dmst].Add(key, container.Entities[key]);
                        }
                    }
                }
            }

            networkModelTransfer = new NetworkModelTransfer(insertCE, updateCE, deleteCE);
            signalsTransfer      = new SignalsTransfer(insertSCADA, updateSCADA, deleteSCADA);
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Analog temp1 = new Analog(30064771073);

            temp1.Name                = "Wind";
            temp1.NormalValue         = 1700;
            temp1.PowerSystemResource = 21474836482;
            temp1.Description         = "Aqusition";
            temp1.Latitude            = (float)45.27777;
            temp1.Longitude           = (float)19.7993031;
            temp1.MaxValue            = 20;
            temp1.MinValue            = 10;
            temp1.Mrid                = "a_22";
            temp1.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            //////////////////Simulation
            Analog temp2 = new Analog(30064771074);

            temp2.Name                = "Wind";
            temp2.NormalValue         = 1700;
            temp2.PowerSystemResource = 21474836482;
            temp2.Description         = "Simulation";
            temp2.Latitude            = (float)45.27777;
            temp2.Longitude           = (float)19.7993031;
            temp2.MaxValue            = 20;
            temp2.MinValue            = 10;
            temp2.Mrid                = "a_2221";
            temp2.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            //////////Commmanding
            Analog temp3 = new Analog(30064771075);

            temp3.Name                = "Wind";
            temp3.NormalValue         = 0;
            temp3.PowerSystemResource = 21474836482;
            temp3.Description         = "Commanding";
            temp3.Latitude            = (float)45.27777;
            temp3.Longitude           = (float)19.7993031;
            temp3.MaxValue            = 20;
            temp3.MinValue            = 10;
            temp3.Mrid                = "a_2222";
            temp3.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            ////////////////DRUGI SIGNAL
            Analog temp4 = new Analog(30064771076);

            temp4.Name                = "Solar";
            temp4.NormalValue         = 986;
            temp4.PowerSystemResource = 21474836481;
            temp4.Description         = "Aqusition";
            temp4.Latitude            = (float)19.7993031;
            temp4.Longitude           = (float)45.27777;
            temp4.MaxValue            = 20;
            temp4.MinValue            = 10;
            temp4.Mrid                = "a_22";
            temp4.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            //////////////////Simulation
            Analog temp5 = new Analog(30064771077);

            temp5.Name                = "Solar";
            temp5.NormalValue         = 986;
            temp5.PowerSystemResource = 21474836481;
            temp5.Description         = "Simulation";
            temp5.Latitude            = (float)19.7993031;
            temp5.Longitude           = (float)45.27777;
            temp5.MaxValue            = 20;
            temp5.MinValue            = 10;
            temp5.Mrid                = "a_22";
            temp5.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            //////////Commmanding
            Analog temp6 = new Analog(30064771078);

            temp6.Name                = "Solar";
            temp6.NormalValue         = 0;
            temp6.PowerSystemResource = 21474836481;
            temp6.Description         = "Commanding";
            temp6.Latitude            = (float)19.7993031;
            temp6.Longitude           = (float)45.27777;
            temp6.MaxValue            = 20;
            temp6.MinValue            = 10;
            temp6.Mrid                = "a_22";
            temp6.MeasurementType     = FTN.Common.MeasurementType.ActivePower;
            ///////////////TRECI SIGNAL
            Analog temp7 = new Analog(30064771079);

            temp7.Name                = "Wind";
            temp7.NormalValue         = 2486;
            temp7.PowerSystemResource = 21474836484;
            temp7.Description         = "Aqusition";
            temp7.Latitude            = (float)19.7993031;
            temp7.Longitude           = (float)45.27777;
            temp7.MaxValue            = 20;
            temp7.MinValue            = 10;
            temp7.Mrid                = "a_22";
            temp7.MeasurementType     = FTN.Common.MeasurementType.ActivePower;

            Analog temp8 = new Analog(30064771080);

            temp8.Name                = "Wind";
            temp8.NormalValue         = 2486;
            temp8.PowerSystemResource = 21474836484;
            temp8.Description         = "Simulation";
            temp8.Latitude            = (float)19.7993031;
            temp8.Longitude           = (float)45.27777;
            temp8.MaxValue            = 20;
            temp8.MinValue            = 10;
            temp8.Mrid                = "a_22";
            temp8.MeasurementType     = FTN.Common.MeasurementType.ActivePower;

            Analog temp9 = new Analog(30064771081);

            temp9.Name                = "Wind";
            temp9.NormalValue         = 0;
            temp9.PowerSystemResource = 21474836484;
            temp9.Description         = "Commanding";
            temp9.Latitude            = (float)19.7993031;
            temp9.Longitude           = (float)45.27777;
            temp9.MaxValue            = 20;
            temp9.MinValue            = 10;
            temp9.Mrid                = "a_22";
            temp9.MeasurementType     = FTN.Common.MeasurementType.ActivePower;

            Dictionary <int, Dictionary <long, IdentifiedObject> > insert = new Dictionary <int, Dictionary <long, IdentifiedObject> >();
            Dictionary <int, Dictionary <long, IdentifiedObject> > update = new Dictionary <int, Dictionary <long, IdentifiedObject> >();
            Dictionary <int, Dictionary <long, IdentifiedObject> > delete = new Dictionary <int, Dictionary <long, IdentifiedObject> >();
            Dictionary <long, IdentifiedObject> tempDic = new Dictionary <long, IdentifiedObject>();

            tempDic.Add(temp1.GlobalId, temp1);
            tempDic.Add(temp2.GlobalId, temp2);
            tempDic.Add(temp3.GlobalId, temp3);
            tempDic.Add(temp4.GlobalId, temp4);
            tempDic.Add(temp5.GlobalId, temp5);
            tempDic.Add(temp6.GlobalId, temp6);
            tempDic.Add(temp7.GlobalId, temp7);
            tempDic.Add(temp8.GlobalId, temp8);
            tempDic.Add(temp9.GlobalId, temp9);

            insert.Add(0, tempDic);
            SignalsTransfer signalsTransfer = new SignalsTransfer(insert, update, delete);
            //int siz = Marshal.SizeOf(signalsTransfer);
            NetTcpBinding binding = new NetTcpBinding();

            binding.Security = new NetTcpSecurity()
            {
                Mode = SecurityMode.None
            };
            factory = new ChannelFactory <ISendDataFromNMSToScada>(binding, new EndpointAddress("net.tcp://localhost:19012/ISendDataFromNMSToScada"));

            sendToScada = factory.CreateChannel();
            bool result = false;

            result = sendToScada.CheckForTM(signalsTransfer);
            result = sendToScada.SendGids(signalsTransfer);
        }