public void Run() { if (ConnectToInstrument() == true) { ScpiCommand scpiCmd = new ScpiCommand(); bool status = true; while (true == status && parser.GetNextLine(ref scpiCmd) == true) { switch (scpiCmd.Type) { case ScpiCommandType.SET: output.ShowCommand(scpiCmd); status = SendToInstrument(scpiCmd.Cmd); break; case ScpiCommandType.QUERY: output.ShowCommand(scpiCmd); status = SendToInstrument(scpiCmd.Cmd); string replyStr = ""; if (true == status) { status = ReadFromInstrument(ref replyStr); } output.ShowResult(replyStr); break; case ScpiCommandType.WAIT: output.ShowWait(scpiCmd); //System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); break; } } DisconnectFromInstrument(); } }
public void ShowCommand(ScpiCommand scpiCmd) { if (this.InvokeRequired) { this.BeginInvoke(new ShowCommandDelegate(this.ShowCommand), new object[] { scpiCmd }); } else { ListViewItem curItem = this.Items[m_ParserPointer - 1]; curItem.BackColor = COLOR_COMPLETED; } }
private void AddLine(ScpiCommand scpiCmd) { ListViewItem item = new ListViewItem(); item.SubItems.Add(scpiCmd.Str); //HDR_COMMAND item.SubItems.Add(""); //HDR_RESULT if (ScpiCommandType.INVALID == scpiCmd.Type) { item.BackColor = COLOR_INVALID; item.UseItemStyleForSubItems = true; } this.Items.Add(item); }
public void LoadFromEditor(ScpiEditor scpiEditor) { //clear the list view this.Items.Clear(); //Create parser TextParser txtParser = new TextParser(scpiEditor, ParseStd.SFXSCPI);//SRIX:change pasrsetd:sfxscpi to variable //Load the file in the listview ScpiCommand scpiCmd = new ScpiCommand(); while (txtParser.GetNextLine(ref scpiCmd)) { AddLine(scpiCmd); } }
public void LoadFromFile(TabData tabData) { //clear the list view this.Items.Clear(); //Create parser TextParser txtParser = new TextParser(tabData.fileName, tabData.parseStd); //Load the file in the listview ScpiCommand scpiCmd = new ScpiCommand(); while (txtParser.GetNextLine(ref scpiCmd)) { AddLine(scpiCmd); } }
public void ShowWait(ScpiCommand scpiCmd) { string cmd = scpiCmd.Str; cmd = cmd.Remove(0, 2); cmd.Trim(); int wait = Convert.ToInt32(cmd); Console.Write(scpiCmd.Str + " "); for (int i = 0; i < wait; i++) { //when the output of scpugui is directed to text file //Invalid handle error appears when drawtextprogressbar is first called //And scpigui stops there. drawDotProgressBar(i + 1, wait); System.Threading.Thread.Sleep(1000); } Console.WriteLine(); }
public void ShowWait(ScpiCommand scpiCmd) { if (this.InvokeRequired) { this.BeginInvoke(new ShowWaitDelegate(this.ShowWait), new object[] { scpiCmd }); } else { string cmd = scpiCmd.Str; cmd = cmd.Remove(0, 2); cmd.Trim(); int wait = Convert.ToInt32(cmd); waitProgressBar.Maximum = wait; waitProgressBar.Visible = true; // pg.s //for (int i = 0; i < wait; i++) //{ // //when the output of scpugui is directed to text file // //Invalid handle error appears when drawtextprogressbar is first called // //And scpigui stops there. // System.Threading.Thread.Sleep(1000); // pg.Value = i; //} this.AddEmbeddedControl(waitProgressBar, HDR_RESULT, m_ParserPointer - 1); TabPage parentTab = (TabPage)this.Parent; TabData tabData = (TabData)parentTab.Tag; tabData.scpiTestThread.Suspend(); waitTimer.Start(); } }
public void ShowCommand(ScpiCommand scpiCmd) { Console.WriteLine(scpiCmd.Str); }
public bool GetNextLine(ref ScpiCommand scpiCmd) { bool status = true; string readStr = ""; if (ReadNextLine(ref readStr) == true) { if (parseStd == ParseStd.SFXSCPI) { readStr = readStr.Trim(); if ("r:" == readStr) { scpiCmd.Type = ScpiCommandType.QUERY; scpiCmd.Cmd = ""; } else if (readStr.StartsWith("s: ", true, CultureInfo.CurrentCulture) == true) { scpiCmd.Type = ScpiCommandType.SET; scpiCmd.Cmd = readStr.Remove(readStr.IndexOf("s: ", StringComparison.OrdinalIgnoreCase), 3); } else if (readStr.StartsWith("w: ", true, CultureInfo.CurrentCulture) == true) { scpiCmd.Type = ScpiCommandType.WAIT; scpiCmd.Cmd = ""; } else //default { scpiCmd.Type = ScpiCommandType.INVALID; scpiCmd.Cmd = ""; } scpiCmd.Str = readStr; } else//ParseStd.SCPI { readStr.Trim(); if ((readStr.StartsWith(":") == true) && (readStr.EndsWith("?") == true)) { scpiCmd.Type = ScpiCommandType.QUERY; } else if (readStr.StartsWith(":w ") == true) { scpiCmd.Type = ScpiCommandType.WAIT; } else if ((readStr.StartsWith(":") == true) && (readStr.EndsWith("?") == false)) { scpiCmd.Type = ScpiCommandType.SET; } else //default { scpiCmd.Type = ScpiCommandType.INVALID; } scpiCmd.Cmd = readStr; } } else { status = false; } return(status); }