Example #1
0
 public ComPort(ComPortPars _par, DOnPr _OnPr = null)
     : base(_par, _OnPr)
 {
     hPort = Win32Com.CreateFile(_par.Port, Win32Com.GENERIC_READ | Win32Com.GENERIC_WRITE, 0, IntPtr.Zero, Win32Com.OPEN_EXISTING, 0, IntPtr.Zero);
     if (hPort == (IntPtr)Win32Com.INVALID_HANDLE_VALUE)
     {
         prfatal("Не могу прочитать параметры");
     }
     Win32Com.DCB PortDCB = new Win32Com.DCB();
     if (!Win32Com.GetCommState(hPort, ref PortDCB))
     {
         prfatal("Не могу прочитать параметры");
     }
     PortDCB.BaudRate = _par.BaudRate;
     PortDCB.ByteSize = (byte)_par.ByteSize;
     PortDCB.Parity   = (byte)_par.Parity;
     PortDCB.StopBits = (byte)_par.StopBits;
     Win32Com.COMMTIMEOUTS CommTimeouts = new Win32Com.COMMTIMEOUTS();
     if (!Win32Com.SetCommState(hPort, ref PortDCB))
     {
         prfatal("Не могу установить параметры");
     }
     CommTimeouts.ReadIntervalTimeout        = (uint)_par.ReadIntervalTimeout;
     CommTimeouts.ReadTotalTimeoutConstant   = (uint)_par.ReadTotalTimeoutConstant;
     CommTimeouts.ReadTotalTimeoutMultiplier = (uint)_par.ReadTotalTimeoutMultiplier;
     if (!Win32Com.SetCommTimeouts(hPort, ref CommTimeouts))
     {
         prfatal("Не могу выставить задержки");
     }
 }
Example #2
0
 public ComPortBase(ComPortPars _par, DOnPr _OnPr = null)
 {
     OnPr          = _OnPr;
     ProtocolLevel = 0;
     opened        = true;
     pr("Открыт");
 }
Example #3
0
 public void Init(ComPortPars _ComPort, ConverterPars _pars, int _frequency)
 {
     label2.Text     = "Абонент " + _pars.Abonent.ToString();
     textBox1.Text   = _frequency.ToString();
     label3.Text     = null;
     inverter        = new JInverterTh(_ComPort, _pars, _frequency);
     timer1.Interval = inverter.RTimeout;
 }
Example #4
0
        public static ComPortBase Create(ComPortPars _par, DOnPr _OnPr = null)
        {
#if COMPORT_virtual
            return(new ComPortBase(_par, _OnPr));
#else
            return(new ComPort(_par, _OnPr));
#endif
        }
Example #5
0
        public JInverterTh(ComPortPars _comPortPars, ConverterPars _converterPars, int _Frequency)
        {
//            mitcom = new MitCOM(_comPortPars, pr);
            mitcom            = new MitCOM(_comPortPars, null);
            abonent           = _converterPars.Abonent;
            timeout           = _comPortPars.Timeout;
            frequencyPosition = _converterPars.SpeedPar;
            frequency         = _Frequency;
            IsABC             = _converterPars.IsABC;
            Iters             = _converterPars.Iters;
            RTimeout          = 500;
            ts = new ThreadStart(Run);
            th = null;
        }
Example #6
0
 public void Init(ComPortPars _ComPortPars)
 {
     ComPortPars = _ComPortPars;
 }
Example #7
0
 public MitCOM(ComPortPars _parCOM, ComPort.DOnPr _OnPr, object _SyncObj)
 {
     comPort = ComPort.Create(_parCOM, _OnPr);
     SyncObj = _SyncObj;
 }
Example #8
0
 public MitCOM(ComPortPars _parCOM, ComPort.DOnPr _OnPr) : this(_parCOM, _OnPr, new object())
 {
 }
Example #9
0
 public JScanRotationTh(ComPortPars _ComPortPars)
 {
     comPort     = ComPort.Create(_ComPortPars, pr);
     l_lastError = null;
     lastError   = null;
 }