Exemplo n.º 1
0
        static void Main(string[] args)
        {
            /* Для проверки  декодера из файла или буфера */
            ProtocolUSB5E4D dec = new ProtocolUSB5E4D();
            dec.GotProtocolMsg += new ProtocolUSBBase.ProtocolMsgEventHandler(onDecMsg);
            dec.GotProtocolError += new ProtocolUSBBase.ProtocolErrorEventHandler(onErrMsg);
            //*/
            FileStream fStream = new FileStream(@"D:\Projects\USBLOG\Debug\Win32\logs\201310\21_161433.dat", FileMode.Open);
            ProtocolThread dT = new ProtocolThread(dec, fStream);
            /* проверка работы модуля приема и декодирования данных */
               // FileStream fStream = new FileStream(@"D:\Projects\USBLOG\Release\Win32\logs\201310\usb_log.dat", FileMode.Create);
              //  TextWriter fTxtWriter = new StreamWriter(@"D:\Projects\USBLOG\Release\Win32\logs\201310\usb_log.txt");
              //  ProtocolUSB5E4D _dec = new ProtocolUSB5E4D(fStream, fTxtWriter, false, false);
              //  _dec.onMessage = onDecMsg;
               // _dec.onProtocolError = onErrMsg;
              //  _dev = new Device("FTVAFGPQ", _dec, new EGSE.USB.USBCfg(10));

            ///* выдаем команду в устройство */
            byte[] tmp = { 1 };
            byte[] tmpbuf;
            dec.Encode(0x03, tmp, out tmpbuf);
            /* ждем пока не нажмем кнопку в консоли, тогда все завершаем */
            System.Console.ReadLine();
            /* текстовый лог загрываем */
              //  _dev.finishAll();
              //  fTxtWriter.Flush();
              //  fTxtWriter.Close();
              //  fStream.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Конструктор по-умолчанию
        /// </summary>
        public XSAN()
        {
            Connected = false;
            ControlValuesList.Add(new ControlValue()); // XSAN_CTRL_IDX
            ControlValuesList.Add(new ControlValue()); // BUNI_CTRL_IDX
            ControlValuesList.Add(new ControlValue()); // POWER_CTRL_IDX

            _decoder = new ProtocolUSB5E4D(null, LogsClass.Instance.Files[LogsClass.UsbIdx], false, true);
            _decoder.GotProtocolMsg += new ProtocolUSBBase.ProtocolMsgEventHandler(onMessageFunc);
            _decoder.GotProtocolError += new ProtocolUSBBase.ProtocolErrorEventHandler(onErrorFunc);

            ETime = new EgseTime();

            Device = new XsanDevice(XsanConst.XSANSerial, _decoder);
            Device.ChangeStateEvent = onChangeConnection;

            //
            _xsanDataLogStream = null;
            _xsanChannelForWriting = 0;
            _writeXsanDataToFile = false;

            HSIInt = new HSIInterface();
            Tm = new XsanTm();
            //
            ControlValuesList[XsanConst.XSAN_CTRL_IDX].AddProperty(XsanConst.PROPERTY_XSAN_READY_IDX, 4, 1, Device.CmdHSIXSANControl, delegate(UInt32 value)
            {
                XsanImitatorReady = (value == 1);
            });
            ControlValuesList[XsanConst.XSAN_CTRL_IDX].AddProperty(XsanConst.PROPERTY_XSAN_BUSY_IDX, 5, 1, Device.CmdHSIXSANControl, delegate(UInt32 value)
            {
                XsanImitatorBusyOn = (value == 1);
            });
            ControlValuesList[XsanConst.XSAN_CTRL_IDX].AddProperty(XsanConst.PROPERTY_XSAN_ME_IDX, 6, 1, Device.CmdHSIXSANControl, delegate(UInt32 value)
            {
                XsanImitatorMeOn = (value == 1);
            });
            ControlValuesList[XsanConst.XSAN_CTRL_IDX].AddProperty(XsanConst.PROPERTY_XSAN_CMD_CH_IDX, 0, 2, Device.CmdHSIXSANControl, delegate(UInt32 value)
            {
                XsanImitatorCmdChannel = (int)value;

            });
            ControlValuesList[XsanConst.XSAN_CTRL_IDX].AddProperty(XsanConst.PROPERTY_XSAN_DAT_CH_IDX, 2, 2, Device.CmdHSIXSANControl, delegate(UInt32 value)
            {
                XsanImitatorDatChannel = (int)value;

            });
            //
            ControlValuesList[XsanConst.BUNI_CTRL_IDX].AddProperty(XsanConst.PROPERTY_BUNI_ON_IDX, 0, 1, Device.CmdHSIBUNIControl, delegate(UInt32 value)
            {
                BuniImitatorOn = (value == 1);
            });
            ControlValuesList[XsanConst.BUNI_CTRL_IDX].AddProperty(XsanConst.PROPERTY_BUNI_CMD_CH_IDX, 1, 1, Device.CmdHSIBUNIControl, delegate(UInt32 value)
            {
                BuniImitatorCmdChannel = (int)value;
            });
            ControlValuesList[XsanConst.BUNI_CTRL_IDX].AddProperty(XsanConst.PROPERTY_BUNI_DAT_CH_IDX, 2, 2, Device.CmdHSIBUNIControl, delegate(UInt32 value)
            {
                BuniImitatorDatChannel = (int)value;
            });
            ControlValuesList[XsanConst.BUNI_CTRL_IDX].AddProperty(XsanConst.PROPERTY_BUNI_HZ_IDX, 4, 1, Device.CmdHSIBUNIControl, delegate(UInt32 value)
            {
                BuniImitatorTimeStampOn = (value == 1);
            });
            ControlValuesList[XsanConst.BUNI_CTRL_IDX].AddProperty(XsanConst.PROPERTY_BUNI_KBV_IDX, 5, 1, Device.CmdHSIBUNIControl, delegate(UInt32 value)
            {
                BuniImitatorObtOn = (value == 1);
            });
            //
            ControlValuesList[XsanConst.POWER_CTRL_IDX].AddProperty(XsanConst.PROPERTY_POWER_IDX, 0, 1, Device.CmdPowerOnOff, delegate(UInt32 value) { });
        }