private void AddVariavle(int id, Enums.LinkType type, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            switch (type)
            {
            case Enums.LinkType.Linear:
                _variables.Add(name, AxVariable.Create(id, name));
                break;

            case Enums.LinkType.TwoPos:
            case Enums.LinkType.WriteTwoPos:
            case Enums.LinkType.PulseTwoPos:

                var baseName = BitSetVariable.GetBaseName(name, out int idx);

                if (_variables.TryGetValue(baseName, out Variable var))
                {
                    (var as BitSetVariable).AddBit(id, idx);
                }
                else
                {
                    _variables.Add(baseName, BitSetVariable.Create(id, baseName, idx));
                }
                break;

            default:
                throw new ArgumentException("Invalid link type!");
            }
        }
Ejemplo n.º 2
0
        public static BitSetVariable Create(int linkId, string name, int bitIndex)
        {
            var v    = new BitSetVariable();
            var iErr = v.Initialize(name);

            v.AddBit(linkId, bitIndex);

            return(v);
        }