コード例 #1
0
        public List <List <double> > GetRatesForGridType2(string dataPath, ISOTreatmentZone treatmentZone)
        {
            if (treatmentZone == null || treatmentZone.ProcessDataVariables.Count <= 0)
            {
                return(null);
            }

            List <List <double> >        productRates = new List <List <double> >();
            Dictionary <string, ISOUnit> unitsByDDI   = new Dictionary <string, ISOUnit>();
            string filePath = Path.ChangeExtension(Path.Combine(dataPath, Filename), ".bin");

            using (var fileStream = File.OpenRead(filePath))
            {
                var bytes     = new byte[4];
                var rates     = new List <double>();
                var rateCount = 0;

                while (true)
                {
                    var result = fileStream.Read(bytes, 0, bytes.Length);
                    if (result == 0)
                    {
                        break;
                    }

                    var rate = BitConverter.ToInt32(bytes, 0);

                    ISOProcessDataVariable pdv = treatmentZone.ProcessDataVariables[rateCount];
                    ISOUnit unit = null;
                    if (!unitsByDDI.ContainsKey(pdv.ProcessDataDDI))
                    {
                        unit = UnitFactory.Instance.GetUnitByDDI(pdv.ProcessDataDDI.AsInt32DDI());
                        unitsByDDI.Add(pdv.ProcessDataDDI, unit);
                    }
                    unit = unitsByDDI[pdv.ProcessDataDDI];

                    if (unit != null)
                    {
                        rates.Add(unit.ConvertFromIsoUnit(rate));
                    }
                    else
                    {
                        throw new ApplicationException("Missing unit on rate calculation from PDV.");
                    }
                    rateCount++;

                    if (rateCount == treatmentZone.ProcessDataVariables.Count)
                    {
                        productRates.Add(rates);
                        rateCount = 0;
                        rates     = new List <double>();
                    }
                }
            }

            return(productRates);
        }
コード例 #2
0
        public static List <ISOProcessDataVariable> ReadXML(XmlNodeList nodes)
        {
            List <ISOProcessDataVariable> items = new List <ISOProcessDataVariable>();

            foreach (XmlNode node in nodes)
            {
                items.Add(ISOProcessDataVariable.ReadXML(node));
            }
            return(items);
        }
コード例 #3
0
        public static ISOProcessDataVariable ReadXML(XmlNode node)
        {
            ISOProcessDataVariable pdv = new ISOProcessDataVariable();

            pdv.ProcessDataDDI              = node.GetXmlNodeValue("@A");
            pdv.ProcessDataValue            = node.GetXmlNodeValueAsInt("@B");
            pdv.ProductIdRef                = node.GetXmlNodeValue("@C");
            pdv.DeviceElementIdRef          = node.GetXmlNodeValue("@D");
            pdv.ValuePresentationIdRef      = node.GetXmlNodeValue("@E");
            pdv.ActualCulturalPracticeValue = node.GetXmlNodeValueAsNullableInt("@F");
            pdv.ElementTypeInstanceValue    = node.GetXmlNodeValueAsNullableInt("@G");

            XmlNodeList pdvNodes = node.SelectNodes("PDV");

            if (pdvNodes != null)
            {
                pdv.ChildProcessDataVariables.AddRange(ISOProcessDataVariable.ReadXML(pdvNodes));
            }

            return(pdv);
        }
コード例 #4
0
        public static ISOTreatmentZone ReadXML(XmlNode tznNode)
        {
            ISOTreatmentZone treatmentZone = new ISOTreatmentZone();

            treatmentZone.TreatmentZoneCode       = tznNode.GetXmlNodeValueAsByte("@A");
            treatmentZone.TreatmentZoneDesignator = tznNode.GetXmlNodeValue("@B");
            treatmentZone.TreatmentZoneColour     = tznNode.GetXmlNodeValueAsNullableByte("@C");

            XmlNodeList pdvNodes = tznNode.SelectNodes("PDV");

            if (pdvNodes != null)
            {
                treatmentZone.ProcessDataVariables.AddRange(ISOProcessDataVariable.ReadXML(pdvNodes));
            }

            XmlNodeList plnNodes = tznNode.SelectNodes("PLN");

            if (plnNodes != null)
            {
                treatmentZone.Polygons.AddRange(ISOPolygon.ReadXML(plnNodes));
            }
            return(treatmentZone);
        }