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); //} }
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); //} }
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); }
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(); }
public static LiveDataVector GetLiveData(string cls) { LiveDataVector vec = new LiveDataVector(); if (!LiveDataPrepare(cls)) { throw new System.Exception("Can't prepare live data"); } while (true) { StringBuilder shortName = new StringBuilder(100); StringBuilder content = new StringBuilder(100); StringBuilder unit = new StringBuilder(100); StringBuilder defaultValue = new StringBuilder(100); StringBuilder commandName = new StringBuilder(100); StringBuilder commandClass = new StringBuilder(100); StringBuilder description = new StringBuilder(100); int index = 0; if (LiveDataNext(shortName, content, unit, defaultValue, commandName, commandClass, description, out index)) { vec.Add(new LiveData(shortName.ToString(), content.ToString(), unit.ToString(), defaultValue.ToString(), commandName.ToString(), commandClass.ToString(), description.ToString(), index, true)); } else break; } return vec; }
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; //} } }
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); }
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); //} }
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); }
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; //} } }
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); }
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(); }