Ejemplo n.º 1
0
        public static bool Match(this TypeReference tr1, StandardType type)
        {
            if (tr1 == null || type == null)
            {
                return(false);
            }

            return(tr1.FullName == type.ToString());
        }
Ejemplo n.º 2
0
    /// <summary> Creates the lookup table for what types inherit from what. This would be hard-coded if C# would allow. </summary>
    public static void InitInheritanceTree()
    {
        for (StandardType st = StandardType.anything; st < StandardType.Count; st++)
        {
            var it = new InheritedType()
            {
                name = st.ToString(), subtypes = null, typeid = st
            };
            switch (st)
            {
            case StandardType.anything: it.parent = null; break;

            case StandardType.something:
            case StandardType.nothing: it.parent = StandardType.anything.ToString(); break;

            case StandardType.valueType:
            case StandardType.referenceType: it.parent = StandardType.something.ToString(); break;

            case StandardType.number:
            case StandardType.discrete:
            case StandardType.reference:
            case StandardType.structure: it.parent = StandardType.valueType.ToString(); break;

            case StandardType.homogene:
            case StandardType.heterogene:
            case StandardType.value: it.parent = StandardType.referenceType.ToString(); break;

            case StandardType.percent:
            case StandardType.money: it.parent = StandardType.number.ToString(); break;

            case StandardType.position:
            case StandardType.boole: it.parent = StandardType.discrete.ToString(); break;

            case StandardType.time: it.parent = StandardType.structure.ToString(); break;

            case StandardType.text:
            case StandardType.list: it.parent = StandardType.homogene.ToString(); break;

            case StandardType.sequence:
            case StandardType.Object: it.parent = StandardType.heterogene.ToString(); break;

            default: Console.WriteLine("ERROR IN COMPILER: unknown base type {0}", st); break;
            }
            InheritanceTree.Add(it);
        }
        //TestInheritanceTree();
    }
Ejemplo n.º 3
0
        private StandardType SetStandardType(ProtocolType protocol)
        {
            if (_iStandard != StandardType.Automatic)
            {
                return(_iStandard);
            }
            bool         bflag    = false;
            StandardType standard = StandardType.Automatic;

            switch (protocol)
            {
            case ProtocolType.J1850_PWM:
            case ProtocolType.J1850_VPW:
            case ProtocolType.ISO9141_2:
            case ProtocolType.ISO_14230_4_KWP_5BAUDINIT:
            case ProtocolType.ISO_14230_4_KWP_FASTINIT:
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("0100").Replace(" ", "").Contains("4100"))
                    {
                        bflag    = true;
                        standard = StandardType.ISO_15031;
                    }
                }
                break;

            case ProtocolType.ISO_15765_4_CAN_11BIT_500KBAUD:
            case ProtocolType.ISO_15765_4_CAN_11BIT_250KBAUD:
                ConfirmAT("ATCF700");
                ConfirmAT("ATCMF00");
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("22F810").Replace(" ", "").Contains("62F810"))
                    {
                        bflag    = bflag || true;
                        standard = StandardType.ISO_27145;
                    }
                }
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("0100").Replace(" ", "").Contains("4100"))
                    {
                        bflag    = true;
                        standard = StandardType.ISO_15031;
                    }
                }
                if (standard == StandardType.Automatic)
                {
                    ConfirmAT("ATAR");
                }
                break;

            case ProtocolType.ISO_15765_4_CAN_29BIT_500KBAUD:
            case ProtocolType.ISO_15765_4_CAN_29BIT_250KBAUD:
                ConfirmAT("ATCF18DAF100");
                ConfirmAT("ATCM1FFFFF00");
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("22F810").Replace(" ", "").Contains("62F810"))
                    {
                        bflag    = bflag || true;
                        standard = StandardType.ISO_27145;
                    }
                }
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("0100").Replace(" ", "").Contains("4100"))
                    {
                        bflag    = true;
                        standard = StandardType.ISO_15031;
                    }
                }
                if (standard == StandardType.Automatic)
                {
                    ConfirmAT("ATAR");
                }
                break;

            case ProtocolType.SAE_J1939_CAN_29BIT_250KBAUD:
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("00FECE").Replace(" ", "").Contains("60FECE"))
                    {
                        bflag    = bflag || true;
                        standard = StandardType.SAE_J1939;
                    }
                }
                break;

            default:
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("22F810").Replace(" ", "").Contains("62F810"))
                    {
                        bflag    = bflag || true;
                        standard = StandardType.ISO_27145;
                    }
                }
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("0100").Replace(" ", "").Contains("4100"))
                    {
                        bflag    = true;
                        standard = StandardType.ISO_15031;
                    }
                }
                for (int i = 3; i > 0 && !bflag; i--)
                {
                    if (GetOBDResponse("00FECE").Replace(" ", "").Contains("60FECE"))
                    {
                        bflag    = bflag || true;
                        standard = StandardType.SAE_J1939;
                    }
                }
                break;
            }
            _log.TraceInfo("SetStandardType: " + standard.ToString());
            return(standard);
        }
Ejemplo n.º 4
0
 /// <summary>Creates a new type defined by the user, typically of type 'object'.</summary>
 public static InheritedType CreateNewType(string ident, StandardType parentClass = StandardType.heterogene)
 {
     return(CreateNewType(ident, parentClass.ToString()));
 }