void CPlot_Example_1::pvPlotRow(const char* row_p, const unsigned int* length_p, unsigned int rowIndex) { if (!m_graphAdded) { m_valueGraph_p = AddGraph(m_subPlotID, "Value graph", 1000); m_graphAdded = true; } // The "data" string in the example_1 text log looks like this: Time:0 Value:1 // 1. Search for a string starting with text Time: // 2. Parse the integer value // 3. Search for Value: // 4. Parse the integer value // Initialize the parser with the string m_parser.SetText(row_p, *length_p); // Make sure the parser starts looking at index 0 m_parser.ResetParser(); // 1. Search for "Time:" if (m_parser.Search("Time:", 5)) { bool status; int time; int value; // 2. Parse the INT value that comes after the "Time:" string status = m_parser.ParseInt(&time); // 3. Search for the string "Value:" if (status && m_parser.Search("Value:", 6)) { // 4. Parse the INT value that comes after the "Value:" string status = m_parser.ParseInt(&value); if (status) { // If this was the first value we need to initialize the first point of the graph if (m_prevValue == -1 && m_prevTime == -1) { m_prevValue = value; m_prevTime = time; } // Add a line to the graph (x1,Y1) -> (x2,y2) m_valueGraph_p->AddLine((double)m_prevTime, (float)m_prevValue, (double)time, (float)value, rowIndex); m_prevValue = value; m_prevTime = time; } } } }
void HypoMain::OnGraphAdd(wxCommandEvent& WXUNUSED(event)) { SetStatusText("Add Graph"); AddGraph(); }