Beispiel #1
0
        public List <EcuFunctionStructs.EcuFixedFuncStruct> GetFixedFuncStructList(EcuFunctionStructs.EcuVariant ecuVariant)
        {
            List <EcuFunctionStructs.EcuFixedFuncStruct> fixedFuncStructList = new List <EcuFunctionStructs.EcuFixedFuncStruct>();

            if (ecuVariant.RefEcuVariantList != null)
            {
                foreach (EcuFunctionStructs.RefEcuVariant refEcuVariant in ecuVariant.RefEcuVariantList)
                {
                    if (refEcuVariant.FixedFuncStructList != null)
                    {
                        fixedFuncStructList.AddRange(refEcuVariant.FixedFuncStructList);
                    }
                }
            }

            if (ecuVariant.EcuFuncStructList != null)
            {
                foreach (EcuFunctionStructs.EcuFuncStruct ecuFuncStruct in ecuVariant.EcuFuncStructList)
                {
                    if (ecuFuncStruct.FixedFuncStructList != null)
                    {
                        fixedFuncStructList.AddRange(ecuFuncStruct.FixedFuncStructList);
                    }
                }
            }

            return(fixedFuncStructList);
        }
Beispiel #2
0
        public EcuFunctionStructs.EcuVariant GetEcuVariant(string ecuName)
        {
            try
            {
                if (string.IsNullOrEmpty(ecuName))
                {
                    return(null);
                }

                EcuFunctionStructs.EcuVariant ecuVariant = null;
                ZipFile zf = null;
                try
                {
                    string ecuFileName = ecuName.ToLowerInvariant() + ".xml";
                    using (FileStream fs = File.OpenRead(Path.Combine(_rootDir, EcuFuncFileName)))
                    {
                        zf = new ZipFile(fs);
                        foreach (ZipEntry zipEntry in zf)
                        {
                            if (!zipEntry.IsFile)
                            {
                                continue; // Ignore directories
                            }
                            if (string.Compare(zipEntry.Name, ecuFileName, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                Stream zipStream = zf.GetInputStream(zipEntry);
                                using (TextReader reader = new StreamReader(zipStream))
                                {
                                    XmlSerializer serializer = new XmlSerializer(typeof(EcuFunctionStructs.EcuVariant));
                                    ecuVariant = serializer.Deserialize(reader) as EcuFunctionStructs.EcuVariant;
                                }
                                break;
                            }
                        }
                    }

                    return(ecuVariant);
                }
                finally
                {
                    if (zf != null)
                    {
                        zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                        zf.Close();              // Ensure we release resources
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #3
0
        public EcuFunctionStructs.EcuVariant GetEcuVariant(string ecuName)
        {
            EcuFunctionStructs.EcuVariant ecuVariant = GetEcuDataObject(ecuName, typeof(EcuFunctionStructs.EcuVariant)) as EcuFunctionStructs.EcuVariant;
            if (ecuVariant?.EcuFaultCodeList != null)
            {
                Dictionary <Int64, EcuFunctionStructs.EcuFaultCode> ecuFaultCodeDict = new Dictionary <Int64, EcuFunctionStructs.EcuFaultCode>();
                foreach (EcuFunctionStructs.EcuFaultCode ecuFaultCode in ecuVariant.EcuFaultCodeList)
                {
                    Int64 errorCode = ecuFaultCode.Code.ConvertToInt();
                    if (errorCode != 0)
                    {
                        ecuFaultCodeDict.TryAdd(errorCode, ecuFaultCode);
                    }
                }

                ecuVariant.EcuFaultCodeDict = ecuFaultCodeDict;
            }
            return(ecuVariant);
        }
Beispiel #4
0
        public EcuFunctionStructs.EcuFaultCodeLabel GetFaultCodeLabel(Int64 errorCode, EcuFunctionStructs.EcuVariant ecuVariant)
        {
            if (!ecuVariant.EcuFaultCodeDict.TryGetValue(errorCode, out EcuFunctionStructs.EcuFaultCode ecuFaultCode))
            {
                return(null);
            }

            if (!_ecuFaultCodeLabelDict.TryGetValue(ecuFaultCode.EcuFaultCodeLabelId.ToLowerInvariant(), out EcuFunctionStructs.EcuFaultCodeLabel ecuFaultCodeLabel))
            {
                return(null);
            }

            return(ecuFaultCodeLabel);
        }
Beispiel #5
0
        // for tesing result states only!
        public List <EcuFunctionStructs.EcuEnvCondLabel> GetEnvCondLabelListWithResultStates(EcuFunctionStructs.EcuVariant ecuVariant)
        {
            List <EcuFunctionStructs.EcuEnvCondLabel> ecuEnvCondLabelList = new List <EcuFunctionStructs.EcuEnvCondLabel>();

            foreach (KeyValuePair <Int64, EcuFunctionStructs.EcuFaultCode> ecuFaultCodePair in ecuVariant.EcuFaultCodeDict)
            {
                if (ecuFaultCodePair.Value.EcuEnvCondLabelIdList != null)
                {
                    foreach (string ecuEnvCondId in ecuFaultCodePair.Value.EcuEnvCondLabelIdList)
                    {
                        if (_ecuEnvCondLabelDict.TryGetValue(ecuEnvCondId.ToLowerInvariant(), out EcuFunctionStructs.EcuEnvCondLabel ecuEnvCondLabel))
                        {
                            if (ecuEnvCondLabel.EcuResultStateValueList != null && ecuEnvCondLabel.EcuResultStateValueList.Count > 0)
                            {
                                ecuEnvCondLabelList.Add(ecuEnvCondLabel);
                            }
                        }
                    }
                }
            }

            return(ecuEnvCondLabelList);
        }
Beispiel #6
0
        public List <EcuFunctionStructs.EcuEnvCondLabel> GetEnvCondLabelList(Int64 errorCode, EcuFunctionStructs.EcuVariant ecuVariant)
        {
            if (!ecuVariant.EcuFaultCodeDict.TryGetValue(errorCode, out EcuFunctionStructs.EcuFaultCode ecuFaultCode))
            {
                return(null);
            }

            if (ecuFaultCode.EcuEnvCondLabelIdList == null)
            {
                return(null);
            }

            List <EcuFunctionStructs.EcuEnvCondLabel> ecuEnvCondLabelList = new List <EcuFunctionStructs.EcuEnvCondLabel>();

            foreach (string ecuEnvCondId in ecuFaultCode.EcuEnvCondLabelIdList)
            {
                if (_ecuEnvCondLabelDict.TryGetValue(ecuEnvCondId.ToLowerInvariant(), out EcuFunctionStructs.EcuEnvCondLabel ecuEnvCondLabel))
                {
                    ecuEnvCondLabelList.Add(ecuEnvCondLabel);
                }
            }

            return(ecuEnvCondLabelList);
        }