コード例 #1
0
ファイル: Synerject.cs プロジェクト: grtwall/JM.Core
        public void Active(Core.LiveDataVector vec, string mode)
        {
            ldVec = vec;
            byte[] cmd  = Database.GetCommand("Read Data By Local Identifier1", "Synerject");
            byte[] buff = Protocol.SendAndRecv(startDiagnosticSession, 0, startDiagnosticSession.Length, Pack);

            if (buff == null || buff[0] != 0x50)
            {
                throw new IOException(Database.GetText("Active Test Fail", "System"));
            }

            ActiveOn = ActiveState.Idle;
            buff     = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
            if (buff == null)
            {
                Protocol.SendAndRecv(stopDiagnosticSession, 0, stopDiagnosticSession.Length, Pack);
                Protocol.SendAndRecv(stopCommunication, 0, stopCommunication.Length, Pack);
                throw new IOException(Database.GetText("Communication Fail", "System"));
            }

            var items = vec.Items;

            while (ActiveOn != ActiveState.Stop)
            {
                if (ActiveOn == ActiveState.Idle)
                {
                    buff = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                    foreach (var item in items)
                    {
                        item.Value = DataStreamCalc[item.ShortName](buff);
                    }
                    Thread.Sleep(10);
                }
                else if (ActiveOn == ActiveState.Positive)
                {
                    ActiveTests[mode](true);
                    ActiveOn = ActiveState.Idle;
                    Thread.Sleep(10);
                }
                else if (ActiveOn == ActiveState.Negative)
                {
                    ActiveTests[mode](false);
                    ActiveOn = ActiveState.Idle;
                    Thread.Sleep(10);
                }
            }

            Protocol.SendAndRecv(stopDiagnosticSession, 0, stopDiagnosticSession.Length, Pack);
            Protocol.SendAndRecv(stopCommunication, 0, stopCommunication.Length, Pack);
        }
コード例 #2
0
ファイル: Synerject.cs プロジェクト: grtwall/JM.Core
        public string Active(string mode, bool on)
        {
            byte[] buff = Protocol.SendAndRecv(startDiagnosticSession, 0, startDiagnosticSession.Length, Pack);

            if (buff == null || buff[0] != 0x50)
            {
                throw new IOException(Database.GetText("Active Test Fail", "System"));
            }

            string ret = ActiveTests[mode](on);

            Protocol.SendAndRecv(stopDiagnosticSession, 0, stopDiagnosticSession.Length, Pack);
            Protocol.SendAndRecv(stopCommunication, 0, stopCommunication.Length, Pack);
            return(ret);
        }