示例#1
0
        protected override void OnReplyReceived(SerialEventArgs info)
        {
            base.OnReplyReceived(info);

            if (info.Info.StartsWith(";CNCJoystick"))
            {
                string initCommands = _global.Joystick?.InitCommands;
                if (initCommands != null)
                {
                    RunCommandInNewTask(
                        async() =>
                    {
                        string[] separators = { @"\n" };
                        string[] cmds       = initCommands.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                        await QueueCommandsAsync(cmds);
                    });
                }
            }
            else
            {
                RunCommandInNewTask(
                    async() =>
                {
                    string msg = _global.Machine.JoystickReplyReceived(info.Info.Trim());
                    await _global.Com.Current.QueueCommandsAsync(new string[] { msg }).ConfigureAwait(false);
                });
            }
        }
示例#2
0
 private static void DontWatchHandler(object sender, SerialEventArgs e)
 {
     if (e.status)
     {
         db.RemoveWatched(activeUser.Id, e.id);
         db.RemoveWatching(activeUser.Id, e.id);
     }
 }
示例#3
0
 private static void WatchingHandler(object sender, SerialEventArgs e)
 {
     if (e.status)
     {
         db.SetWatching(activeUser.Id, e.id);
     }
     else
     {
         db.RemoveWatching(activeUser.Id, e.id);
     }
 }
        protected override void OnReplyReceived(SerialEventArgs info)
        {
            base.OnReplyReceived(info);

            if (info.Info.StartsWith(";CNCJoystick"))
            {
                if (Global.Instance.Joystick?.InitCommands != null)
                {
                    RunCommandInNewTask(async() => { await new JoystickHelper().SendInitCommands(Global.Instance.Joystick?.InitCommands); });
                }
            }
            else
            {
                RunCommandInNewTask(() => { new JoystickHelper().JoystickReplyReceived(info.Info.Trim()); });
            }
        }
示例#5
0
        private void Serial_DataToRead(object source, SerialEventArgs e)
        {
            try
            {
                if (serialInterface.BytesToRead <= 0)
                {
                    return;
                }

                var data = serialInterface.Read(serialInterface.BytesToRead);

                switch (API_Mode)
                {
                case APIMode.WriteRam:
                    API_HandleWriteRam(data);
                    break;

                case APIMode.ReadRam:
                case APIMode.ReadRom:
                    if (!API_HandleReadRomRam(data))
                    {
                        API_ResetVariables();
                    }
                    break;

                case APIMode.Open:
                default:
                    _throwInfo(this, Encoding.ASCII.GetString(data, 0, data.Length));
                    break;
                }
                return;
            }
            catch (Exception ex)
            {
                _throwException(ex);
                API_ResetVariables();
                try
                {
                    serialInterface.Write(new byte[] { GB_API_Protocol.API_ABORT_CMD }, 0, 1);
                }
                catch (Exception exc)
                {
                    _throwException(exc);
                }
                return;
            }
        }
示例#6
0
        protected void serialPort_OnReceiveEvent(object source, SerialEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                case SerialEvents.ReceivedChars:
                    byte[] b = new byte[serialPort.InBufferBytes];
                    serialPort.Read(b, 0, b.Length);
                    receiveBuffer.AddRange(b);
                    findSnapPacket();
                    break;

                default:
                    Debug.WriteLine("Unknown event: " + e.EventType);
                    break;
                }
            }
            catch {}
        }
示例#7
0
 private void OnSerialDataTransfered(object sender, SerialEventArgs e)
 {
     _serialData.Add(e.SerialData);
 }
示例#8
0
 internal void OnSerialReplyReceived(SerialEventArgs eventArgs)
 {
     SerialReplyReceived?.Invoke(session, eventArgs);
 }
 void mainPage_lbSerialsHandler(object sender, SerialEventArgs e)
 {
     Id = e.idSerial;
     infoPage.AddNew = false;
     MainFrame.Navigate(infoPage);
 }