Пример #1
0
        //data from CDUpdate
        private void PackUpdateData()
        {
            Array array = dumpingBufferToHistorical.SendToHistorical();

            list = array.Cast <DeltaCD>().ToList();

            historicalProperty = new HistoricalProperty();
            description        = new Description();
            descriptionList    = new DescriptionList();

            foreach (var item in list)
            {
                foreach (var item2 in item.CollectionDescriptionUpdate.PropertyCollection.DumpingProperties)
                {
                    historicalProperty.Code = item2.Code;
                    code = item2.Code;
                    historicalProperty.HistoricalValue = item2.DumpingValue;
                }

                //  description.Id = item.CollectionDescriptionAdd.Id;
                description.Dataset = item.CollectionDescriptionUpdate.Dataset;
                dataset             = item.CollectionDescriptionAdd.Dataset;

                if (CheckCodeAndDataset())
                {
                    description.HistoricalProperties.Add(historicalProperty);

                    descriptionList.Descriptions.Add(description);
                    descriptionLists.Add(descriptionList);
                }
                else
                {
                    Console.WriteLine("Error with code and dataset!");
                }
            }
        }
Пример #2
0
        //data from CDAdd
        public void PackAddData()
        {
            Array array = dumpingBufferToHistorical.SendToHistorical();

            list = array.Cast <DeltaCD>().ToList();

            historicalProperty = new HistoricalProperty();
            description        = new Description();
            descriptionList    = new DescriptionList();

            foreach (var item in list)
            {
                foreach (var item2 in item.CollectionDescriptionAdd.PropertyCollection.DumpingProperties)
                {
                    historicalProperty.Code = item2.Code;
                    code = item2.Code;
                    historicalProperty.HistoricalValue = item2.DumpingValue;

                    if (code == "CODE_ANALOG")
                    {
                        description.Id = 1;
                    }
                    else if (code == "CODE_DIGITAL")
                    {
                        description.Id = 2;
                    }
                    else if (code == "CODE_CUSTOM")
                    {
                        description.Id = 3;
                    }
                    else if (code == "CODE_LIMITSET")
                    {
                        description.Id = 4;
                    }
                    else if (code == "CODE_SINGLENOE")
                    {
                        description.Id = 5;
                    }
                    else if (code == "CODE_MULTIPLENODE")
                    {
                        description.Id = 6;
                    }
                    else if (code == "CODE_CONSUMER")
                    {
                        description.Id = 7;
                    }
                    else if (code == "CODE_SOURCE")
                    {
                        description.Id = 8;
                    }
                    else if (code == "CODE_MOTION")
                    {
                        description.Id = 9;
                    }
                    else if (code == "CODE_SENSOR")
                    {
                        description.Id = 10;
                    }

                    description.Dataset = item.CollectionDescriptionAdd.Dataset;
                    dataset             = item.CollectionDescriptionAdd.Dataset;

                    if (CheckCodeAndDataset())
                    {
                        description.HistoricalProperties.Add(historicalProperty);

                        descriptionList.Descriptions.Add(description);
                        descriptionLists.Add(descriptionList);
                    }
                    else
                    {
                        Console.WriteLine("Error with code and dataset!");
                    }
                }
            }

            Read();
        }
        public void SettingValues()
        {
            string code  = writer.ManualWriteToHistory().code;
            int    value = writer.ManualWriteToHistory().value;

            Console.WriteLine("******************");
            Console.WriteLine("Historical value:" + value);
            Console.WriteLine("Historical code:" + code);
            Console.WriteLine("******************");


            int indeks = CheckForUpdate(code);

            if (indeks < 0)
            {
                historicalProperty                 = new HistoricalProperty();
                historicalProperty.Code            = code;
                historicalProperty.HistoricalValue = value;

                description = new Description();
                description.HistoricalProperties.Add(historicalProperty);



                #region dataset and id
                if (code == "CODE_ANALOG")
                {
                    description.Dataset = 1;
                    description.Id      = 1;
                }
                else if (code == "CODE_DIGITAL")
                {
                    description.Dataset = 1;
                    description.Id      = 2;
                }
                else if (code == "CODE_CUSTOM")
                {
                    description.Dataset = 2;
                    description.Id      = 3;
                }
                else if (code == "CODE_LIMITSET")
                {
                    description.Dataset = 2;
                    description.Id      = 4;
                }
                else if (code == "CODE_SINGLENODE ")
                {
                    description.Dataset = 3;
                    description.Id      = 5;
                }
                else if (code == "CODE_MULTIPLENODE")
                {
                    description.Dataset = 3;
                    description.Id      = 6;
                }
                else if (code == "CODE_CONSUMER")
                {
                    description.Dataset = 4;
                    description.Id      = 7;
                }
                else if (code == "CODE_SOURCE")
                {
                    description.Dataset = 4;
                    description.Id      = 8;
                }
                else if (code == "CODE_MOTION")
                {
                    description.Dataset = 5;
                    description.Id      = 9;
                }
                else if (code == "CODE_SENSOR")
                {
                    description.Dataset = 5;
                    description.Id      = 10;
                }
                #endregion

                descriptionList = new DescriptionList();
                descriptionList.descriptions.Add(description);

                descriptionLists.Add(descriptionList);
            }
            else
            {
                foreach (var item in descriptionLists)
                {
                    foreach (var item2 in item.descriptions)
                    {
                        foreach (var item3 in item2.HistoricalProperties)
                        {
                            if (indeks == item2.Id)
                            {
                                item3.HistoricalValue = value;
                            }
                        }
                    }
                }
            }
            Read();

            Thread.Sleep(2000);
        }