示例#1
0
        public static ISOTime ReadXML(XmlNode node)
        {
            ISOTime time = new ISOTime();

            time.Start    = node.GetXmlNodeValueAsNullableDateTime("@A");
            time.Stop     = node.GetXmlNodeValueAsNullableDateTime("@B");
            time.Duration = node.GetXmlNodeValueAsNullableUInt("@C");
            time.TypeInt  = node.GetXmlNodeValueAsInt("@D");

            time.HasStart    = node.IsAttributePresent("A");
            time.HasStop     = node.IsAttributePresent("B");
            time.HasDuration = node.IsAttributePresent("C");
            time.HasType     = node.IsAttributePresent("D");

            XmlNodeList ptnNodes = node.SelectNodes("PTN");

            if (ptnNodes != null)
            {
                time.Positions.AddRange(ISOPosition.ReadXML(ptnNodes));
            }

            XmlNodeList dlvNodes = node.SelectNodes("DLV");

            if (dlvNodes != null)
            {
                time.DataLogValues.AddRange(ISODataLogValue.ReadXML(dlvNodes));
            }

            return(time);
        }
示例#2
0
        public static ISOTime Merge(ISOTime time, ISOTime otherTime)
        {
            if (time == null)
            {
                return(otherTime);
            }
            if (otherTime == null)
            {
                return(time);
            }

            ISOTime result = new ISOTime
            {
                // Pick earlier date
                Start = time.Start.Min(otherTime.Start),
                // Pick later date
                Stop = time.Stop.Max(otherTime.Stop),
                // Pick max from both since they most likely overlap
                Duration    = time.Duration.Max(otherTime.Duration),
                Type        = time.Type == 0 ? otherTime.Type : time.Type,
                HasStart    = time.HasStart || otherTime.HasStart,
                HasStop     = time.HasStop || otherTime.HasStop,
                HasDuration = time.HasDuration || otherTime.HasDuration,
                HasType     = time.HasType || otherTime.HasType
            };

            result.DataLogValues.AddRange(time.DataLogValues);
            result.DataLogValues.AddRange(otherTime.DataLogValues);

            return(result);
        }
示例#3
0
        public static List <ISOTime> ReadXML(XmlNodeList nodes)
        {
            List <ISOTime> items = new List <ISOTime>();

            foreach (XmlNode node in nodes)
            {
                items.Add(ISOTime.ReadXML(node));
            }
            return(items);
        }
示例#4
0
        public ISOTime GetTimeElement(string dataPath)
        {
            string filePath = Path.Combine(dataPath, string.Concat(Filename, ".xml"));

            if (File.Exists(filePath))
            {
                XmlDocument document = new XmlDocument();
                document.Load(filePath);

                XmlNode rootNode = document.SelectSingleNode("TIM");
                return(ISOTime.ReadXML(rootNode));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        public ISOTime GetTimeElement(string dataPath)
        {
            string xmlName  = string.Concat(Filename, ".xml");
            string filePath = dataPath.GetDirectoryFiles(xmlName, SearchOption.TopDirectoryOnly).FirstOrDefault();

            if (filePath != null)
            {
                XmlDocument document = new XmlDocument();
                document.Load(filePath);

                XmlNode rootNode = document.SelectSingleNode("TIM");
                return(ISOTime.ReadXML(rootNode));
            }
            else
            {
                return(null);
            }
        }
        public static ISOTask ReadXML(XmlNode taskNode)
        {
            ISOTask task = new ISOTask();

            task.TaskID                        = taskNode.GetXmlNodeValue("@A");
            task.TaskDesignator                = taskNode.GetXmlNodeValue("@B");
            task.CustomerIdRef                 = taskNode.GetXmlNodeValue("@C");
            task.FarmIdRef                     = taskNode.GetXmlNodeValue("@D");
            task.PartFieldIdRef                = taskNode.GetXmlNodeValue("@E");
            task.ResponsibleWorkerIdRef        = taskNode.GetXmlNodeValue("@F");
            task.TaskStatusInt                 = taskNode.GetXmlNodeValueAsInt("@G");
            task.DefaultTreatmentZoneCode      = taskNode.GetXmlNodeValueAsNullableInt("@H");
            task.PositionLostTreatmentZoneCode = taskNode.GetXmlNodeValueAsNullableInt("@I");
            task.OutOfFieldTreatmentZoneCode   = taskNode.GetXmlNodeValueAsNullableInt("@J");

            //Treatment Zones
            XmlNodeList tznNodes = taskNode.SelectNodes("TZN");

            if (tznNodes != null)
            {
                task.TreatmentZones.AddRange(ISOTreatmentZone.ReadXML(tznNodes));
            }

            //Times
            XmlNodeList timNodes = taskNode.SelectNodes("TIM");

            if (timNodes != null)
            {
                task.Times.AddRange(ISOTime.ReadXML(timNodes));
            }

            //Worker Allocations
            XmlNodeList wanNodes = taskNode.SelectNodes("WAN");

            if (wanNodes != null)
            {
                task.WorkerAllocations.AddRange(ISOWorkerAllocation.ReadXML(wanNodes));
            }

            //Device Allocations
            XmlNodeList danNodes = taskNode.SelectNodes("DAN");

            if (danNodes != null)
            {
                task.DeviceAllocations.AddRange(ISODeviceAllocation.ReadXML(danNodes));
            }

            //Connections
            XmlNodeList cnnNodes = taskNode.SelectNodes("CNN");

            if (cnnNodes != null)
            {
                task.Connections.AddRange(ISOConnection.ReadXML(cnnNodes));
            }

            //Product Allocations
            XmlNodeList panNodes = taskNode.SelectNodes("PAN");

            if (panNodes != null)
            {
                task.ProductAllocations.AddRange(ISOProductAllocation.ReadXML(panNodes));
            }

            //Data Log Triggers
            XmlNodeList dltNodes = taskNode.SelectNodes("DLT");

            if (dltNodes != null)
            {
                task.DataLogTriggers.AddRange(ISODataLogTrigger.ReadXML(dltNodes));
            }

            //Comment Allocations
            XmlNodeList canNodes = taskNode.SelectNodes("CAN");

            if (canNodes != null)
            {
                task.CommentAllocations.AddRange(ISOCommentAllocation.ReadXML(canNodes));
            }

            //Grid
            XmlNode grdNode = taskNode.SelectSingleNode("GRD");

            if (grdNode != null)
            {
                task.Grid = ISOGrid.ReadXML(grdNode);
            }

            //TimeLogs
            XmlNodeList tlgNodes = taskNode.SelectNodes("TLG");

            if (tlgNodes != null)
            {
                task.TimeLogs.AddRange(ISOTimeLog.ReadXML(tlgNodes));
            }

            //Guidance Allocations
            XmlNodeList ganNodes = taskNode.SelectNodes("GAN");

            if (ganNodes != null)
            {
                task.GuidanceAllocations.AddRange(ISOGuidanceAllocation.ReadXML(ganNodes));
            }

            //OperTechPractice
            XmlNode otpNode = taskNode.SelectSingleNode("OTP");

            if (otpNode != null)
            {
                task.OperationTechPractice = ISOOperTechPractice.ReadXML(otpNode);
            }

            return(task);
        }