예제 #1
0
        private unsafe int GetEnumerated(PIActionReference reference, uint *type, uint *enumValue)
        {
            if (enumValue == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                ActionReferenceItem item = container.GetReference();
                if (item != null)
                {
                    EnumeratedValue enumerated = (EnumeratedValue)item.Value;

                    if (type != null)
                    {
                        *type = enumerated.Type;
                    }
                    *enumValue = enumerated.Value;

                    return(PSError.kSPNoError);
                }
            }

            return(PSError.kSPBadParameterError);
        }
예제 #2
0
        public void GivenOperationDataWithSpatialRecordDataWithEnumeratedValueWhenProcessOperationDataThenRowsAreAdded()
        {
            var meter = new EnumeratedWorkingData {
                Representation = RepresentationInstanceList.dtRecordingStatus.ToModelRepresentation()
            };

            _workingDatas.Add(meter);
            _deviceElementUses.Add(0, new List <DeviceElementUse>
            {
                new DeviceElementUse
                {
                    Depth           = 0,
                    GetWorkingDatas = () => _workingDatas,
                }
            });

            var spatialRecord   = new SpatialRecord();
            var enumeratedValue = new EnumeratedValue {
                Value = DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember()
            };

            spatialRecord.SetMeterValue(meter, enumeratedValue);

            _spatialRecords.Add(spatialRecord);

            var dataTable = _operationDataProcessor.ProcessOperationData(_operationData, _spatialRecords);

            Assert.AreEqual(1, dataTable.Rows.Count);
            Assert.AreEqual(enumeratedValue.Value.Value, dataTable.Rows[0][4]);
        }
예제 #3
0
        public EnumeratedValue ImportCodedComment(ISOCodedComment comment)
        {
            EnumeratedValue value = new EnumeratedValue();

            value.Designator     = comment.CodedCommentDesignator;
            value.Representation = new EnumeratedRepresentation();
            value.Representation.EnumeratedMembers = _listMapper.ImportCodedCommentListValues(comment.CodedCommentListValues).ToList();
            return(value);
        }
예제 #4
0
        public ISOCodedComment ExportCodedComment(EnumeratedValue value)
        {
            ISOCodedComment comment = new ISOCodedComment();

            comment.CodedCommentID         = GenerateId();
            comment.CodedCommentDesignator = value.Representation.Description;
            comment.CodedCommentListValues = _listMapper.ExportCodedCommentList(value.Representation.EnumeratedMembers).ToList();
            ExportedComments.Add(comment);
            return(comment);
        }
        private static EnumeratedValue ParseEnumerated(BinaryReverseReader reader)
        {
            EnumeratedValue value = new EnumeratedValue()
            {
                type  = ParseKey(reader),
                value = ParseKey(reader)
            };

            return(value);
        }
        public void GivenIsoSpatialRowsWithoutEnumeratedMeterOnSecondWhenMapThenSecondValueIsInterpolator()
        {
            var spatialValue = new SpatialValue
            {
                Id    = 0,
                Value = 1
            };

            _isoSpatialRow.SpatialValues = new List <SpatialValue> {
                spatialValue
            };
            var isoSpatialRow2 = new ISOSpatialRow {
                SpatialValues = new List <SpatialValue>()
            };

            _isoSpatialRows = new List <ISOSpatialRow> {
                _isoSpatialRow, isoSpatialRow2
            };

            var meter = new ISOEnumeratedMeter
            {
                Representation = RepresentationInstanceList.dtSectionControlMasterState.ToModelRepresentation(),
                ValueCodes     = new List <int> {
                    1, 2, 3
                },
                DeviceElementUseId = 1,
                GetEnumeratedValue = (sv, im) => new EnumeratedValue {
                    Value = new AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember {
                        Code = 3
                    }
                }
            };

            var uniqueId = new UniqueId
            {
                IdType = IdTypeEnum.String,
                Id     = "DLV0"
            };

            meter.Id.UniqueIds.Add(uniqueId);
            _meters.Add(meter);


            var enumeratedRepresentation = new EnumeratedValue {
                Value = new AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember {
                    Code = 3
                }
            };

            _spatialValueInterpolator.Setup(s => s.Interpolate(meter)).Returns(enumeratedRepresentation);

            var result = Map().ToList();

            Assert.AreEqual(enumeratedRepresentation, result[1].GetMeterValue(meter) as EnumeratedValue);
        }
예제 #7
0
 private static void CompareWorkState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOff.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
 }
예제 #8
0
 private static void CompareNetWeightState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiWeightUnStable.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiWeightStable.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
 }
예제 #9
0
 private static void CompareCondensedSectionOverrideState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionUsed.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionOverridden.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
 }
예제 #10
0
        public IEnumerable <EnumeratedValue> ImportCodedComments(IEnumerable <ISOCodedComment> isoComments)
        {
            List <EnumeratedValue> enumerations = new List <EnumeratedValue>();

            foreach (ISOCodedComment isoComment in isoComments)
            {
                EnumeratedValue enumeration = ImportCodedComment(isoComment);
                enumerations.Add(enumeration);
            }

            return(enumerations);
        }
예제 #11
0
        private int PutEnumerated(PIActionList list, uint type, uint data)
        {
            try
            {
                EnumeratedValue item = new EnumeratedValue(type, data);
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Enumerated, item));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
        private static double GetActiveWidthFt(SpatialRecord spatialRecord, List <RowConfiguration> rows)
        {
            double activeWidthIn = 0;

            foreach (RowConfiguration row in rows)
            {
                EnumeratedValue rowStatus = spatialRecord.GetMeterValue(row.statusMeter) as EnumeratedValue;
                if (rowStatus.Value.Value == "On")
                {
                    activeWidthIn += row.widthIn;
                }
            }

            return(activeWidthIn / 12.0);
        }
예제 #13
0
 private static void ComparePrescriptionControl(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterManualOff.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterAutoOn.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterError.ToModelEnumMember().Code)
     {
         Assert.AreEqual(2, isoValue.Value);
     }
 }
예제 #14
0
        public IEnumerable <DeviceElement> ImportDeviceElements(ISODevice isoDevice)
        {
            EnumeratedValue deviceClassification = DecodeMachineInfo(isoDevice.ClientNAME);

            ISODeviceElement rootDeviceElement = isoDevice.DeviceElements.SingleOrDefault(det => det.DeviceElementType == ISODeviceElementType.Device);

            if (rootDeviceElement == null)
            {
                //Short circuit on invalid TaskData
                TaskDataMapper.AddError("Missing root DeviceElement.  Device will not be imported.", isoDevice.DeviceId.ToString(), "DeviceElementMapper");
                return(null);
            }

            DeviceElementHierarchy rootDeviceElementHierarchy = TaskDataMapper.DeviceElementHierarchies.Items[isoDevice.DeviceId];

            //Import device elements
            List <DeviceElement> adaptDeviceElements = new List <DeviceElement>();

            //Import down the hierarchy to ensure integrity of parent references
            for (int i = 0; i <= rootDeviceElementHierarchy.GetMaxDepth(); i++)
            {
                IEnumerable <ISODeviceElement> isoDeviceElements = rootDeviceElementHierarchy.GetElementsAtDepth(i).Select(h => h.DeviceElement);
                foreach (ISODeviceElement isoDeviceElement in isoDeviceElements)
                {
                    if (isoDeviceElement.DeviceElementType != ISODeviceElementType.Connector)
                    {
                        DeviceElement adaptDeviceElement = ImportDeviceElement(isoDeviceElement, deviceClassification, rootDeviceElementHierarchy);
                        if (isoDeviceElement.DeviceElementType == ISODeviceElementType.Device)
                        {
                            //Setting the Device serial number on the root Device Element only
                            adaptDeviceElement.SerialNumber = isoDevice.DeviceSerialNumber;
                        }
                        adaptDeviceElements.Add(adaptDeviceElement);
                        DataModel.Catalog.DeviceElements.Add(adaptDeviceElement);
                    }
                    else
                    {
                        //Connectors are not represented as DeviceElements in ADAPT
                        AddConnector(rootDeviceElementHierarchy, isoDeviceElement);
                    }
                }
            }

            return(adaptDeviceElements);
        }
예제 #15
0
        private int PutEnumerated(IntPtr descriptor, uint key, uint type, uint data)
        {
#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}({1})", key, DebugUtils.PropToString(key)));
#endif
            try
            {
                EnumeratedValue item = new EnumeratedValue(type, data);

                actionDescriptors[descriptor].Add(key, new AETEValue(DescriptorTypes.Enumerated, GetAETEParamFlags(key), 0, item));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
예제 #16
0
        public void GivenEnumeratedRepresentationValueWhenInterpolateThenRepresentationValue()
        {
            var previousEnumeratedValue = new EnumeratedValue
            {
                Representation = RepresentationInstanceList.dtSkyCondition.ToModelRepresentation()
            };

            var enumMember = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember();

            previousEnumeratedValue.Value = enumMember;
            previousEnumeratedValue.Code  = enumMember.Code;

            _interpolator.SetMostRecentMeterValue(_enumeratedMeter, previousEnumeratedValue);

            var result = _interpolator.Interpolate(_enumeratedMeter);

            Assert.IsInstanceOf <EnumeratedValue>(result);
        }
예제 #17
0
 private static void CompareActualLoadingSystemStatus(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateDisabled.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateEnabled.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateError.ToModelEnumMember().Code)
     {
         Assert.AreEqual(2, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateNotAvailable.ToModelEnumMember().Code)
     {
         Assert.AreEqual(3, isoValue.Value);
     }
 }
예제 #18
0
 private static void CompareSkyConditions(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiClear.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0x20524C43, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0x2043534E, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0x20544353, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember().Code)
     {
         Assert.AreEqual(0x2043564F, isoValue.Value);
     }
 }
예제 #19
0
 private static void CompareConnectorType(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiDrawbar.ToModelEnumMember().Code)
     {
         Assert.AreEqual(1, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember().Code)
     {
         Assert.AreEqual(2, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiThreePoint.ToModelEnumMember().Code)
     {
         Assert.AreEqual(3, isoValue.Value);
     }
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearPivotWagonHitch.ToModelEnumMember().Code)
     {
         Assert.AreEqual(7, isoValue.Value);
     }
 }
예제 #20
0
        private int GetEnumerated(IntPtr reference, ref uint type, ref uint enumValue)
        {
            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                ActionReferenceItem item = container.GetReference();
                if (item != null)
                {
                    EnumeratedValue enumerated = (EnumeratedValue)item.Value;
                    type      = enumerated.Type;
                    enumValue = enumerated.Value;

                    return(PSError.kSPNoError);
                }
            }

            return(PSError.kSPBadParameterError);
        }
예제 #21
0
        private void WriteListValues(XmlWriter writer, EnumeratedValue value)
        {
            if (value == null)
            {
                return;
            }

            if (value.Representation != null &&
                value.Representation.EnumeratedMembers != null)
            {
                _listWriter.Write(writer, value.Representation.EnumeratedMembers);
            }
            else if (value.Value != null)
            {
                _listWriter.Write(writer, new List <EnumerationMember> {
                    value.Value
                });
            }
        }
예제 #22
0
        public RepresentationValue Interpolate(WorkingData meter)
        {
            if (!_meterToPreviousValue.ContainsKey(meter))
            {
                return(null);
            }

            var previousValue = _meterToPreviousValue[meter];

            var numericRepresentationValue = previousValue as NumericRepresentationValue;

            if (numericRepresentationValue != null)
            {
                var newNumericRepresentationValue = numericRepresentationValue.Copy();

                if (numericRepresentationValue.Representation != null && _numericRepresentationTotals.Contains(numericRepresentationValue.Representation.Code))
                {
                    newNumericRepresentationValue.Value.Value = 0;
                }

                return(newNumericRepresentationValue);
            }

            var enumeratedValue = previousValue as EnumeratedValue;

            if (enumeratedValue != null)
            {
                var newEnumeratedValue = new EnumeratedValue
                {
                    Code  = enumeratedValue.Code,
                    Value = new EnumerationMember
                    {
                        Code  = enumeratedValue.Value.Code,
                        Value = enumeratedValue.Value.Value
                    },
                    Representation = enumeratedValue.Representation
                };

                return(newEnumeratedValue);
            }

            return(null);
        }
예제 #23
0
        public void GivenEnumeratedValueWhenInterpolateThenValueIsSameAsPrevious()
        {
            var previousEnumeratedValue = new EnumeratedValue
            {
                Representation = RepresentationInstanceList.dtSkyCondition.ToModelRepresentation()
            };

            var enumMember = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember();

            previousEnumeratedValue.Value = enumMember;
            previousEnumeratedValue.Code  = enumMember.Code;

            _interpolator.SetMostRecentMeterValue(_enumeratedMeter, previousEnumeratedValue);
            var result = _interpolator.Interpolate(_enumeratedMeter);

            var enumeratedRepresentation = result as EnumeratedValue;

            Assert.AreEqual(previousEnumeratedValue.Representation, enumeratedRepresentation.Representation);
            Assert.AreEqual(previousEnumeratedValue.Code, enumeratedRepresentation.Code);
        }
        private int ConvertToIsoValue(EnumeratedValue value)
        {
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateDisabled.ToModelEnumMember().Code)
            {
                return(0);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateEnabled.ToModelEnumMember().Code)
            {
                return(1);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateError.ToModelEnumMember().Code)
            {
                return(2);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateNotAvailable.ToModelEnumMember().Code)
            {
                return(3);
            }

            return(3);
        }
예제 #25
0
        public UInt32 GetMetersValue(List <WorkingData> meters, SpatialRecord spatialRecord)
        {
            // Martin Sperlich: I've got a GS3_2630 data set here for which meters.FirstOrDefault()
            // does return an AgGateway.ADAPT.ApplicationDataModel.LoggedData.EnumeratedWorkingData object.
            // The direct cast to AgGateway.ADAPT.ApplicationDataModel.LoggedData.EnumeratedWorkingData
            // does throw an invalid typecast exception.

            // var meter = (ISOEnumeratedMeter) meters.FirstOrDefault();
            ISOEnumeratedMeter meter = meters.FirstOrDefault() as ISOEnumeratedMeter;

            if (meter == null)
            {
                return(0);
            }
            // var value = (EnumeratedValue) spatialRecord.GetMeterValue(meter);
            EnumeratedValue value = spatialRecord.GetMeterValue(meter) as EnumeratedValue;

            if (value == null)
            {
                return(0);
            }

            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiClear.ToModelEnumMember().Code)
            {
                return(0x20524C43);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember().Code)
            {
                return(0x2043534E);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember().Code)
            {
                return(0x20544353);
            }
            if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember().Code)
            {
                return(0x2043564F);
            }
            return(0);
        }
예제 #26
0
        private int GetEnumerated(IntPtr list, uint index, ref uint type, ref uint data)
        {
            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                EnumeratedValue enumerated = (EnumeratedValue)items[(int)index].Value;
                try
                {
                    type = enumerated.Type;
                }
                catch (NullReferenceException)
                {
                }

                data = enumerated.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
        /// <summary>
        /// Convert enumerated value to design parameter
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private static Parameter ToParameter(this EnumeratedValue value)
        {
            if (value == null)
            {
                return(null);
            }
            var parameter = new Parameter {
                Name        = value.Name,
                Description = value.Documentation.ToLocalizedText()
            };

            if (value.ValueSpecified)
            {
                parameter.Identifier          = value.Value;
                parameter.IdentifierSpecified = true;
            }
            if (!string.IsNullOrEmpty(value.BitMask))
            {
                parameter.BitMask             = value.BitMask;
                parameter.IdentifierSpecified = false;
            }
            return(parameter);
        }
예제 #28
0
        private unsafe int GetEnumerated(PIActionList list, uint index, uint *type, uint *data)
        {
            if (data == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionListItemCollection items = actionLists[list];

            if (index < items.Count)
            {
                EnumeratedValue enumerated = (EnumeratedValue)items[(int)index].Value;
                if (type != null)
                {
                    *type = enumerated.Type;
                }

                *data = enumerated.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
예제 #29
0
        private int GetEnumerated(IntPtr descriptor, uint key, ref uint type, ref uint data)
        {
#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}({1})", key, DebugUtils.PropToString(key)));
#endif
            AETEValue item;
            if (actionDescriptors[descriptor].TryGetValue(key, out item))
            {
                EnumeratedValue enumerated = (EnumeratedValue)item.Value;
                try
                {
                    type = enumerated.Type;
                }
                catch (NullReferenceException)
                {
                }

                data = enumerated.Value;

                return(PSError.kSPNoError);
            }

            return(PSError.errMissingParameter);
        }
예제 #30
0
 public SCCEnumeratedValue(EnumeratedValue o, ITree antlr)
     : base(o, antlr)
 {
 }
예제 #31
0
        public DeviceElement ImportDeviceElement(ISODeviceElement isoDeviceElement, EnumeratedValue deviceClassification, DeviceElementHierarchy rootDeviceHierarchy)
        {
            DeviceElement deviceElement = new DeviceElement();

            //ID
            ImportIDs(deviceElement.Id, isoDeviceElement.DeviceElementId);

            //Device ID
            int?deviceModelId = TaskDataMapper.InstanceIDMap.GetADAPTID(isoDeviceElement.Device.DeviceId);

            if (deviceModelId.HasValue)
            {
                deviceElement.DeviceModelId = deviceModelId.Value;
            }

            //Description
            deviceElement.Description = isoDeviceElement.DeviceElementDesignator;

            //Classification
            deviceElement.DeviceClassification = deviceClassification;

            //Parent ID
            if (isoDeviceElement.Parent != null)
            {
                int?parentDeviceId = null;
                if (isoDeviceElement.ParentObjectId == isoDeviceElement.DeviceElementObjectId)
                {
                    //Element has listed itself as its own parent.   Do not include a parent on the adapt element as it will invalidate logic in the hierarchy creation.
                }
                else if (isoDeviceElement.Parent is ISODeviceElement parentElement)
                {
                    parentDeviceId = TaskDataMapper.InstanceIDMap.GetADAPTID(parentElement.DeviceElementId);
                }
                else if (isoDeviceElement.Parent is ISODevice parentDevice)
                {
                    parentDeviceId = TaskDataMapper.InstanceIDMap.GetADAPTID(parentDevice.DeviceId);
                }
                if (parentDeviceId.HasValue)
                {
                    deviceElement.ParentDeviceId = parentDeviceId.Value;
                }
            }

            DeviceElementHierarchy deviceElementHierarchy = TaskDataMapper.DeviceElementHierarchies.GetRelevantHierarchy(isoDeviceElement.DeviceElementId);

            //Device Element Type
            switch (isoDeviceElement.DeviceElementType)
            {
            case ISODeviceElementType.Device:      //This is the root device element
                if (deviceClassification != null &&
                    deviceClassification.Value != null &&
                    TaskDataMapper.DeviceOperationTypes.First(d => d.MachineEnumerationMember.DomainTag == deviceClassification.Value.Code).HasMachineConfiguration)
                {
                    //Device is a machine
                    deviceElement.DeviceElementType = DeviceElementTypeEnum.Machine;
                }
                else if (deviceElementHierarchy.Children != null &&
                         deviceElementHierarchy.Children.Any(d => d?.DeviceElement.DeviceElementType == ISODeviceElementType.Navigation) &&    //The Nav element should be a direct descendant of the root
                         (!deviceElementHierarchy.Children.Any(d => d?.DeviceElement.DeviceElementType == ISODeviceElementType.Section) &&     //If there are section or function elements, classify as an implement vs. a machine
                          !deviceElementHierarchy.Children.Any(d => d?.DeviceElement.DeviceElementType == ISODeviceElementType.Function)))
                {
                    //Device is a machine
                    deviceElement.DeviceElementType = DeviceElementTypeEnum.Machine;
                }
                else
                {
                    //Default: classify as an implement
                    deviceElement.DeviceElementType = DeviceElementTypeEnum.Implement;
                }
                break;

            case ISODeviceElementType.Bin:
                deviceElement.DeviceElementType = DeviceElementTypeEnum.Bin;
                break;

            case ISODeviceElementType.Function:
                deviceElement.DeviceElementType = DeviceElementTypeEnum.Function;
                break;

            case ISODeviceElementType.Section:
                deviceElement.DeviceElementType = DeviceElementTypeEnum.Section;
                break;

            case ISODeviceElementType.Unit:
                deviceElement.DeviceElementType = DeviceElementTypeEnum.Unit;
                break;

            case ISODeviceElementType.Navigation:
                deviceElement.DeviceElementType = DeviceElementTypeEnum.Function;
                break;
            }


            if (HasGeometryInformation(deviceElementHierarchy))
            {
                //Geometry information is on DeviceProperty elements.
                GetDeviceElementConfiguration(deviceElement, deviceElementHierarchy, DataModel.Catalog); //Add via the Get method to invoke business rules for configs
            }

            return(deviceElement);
        }
예제 #32
0
 public override EnumeratedValue CreateEnumeratedValue(EnumeratedValue o, Antlr.Runtime.Tree.ITree antlr)
 {
     return new SCCEnumeratedValue(o, antlr);
 }