private static ImplementConfiguration AddImplementConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy deviceHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { ImplementConfiguration implementConfig = new ImplementConfiguration(); //Description implementConfig.Description = $"{deviceHierarchy.DeviceElement.Device.DeviceDesignator} : {deviceHierarchy.DeviceElement.DeviceElementDesignator}"; //Device Element ID implementConfig.DeviceElementId = adaptDeviceElement.Id.ReferenceId; //Offsets implementConfig.Offsets = new List <NumericRepresentationValue>(); if (deviceHierarchy.XOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.XOffsetRepresentation); } if (deviceHierarchy.YOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.YOffsetRepresentation); } if (deviceHierarchy.ZOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.ZOffsetRepresentation); } //Total Width if (deviceHierarchy.Width != null) { implementConfig.PhysicalWidth = deviceHierarchy.WidthRepresentation; } //Row Width NumericRepresentationValue rowWidth = deviceHierarchy.GetLowestLevelSectionWidth(); if (rowWidth != null) { implementConfig.Width = rowWidth; } catalog.DeviceElementConfigurations.Add(implementConfig); return(implementConfig); }
private static SectionConfiguration AddSectionConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy deviceHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { SectionConfiguration sectionConfiguration = new SectionConfiguration(); //Description sectionConfiguration.Description = $"{deviceHierarchy.DeviceElement.Device.DeviceDesignator} : {deviceHierarchy.DeviceElement.DeviceElementDesignator}"; //Device Element ID sectionConfiguration.DeviceElementId = adaptDeviceElement.Id.ReferenceId; NumericRepresentationValue width = deviceHierarchy.WidthRepresentation; NumericRepresentationValue xOffset = deviceHierarchy.XOffsetRepresentation; NumericRepresentationValue yOffset = deviceHierarchy.YOffsetRepresentation; if (adaptDeviceElement.DeviceElementType == DeviceElementTypeEnum.Bin) { //A bin carries no geometry information and should inherit width from its parent and carry 0 offsets from its parent. width = deviceHierarchy.Parent.WidthRepresentation; xOffset = 0.AsNumericRepresentationValue("0086", deviceHierarchy.RepresentationMapper); yOffset = 0.AsNumericRepresentationValue("0087", deviceHierarchy.RepresentationMapper); } //Width & Offsets sectionConfiguration.SectionWidth = width; sectionConfiguration.Offsets = new List <NumericRepresentationValue>(); if (xOffset != null) { sectionConfiguration.InlineOffset = xOffset; sectionConfiguration.Offsets.Add(xOffset); } if (yOffset != null) { sectionConfiguration.LateralOffset = yOffset; sectionConfiguration.Offsets.Add(yOffset); } catalog.DeviceElementConfigurations.Add(sectionConfiguration); return(sectionConfiguration); }
private static DeviceElementConfiguration AddDeviceElementConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy isoHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { switch (adaptDeviceElement.DeviceElementType) { case DeviceElementTypeEnum.Machine: return(AddMachineConfiguration(adaptDeviceElement, isoHierarchy, catalog)); case DeviceElementTypeEnum.Implement: return(AddImplementConfiguration(adaptDeviceElement, isoHierarchy, catalog)); case DeviceElementTypeEnum.Function: if (isoHierarchy.Parent.DeviceElement.DeviceElementType == ISODeviceElementType.Function) { //Function is part of the implement. I.e., TC-GEO example 9 / ISO 11783-10:2015(E) Figure F.24 return(AddSectionConfiguration(adaptDeviceElement, isoHierarchy, catalog)); } else { //Function is the entire implement return(AddImplementConfiguration(adaptDeviceElement, isoHierarchy, catalog)); } case DeviceElementTypeEnum.Section: case DeviceElementTypeEnum.Bin: case DeviceElementTypeEnum.Unit: return(AddSectionConfiguration(adaptDeviceElement, isoHierarchy, catalog)); default: return(null); } }
private static MachineConfiguration AddMachineConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy deviceHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { MachineConfiguration machineConfig = new MachineConfiguration(); //Description machineConfig.Description = $"{deviceHierarchy.DeviceElement.Device.DeviceDesignator} : {deviceHierarchy.DeviceElement.DeviceElementDesignator}"; //Device Element ID machineConfig.DeviceElementId = adaptDeviceElement.Id.ReferenceId; //Offsets if (deviceHierarchy.XOffset.HasValue || deviceHierarchy.YOffset.HasValue || deviceHierarchy.ZOffset.HasValue) { machineConfig.Offsets = new List <NumericRepresentationValue>(); if (deviceHierarchy.XOffset != null) { machineConfig.Offsets.Add(deviceHierarchy.XOffsetRepresentation); } if (deviceHierarchy.YOffset != null) { machineConfig.Offsets.Add(deviceHierarchy.YOffsetRepresentation); } if (deviceHierarchy.ZOffset != null) { machineConfig.Offsets.Add(deviceHierarchy.ZOffsetRepresentation); } } //GPS Offsets if (deviceHierarchy.Children != null && deviceHierarchy.Children.Any(h => h.DeviceElement != null && h.DeviceElement.DeviceElementType == ISODeviceElementType.Navigation)) { DeviceElementHierarchy navigation = (deviceHierarchy.Children.First(h => h.DeviceElement.DeviceElementType == ISODeviceElementType.Navigation)); machineConfig.GpsReceiverXOffset = navigation.XOffsetRepresentation; machineConfig.GpsReceiverYOffset = navigation.YOffsetRepresentation; machineConfig.GpsReceiverZOffset = navigation.ZOffsetRepresentation; } catalog.DeviceElementConfigurations.Add(machineConfig); return(machineConfig); }
public static DeviceElementConfiguration GetDeviceElementConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy isoHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { if (isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Connector || isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Navigation) { //Data belongs to the parent device element from the ISO element referenced //Connector and Navigation data may be stored in Timelog data, but Connectors are not DeviceElements in ADAPT. //The data refers to the parent implement, which must always be a Device DET per the ISO spec. DeviceElement parent = catalog.DeviceElements.FirstOrDefault(d => d.Id.ReferenceId == adaptDeviceElement.ParentDeviceId); while (parent != null && (parent.DeviceElementType != DeviceElementTypeEnum.Machine && parent.DeviceElementType != DeviceElementTypeEnum.Implement)) { parent = catalog.DeviceElements.FirstOrDefault(d => d.Id.ReferenceId == parent.ParentDeviceId); } if (parent == null) { throw new ApplicationException($"Cannot identify Device for Navigation/Connector DeviceElement: {adaptDeviceElement.Description}."); } DeviceElementConfiguration parentConfig = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == parent.Id.ReferenceId); if (parentConfig == null) { DeviceElement parentElement = catalog.DeviceElements.Single(d => d.Id.ReferenceId == adaptDeviceElement.ParentDeviceId); parentConfig = AddDeviceElementConfiguration(parentElement, isoHierarchy.Parent, catalog); } return(parentConfig); } else { DeviceElementConfiguration deviceConfiguration = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == adaptDeviceElement.Id.ReferenceId); if (deviceConfiguration == null) { deviceConfiguration = AddDeviceElementConfiguration(adaptDeviceElement, isoHierarchy, catalog); } return(deviceConfiguration); } }
public static DeviceElementConfiguration GetDeviceElementConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy isoHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { if (isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Connector || isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Navigation) { //Data belongs to the parent device element from the ISO element referenced //Connector and Navigation data may be stored in Timelog data, but Connectors are not DeviceElements in ADAPT. The data refers to the parent implement. DeviceElementConfiguration parentConfig = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == adaptDeviceElement.ParentDeviceId); if (parentConfig == null) { DeviceElement parentElement = catalog.DeviceElements.Single(d => d.Id.ReferenceId == adaptDeviceElement.ParentDeviceId); parentConfig = AddDeviceElementConfiguration(parentElement, isoHierarchy.Parent, catalog); } return(parentConfig); } else { DeviceElementConfiguration deviceConfiguration = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == adaptDeviceElement.Id.ReferenceId); if (deviceConfiguration == null) { deviceConfiguration = AddDeviceElementConfiguration(adaptDeviceElement, isoHierarchy, catalog); } return(deviceConfiguration); } }
private static SectionConfiguration AddSectionConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy deviceHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { SectionConfiguration sectionConfiguration = new SectionConfiguration(); //Description sectionConfiguration.Description = $"{deviceHierarchy.DeviceElement.Device.DeviceDesignator} : {deviceHierarchy.DeviceElement.DeviceElementDesignator}"; //Device Element ID sectionConfiguration.DeviceElementId = adaptDeviceElement.Id.ReferenceId; //Width & Offsets if (deviceHierarchy.Width != null) { sectionConfiguration.SectionWidth = deviceHierarchy.WidthRepresentation; } sectionConfiguration.Offsets = new List <NumericRepresentationValue>(); if (deviceHierarchy.XOffset != null) { sectionConfiguration.InlineOffset = deviceHierarchy.XOffsetRepresentation; sectionConfiguration.Offsets.Add(deviceHierarchy.XOffsetRepresentation); } if (deviceHierarchy.YOffset != null) { sectionConfiguration.LateralOffset = deviceHierarchy.YOffsetRepresentation; sectionConfiguration.Offsets.Add(deviceHierarchy.YOffsetRepresentation); } catalog.DeviceElementConfigurations.Add(sectionConfiguration); return(sectionConfiguration); }
public static DeviceElementConfiguration GetDeviceElementConfiguration(DeviceElement adaptDeviceElement, DeviceElementHierarchy isoHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { if ((isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Bin && (isoHierarchy.Parent.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Function || isoHierarchy.Parent.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Device)) || (isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Connector) || (isoHierarchy.DeviceElement.DeviceElementType == ISOEnumerations.ISODeviceElementType.Navigation)) { //Data belongs to the parent device element from the ISO element referenced //Bin children of functions or devices carry data that effectively belong to the parent device element in ISO. See TC-GEO examples 5-8. //Find the parent DeviceElementUse and add the data to that object. //Per the TC-GEO spec: "The location of the Bin type device elements as children of the boom specifies that the products from these bins are all distributed through that boom." //- //Also, Connector and Navigation data may be stored in Timelog data, but Connectors are not DeviceElements in ADAPT. The data refers to the parent implement. DeviceElementConfiguration parentConfig = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == adaptDeviceElement.ParentDeviceId); if (parentConfig == null) { DeviceElement parentElement = catalog.DeviceElements.Single(d => d.Id.ReferenceId == adaptDeviceElement.ParentDeviceId); parentConfig = AddDeviceElementConfiguration(parentElement, isoHierarchy.Parent, catalog); } return(parentConfig); } else { DeviceElementConfiguration deviceConfiguration = catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == adaptDeviceElement.Id.ReferenceId); if (deviceConfiguration == null) { deviceConfiguration = AddDeviceElementConfiguration(adaptDeviceElement, isoHierarchy, catalog); } return(deviceConfiguration); } }
private static ImplementConfiguration AddImplementConfiguration(DeviceElement adaptDeviceElement, DeviceHierarchyElement deviceHierarchy, AgGateway.ADAPT.ApplicationDataModel.ADM.Catalog catalog) { ImplementConfiguration implementConfig = new ImplementConfiguration(); //Description implementConfig.Description = $"{deviceHierarchy.DeviceElement.Device.DeviceDesignator} : {deviceHierarchy.DeviceElement.DeviceElementDesignator}"; //Device Element ID implementConfig.DeviceElementId = adaptDeviceElement.Id.ReferenceId; //Offsets implementConfig.Offsets = new List <NumericRepresentationValue>(); if (deviceHierarchy.XOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.XOffsetRepresentation); } if (deviceHierarchy.YOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.YOffsetRepresentation); } if (deviceHierarchy.ZOffsetRepresentation != null) { implementConfig.Offsets.Add(deviceHierarchy.ZOffsetRepresentation); } //Total Width if (deviceHierarchy.Width != null) { //In an earlier implementation, we used Width for an individual Row Width and Physical Width for the max width. //Going forward, we are adopting a more conventional definition that Width is any reported width of the implement, and //Physical width is a reported max width specifically. //Widths set from Timelog binaries will have already observed this convention as they did not contain the row width variation. implementConfig.Width = deviceHierarchy.WidthRepresentation; if (deviceHierarchy.WidthDDI == "0046") { implementConfig.PhysicalWidth = deviceHierarchy.WidthRepresentation; } } catalog.DeviceElementConfigurations.Add(implementConfig); return(implementConfig); }