private OperationTypeEnum GetOperationTypeFromLoggingDevices(ISOTime time) { HashSet <DeviceOperationType> representedTypes = new HashSet <DeviceOperationType>(); IEnumerable <string> distinctDeviceElementIDs = time.DataLogValues.Select(d => d.DeviceElementIdRef).Distinct(); foreach (string isoDeviceElementID in distinctDeviceElementIDs) { int?deviceElementID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoDeviceElementID); if (deviceElementID.HasValue) { DeviceElement deviceElement = DataModel.Catalog.DeviceElements.FirstOrDefault(d => d.Id.ReferenceId == deviceElementID.Value); if (deviceElement != null && deviceElement.DeviceClassification != null) { DeviceOperationType deviceOperationType = DeviceOperationTypes.FirstOrDefault(d => d.MachineEnumerationMember.ToModelEnumMember().Value == deviceElement.DeviceClassification.Value.Value); if (deviceOperationType != null) { representedTypes.Add(deviceOperationType); } } } } DeviceOperationType deviceType = representedTypes.FirstOrDefault(t => t.ClientNAMEMachineType >= 2 && t.ClientNAMEMachineType <= 11); if (deviceType != null) { //2-11 represent known types of operations //These will map to implement devices and will govern the actual operation type. //Return the first such device type return(deviceType.OperationType); } return(OperationTypeEnum.Unknown); }
public TaskDataMapper(string dataPath, Properties properties) { BaseFolder = dataPath; RepresentationMapper = new RepresentationMapper(); DDIs = DdiLoader.Ddis; Properties = properties; DeviceOperationTypes = new DeviceOperationTypes(); InstanceIDMap = new InstanceIDMap(); Errors = new List <IError>(); }
protected BaseMapper(TaskDataMapper taskDataMapper, string xmlPrefix, int startId = 1) { TaskDataMapper = taskDataMapper; XmlPrefix = xmlPrefix; _itemId = startId; DataModel = TaskDataMapper.AdaptDataModel; ISOTaskData = TaskDataMapper.ISOTaskData; UniqueIDMapper = TaskDataMapper.UniqueIDMapper; RepresentationMapper = TaskDataMapper.RepresentationMapper; DDIs = taskDataMapper.DDIs; DeviceOperationTypes = taskDataMapper.DeviceOperationTypes; }
private EnumeratedValue DecodeMachineInfo(string clientNAME) { if (string.IsNullOrEmpty(clientNAME) || clientNAME.Length != 16) { return(null); } byte deviceGroup; if (!byte.TryParse(clientNAME.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out deviceGroup)) { return(null); } deviceGroup >>= 4; if ((deviceGroup & 0x07) != 2) // Agricultural devices { return(null); } byte deviceClass; if (!byte.TryParse(clientNAME.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out deviceClass)) { return(null); } deviceClass >>= 1; AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember machineType = DefinedTypeEnumerationInstanceList.dtiTractor.ToModelEnumMember(); //Default DeviceOperationType deviceType = DeviceOperationTypes.SingleOrDefault(d => d.ClientNAMEMachineType == deviceClass); if (deviceType != null) { machineType = deviceType.MachineEnumerationMember.ToModelEnumMember(); } return(new EnumeratedValue { Representation = RepresentationInstanceList.dtMachineType.ToModelRepresentation(), Value = machineType }); }
public const string ExportVersion = "ExportVersion"; //Version "3" or "4" public TaskDataMapper(string dataPath, Properties properties) { BaseFolder = dataPath; RepresentationMapper = new RepresentationMapper(); DDIs = DdiLoader.Ddis; Properties = properties ?? new Properties(); DeviceOperationTypes = new DeviceOperationTypes(); InstanceIDMap = new InstanceIDMap(); Errors = new List <IError>(); //Export version string exportVersion = Properties.GetProperty(ExportVersion); if (Int32.TryParse(exportVersion, out int version)) { Version = version; //3 or 4 } if (version != 3 && version != 4) { Version = 4; //Default ISO Version for the export } }