Exemple #1
0
        public void ReadDataStream(Core.LiveDataVector vec)
        {
            stopReadDataStream = false;

            var items = vec.Items;

            while (!stopReadDataStream)
            {
                foreach (var item in items)
                {
                    byte[] cmd  = Database.GetCommand(item.CommandName, item.CommandClass);
                    byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                    if (recv == null)
                    {
                        throw new IOException(Database.GetText("Communication Fail", "System"));
                    }
                    item.Value = DataStreamCalc[item.ShortName](recv);
                    System.Threading.Thread.Sleep(50);
                    if (stopReadDataStream)
                    {
                        break;
                    }
                }
                //int i = vec.NextShowedIndex();
                //byte[] cmd = Db.GetCommand(vec[i].CmdID);
                //byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                //if (recv == null)
                //{
                //    throw new IOException(JM.Core.SysDB.GetText("Communication Fail"));
                //}
                //// calc
                //vec[i].Value = DataStreamCalc[vec[i].ShortName](recv);
                //System.Threading.Thread.Sleep(50);
            }
        }
Exemple #2
0
        public void ReadFreezeFrame(Core.LiveDataVector vec)
        {
            var items = vec.Items;

            foreach (var item in items)
            {
                byte[] cmd = Database.GetCommand(item.CommandName, item.CommandClass);

                byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                if (recv == null)
                {
                    throw new IOException(Database.GetText("Communication Fail", "System"));
                }
                item.Value = DataStreamCalc[item.ShortName](recv);
                System.Threading.Thread.Sleep(50);
            }

            //for (int i = 0; i < vec.ShowedCount; i++)
            //{
            //    int index = vec.ShowedIndex(i);
            //    byte[] cmd = Db.GetCommand(vec[index].CmdID);
            //    byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
            //    if (recv == null)
            //    {
            //        throw new IOException(JM.Core.SysDB.GetText("Communication Fail"));
            //    }
            //    // Cal
            //    vec[index].Value = DataStreamCalc[vec[index].ShortName](recv);
            //}
        }
Exemple #3
0
        public void StaticDataStream(Core.LiveDataVector vec)
        {
            ldVec = vec;
            var items = vec.Items;

            foreach (var item in items)
            {
                byte[] cmd  = Database.GetCommand(item.CommandName, item.CommandClass);
                byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                if (recv == null)
                {
                    throw new IOException(Database.GetText("Communication Fail", "System"));
                }
                item.Value = DataStreamCalc[item.ShortName](recv);
            }
            //vec.DeployShowedIndex();

            //for (int i = 0; i < vec.ShowedCount; i++)
            //{
            //    int index = vec.ShowedIndex(i);
            //    byte[] cmd = Database.GetCommand(vec[index].CommandName, vec[index].CommandClass);
            //    byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
            //    if (recv == null)
            //    {
            //        throw new IOException(Database.GetText("Communication Fail", "System"));
            //    }
            //    // calc
            //    vec[index].Value = DataStreamCalc[vec[index].ShortName](recv);
            //}
        }
Exemple #4
0
        public void StaticDataStream(Core.LiveDataVector vec)
        {
            ldVec = vec;
            byte[] cmd  = Database.GetCommand("Read Data By Local Identifier1", "Synerject");
            byte[] recv = Protocol.SendAndRecv(startDiagnosticSession, 0, startDiagnosticSession.Length, Pack);

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

            recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
            if (recv == null || recv[0] != 0x61)
            {
                throw new IOException(Database.GetText("Communication Fail", "System"));
            }

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

            var items = vec.Items;

            foreach (var item in items)
            {
                item.Value = DataStreamCalc[item.ShortName](recv);
            }
            //for (int i = 0; i < vec.ShowedCount; i++)
            //{
            //    int index = vec.ShowedIndex(i);
            //    vec[index].Value = DataStreamCalc[vec[index].ShortName](recv);
            //}
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public void ReadDataStream(LiveDataVector vec)
        {
            var items = vec.Items;

            byte[] cmd = Database.GetCommand("Read Data Stream", "GW250");
            stopReadDataStream = false;

            byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);

            if (recv == null)
            {
                throw new IOException(Database.GetText("Communication Fail", "System"));
            }

            Task task = Task.Factory.StartNew(() =>
            {
                while (!stopReadDataStream)
                {
                    Thread.Sleep(50);
                    Thread.Yield();
                    byte[] temp = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                    if (temp != null)
                    {
                        Array.Copy(temp, recv, recv.Length >= temp.Length ? recv.Length : temp.Length);
                    }
                }
            });

            while (!stopReadDataStream)
            {
                foreach (var item in items)
                {
                    item.Value = DataStreamCalc[item.ShortName](recv);
                    Thread.Sleep(10);
                    Thread.Yield();
                    if (stopReadDataStream)
                    {
                        break;
                    }
                }
            }

            task.Wait();
        }
Exemple #7
0
        public void ReadDataStream(Core.LiveDataVector vec)
        {
            ldVec = vec;
            stopReadDataStream = false;

            var items = vec.Items;

            //int i = 0;

            while (!stopReadDataStream)
            {
                foreach (var item in items)
                {
                    byte[] cmd  = Database.GetCommand(item.CommandName, item.CommandClass);
                    byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                    if (recv == null)
                    {
                        throw new IOException(Database.GetText("Communication Fail", "System"));
                    }
                    // calc
                    item.Value = DataStreamCalc[item.ShortName](recv);
                    if (stopReadDataStream)
                    {
                        break;
                    }
                }
                //byte[] cmd = Database.GetCommand(items[i].CmdID);
                //byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                //if (recv == null)
                //{
                //    throw new IOException(JM.Core.SysDatabase.GetText("Communication Fail"));
                //}
                //// calc
                //items[i].Value = DataStreamCalc[vec[i].ShortName](recv);
                //i++;
                //if (i == items.Count)
                //{
                //    i = 0;
                //}
            }
        }
Exemple #8
0
        public void ReadDataStream(Core.LiveDataVector vec)
        {
            byte[] calcBuff = new byte[128];
            ldVec = vec;
            var items = vec.Items;

            byte[] cmd = Database.GetCommand("Read Data By Local Identifier1", "Synerject");
            stopReadDataStream = false;

            byte[] recv = Protocol.SendAndRecv(startDiagnosticSession, 0, startDiagnosticSession.Length, Pack);
            if (recv == null || recv[0] != 0x50)
            {
                throw new IOException(Database.GetText("Communication Fail", "System"));
            }

            recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
            if (recv == null)
            {
                Protocol.SendAndRecv(stopDiagnosticSession, 0, stopDiagnosticSession.Length, Pack);
                Protocol.SendAndRecv(stopCommunication, 0, stopCommunication.Length, Pack);
                throw new IOException(Database.GetText("Communication Fail", "System"));
            }
            Array.Copy(recv, calcBuff, recv.Length);
            Task task = Task.Factory.StartNew(() =>
            {
                while (!stopReadDataStream)
                {
                    Thread.Sleep(50);
                    Thread.Yield();
                    byte[] temp = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                    if (temp != null)
                    {
                        Array.Copy(temp, calcBuff, temp.Length);
                    }
                }
            });

            while (!stopReadDataStream)
            {
                foreach (var item in items)
                {
                    item.Value = DataStreamCalc[item.ShortName](calcBuff);
                    Thread.Sleep(10);
                    Thread.Yield();
                    if (stopReadDataStream)
                    {
                        break;
                    }
                }
                //int i = vec.NextShowedIndex();
                //vec[i].Value = DataStreamCalc[vec[i].ShortName](recv);
                //Thread.Sleep(10);
                //Thread.Yield();
                //byte[] recv = Protocol.SendAndRecv(cmd, 0, cmd.Length, Pack);
                //if (recv == null)
                //    throw new IOException(Database.GetText("Communication Fail"));
                //for (int i = 0; i < vec.ShowedCount; i++)
                //{
                //    int j = vec.NextShowedIndex();
                //    vec[j].Value = DataStreamCalc[vec[j].ShortName](recv);
                //}
                //int i = vec.NextShowedIndex();
                //if (recv == null)
                //{
                //    continue;
                //}
                //// calc
                //vec[i].Value = DataStreamCalc[vec[i].ShortName](recv);
            }
            task.Wait();
            Protocol.SendAndRecv(stopDiagnosticSession, 0, stopDiagnosticSession.Length, Pack);
            Protocol.SendAndRecv(stopCommunication, 0, stopCommunication.Length, Pack);
        }