Example #1
0
        public static void PopulateDiscreteProperties(Outage.Discrete cimDiscrete, ResourceDescription rd, ImportHelper importHelper, TransformAndLoadReport report)
        {
            if ((cimDiscrete != null) && (rd != null))
            {
                OutageConverter.PopulateMeasurementProperties(cimDiscrete, rd, importHelper, report);

                if (cimDiscrete.CurrentOpenHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.DISCRETE_CURRENTOPEN, cimDiscrete.CurrentOpen));
                }

                if (cimDiscrete.MaxValueHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.DISCRETE_MAXVALUE, cimDiscrete.MaxValue));
                }

                if (cimDiscrete.MeasurementTypeHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.DISCRETE_MEASUREMENTTYPE, (short)GetDiscreteMeasuremetType(cimDiscrete.MeasurementType)));
                }

                if (cimDiscrete.MinValueHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.DISCRETE_MINVALUE, cimDiscrete.MinValue));
                }

                if (cimDiscrete.NormalValueHasValue)
                {
                    rd.AddProperty(new Property(ModelCode.DISCRETE_NORMALVALUE, cimDiscrete.NormalValue));
                }
            }
        }
        private ResourceDescription CreateDiscreteResourceDescription(Outage.Discrete cimDiscrete)
        {
            ResourceDescription rd = null;

            if (cimDiscrete != null)
            {
                long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.DISCRETE, importHelper.CheckOutIndexForDMSType(DMSType.DISCRETE));
                rd = new ResourceDescription(gid);
                importHelper.DefineIDMapping(cimDiscrete.ID, gid);

                OutageConverter.PopulateDiscreteProperties(cimDiscrete, rd, importHelper, report);
            }

            return(rd);
        }
        private void ImportDiscretes()
        {
            SortedDictionary <string, object> cimDiscretes = concreteModel.GetAllObjectsOfType("Outage.Discrete");

            if (cimDiscretes != null)
            {
                foreach (KeyValuePair <string, object> cimDiscretePair in cimDiscretes)
                {
                    Outage.Discrete     cimDiscrete = cimDiscretePair.Value as Outage.Discrete;
                    ResourceDescription rd          = CreateDiscreteResourceDescription(cimDiscrete);
                    if (rd != null)
                    {
                        string mrid = cimDiscrete.MRID;
                        CreateAndInsertDeltaOperation(mrid, rd);

                        report.Report.Append("Discret ID: ").Append(cimDiscrete.ID).Append(" SUCCESSFULLY converted to GID: ").AppendLine($"0x{rd.Id:X16}");
                    }
                    else
                    {
                        report.Report.Append("Discret ID: ").Append(cimDiscrete.ID).AppendLine(" FAILED to be converted");
                    }
                }
            }
        }