Пример #1
0
        private void InsertEntity(ResourceDescription rd)
        {
            string message = "";

            if (rd == null)
            {
                message = String.Format("Insert entity is not done because update operation is empty.");
                LogHelper.Log(LogTarget.File, LogService.SCADATwoPhaseCommit, " ERROR - SCADAModel.cs - " + message);

                throw new Exception(message);
            }

            long   globalId = rd.Id;
            string mrid     = rd.Properties[0].PropertyValue.StringValue;

            message = String.Format("Inserting entity with GID ({0:x16}).", globalId);
            LogHelper.Log(LogTarget.File, LogService.SCADATwoPhaseCommit, " INFO - SCADAModel.cs - " + message);

            if (EntityExists(globalId, mrid))
            {
                message = String.Format("Failed to insert analog value because entity already exists in network model.");
                LogHelper.Log(LogTarget.File, LogService.SCADATwoPhaseCommit, " ERROR - SCADAModel.cs - " + message);
                throw new Exception(message);
            }

            AnalogValue newAnalogV = new AnalogValue(rd.Id);

            newAnalogV.ConvertFromRD(rd);
            analogValuesCopy.Add(newAnalogV);
        }
Пример #2
0
        public List <AnalogValue> GetAnalogValues()
        {
            int                iteratorId   = 0;
            List <long>        ids          = new List <long>();
            List <AnalogValue> analogValues = new List <AnalogValue>();

            try
            {
                int numberOfResources = 500;
                int resourcesLeft     = 0;

                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.ANALOGVALUE);

                iteratorId    = GdaQueryProxy.GetExtentValues(ModelCode.ANALOGVALUE, properties);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        var         rg          = GdaQueryProxy.GetValues(rds[i].Id, properties);
                        AnalogValue analogValue = new AnalogValue(rds[i].Id);
                        analogValues.Add(analogValue.ConvertFromRD(rg));
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception e)
            {
                string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", ModelCode.ANALOGVALUE, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(analogValues);
        }