public void LOAD_examples(string fname, char del) { C_Motor.cmdPackets = new List <C_Packet>(); C_Motor.cmdEx_str = new List <string>(); string strHex_concantenated; string name; string[] strArr; string[] lines; if (!System.IO.File.Exists(fname)) { LOG_err(string.Format("{0}\n{1}", "File with command examples not found!Searched in:", fname.ToString() )); } else { LOG("File with command examples found, starting to load cmdInners"); lines = System.IO.File.ReadAllLines(fname, Encoding.ASCII); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } strArr = line.Split(del); strHex_concantenated = strArr[0]; name = strArr[1]; cmdEx_str.Add(string.Format("{0} - {1}", name, strHex_concantenated)); // this can be added as a new constructor of C_Packet(mot, insAndPar) List <byte> insAndParams = new List <byte>(); //byte[] insAndParams = insAndParams.AddRange(C_CONV.strHex2byteArray(strHex_concantenated)); C_Motor.cmdPackets.Add( new C_Packet( this, insAndParams[0], insAndParams.GetRange(1, insAndParams.Count - 1) )); } LOG("Command examples loaded succesfully!"); cmdinEx_initialized = true; } }
private void txRawBytes_TextChanged(object sender, TextChangedEventArgs e) { if (C_State.FURTHER(e_stateProg.initialized)) { try { raw = new C_Packet(C_CONV.strHex2byteArray(txRawBytes.Text, " ")); } finally { btnSendRawBytes.IsEnabled = raw.IsConsistent; } } }