Esempio n. 1
0
        SignalPars SignalParsDef(int _iboard, bool _input, int _pos, int _DigitalOffset)
        {
            SignalPars par = new SignalPars();

            par.Digital  = _pos >= _DigitalOffset;
            par.Position = par.Digital ? _pos - _DigitalOffset : _pos;
            //par.Name = string.Format("{0}{2}:{0}",
            //    _iboard.ToString(),
            //    par.Digital ? "Д" : "",
            //    par.Position.ToString()
            //    );
            par.Input = _input;
            return(par);
        }
Esempio n. 2
0
 void SavePanels(L_SignalPars _L)
 {
     if (_L == null)
     {
         return;
     }
     foreach (Signal s in this)
     {
         SignalPars p = _L[s.name];
         if (p == null)
         {
             continue;
         }
         p.X = s.X;
         p.Y = s.Y;
     }
 }
Esempio n. 3
0
        SignalPars GetPars(L_SignalPars _L0, L_SignalPars _L1, string _dn_Name, ref int _board)
        {
            SignalPars p = null;

            _board = -1;
            if (_L0 != null)
            {
                p = _L0[_dn_Name];
            }
            if (p != null)
            {
                _board = 0;
                return(p);
            }
            if (_L1 != null)
            {
                p = _L1[_dn_Name];
            }
            if (p != null)
            {
                _board = 1;
                return(p);
            }
            if (_L0 != null)
            {
                p      = _L0.AddNew() as SignalPars;
                p.Name = _dn_Name;
            }
            if (p != null)
            {
                _board = 0;
                return(p);
            }
            if (_L1 != null)
            {
                p      = _L1.AddNew() as SignalPars;
                p.Name = _dn_Name;
            }
            if (p != null)
            {
                _board = 0;
                return(p);
            }
            return(null);
        }
Esempio n. 4
0
 protected override void SetSignals(PCIE1730pars _pars0, PCIE1730pars _pars1)
 {
     for (int b = 0; b < boards.Length; b++)
     {
         if (boards[b] == null)
         {
             continue;
         }
         for (int pos = 0; pos < boards[b].portCount_in * 8; pos++)
         {
             SignalPars par = null;
             par = GetPars(_pars0.Signals, pos, boards[b].DigitalOffset, true);
             if (par == null)
             {
                 par = SignalParsDef(b, true, pos, boards[b].DigitalOffset);
             }
             Signal s = new Signal(b, par, boards[b].DigitalOffset, SyncObj, WriteSignal);
             if (!PCSide)
             {
                 s.input = !s.input;
             }
             Add(s);
         }
         for (int pos = 0; pos < boards[b].portCount_out * 8; pos++)
         {
             SignalPars par = null;
             par = GetPars(_pars0.Signals, pos, boards[b].DigitalOffset, false);
             if (par == null)
             {
                 par = SignalParsDef(b, false, pos, boards[b].DigitalOffset);
             }
             Signal s = new Signal(b, par, boards[b].DigitalOffset, SyncObj, WriteSignal);
             if (!PCSide)
             {
                 s.input = !s.input;
             }
             Add(s);
         }
     }
 }
Esempio n. 5
0
 public Signal(int _board, SignalPars _p, int _digital_offset, object _SyncObj, DWriteSignal _WriteSignal)
 {
     board          = _board;
     digital_offset = _digital_offset;
     name           = _p.Name;
     digital        = _p.Digital;
     position       = _p.Position;
     hint           = _p.Hint;
     eOn            = _p.EOn;
     eOff           = _p.EOff;
     timeout        = new TimeSpan(0, 0, 0, 0, _p.Timeout);
     no_reset       = _p.NoReset;
     verbal         = _p.Verbal;
     val            = false;
     prev_val       = val;
     last_changed   = Environment.TickCount;
     X           = _p.X;
     Y           = _p.Y;
     SyncObj     = _SyncObj;
     WriteSignal = _WriteSignal;
     input       = _p.Input;
 }
Esempio n. 6
0
        protected override void SetSignals(PCIE1730pars _pars0, PCIE1730pars _pars1)
        {
            Type tp = GetType();

            foreach (FieldInfo fi in tp.GetFields(BindingFlags.Public | BindingFlags.Instance))
            {
                if (fi.FieldType != typeof(Signal))
                {
                    return;
                }
                DNameAttribute dn = Attribute.GetCustomAttribute(fi, typeof(DNameAttribute)) as DNameAttribute;
                if (dn == null)
                {
                    throw new Exception("Сигнал не имеет описания: " + fi.Name);
                }
                SignalInputAttribute si = Attribute.GetCustomAttribute(fi, typeof(SignalInputAttribute)) as SignalInputAttribute;
                if (si == null)
                {
                    throw new Exception("Сигнал не имеет направления: " + fi.Name);
                }
                int        iboard = -1;
                SignalPars p      = GetPars(_pars0 == null ? null : _pars0.Signals, _pars1 == null ? null : _pars1.Signals, dn.Name, ref iboard);
                if (p == null)
                {
                    throw new Exception("Сигнал не найден и его негде создать: " + fi.Name + ": " + dn.Name);
                }
                p.Input = si.Input;
                Signal s = new Signal(iboard, p, boards[iboard].DigitalOffset, SyncObj, WriteSignal);
                if (!PCSide)
                {
                    s.input = !s.input;
                }
                Add(s);
                s.hint = fi.Name;
                fi.SetValue(this, s);
            }
            ClearSignalPars(_pars0 == null ? null : _pars0.Signals, _pars1 == null ? null : _pars1.Signals);
        }