public bool Init() { DataSourceError result = OpenDataSource(m_FileName); if (result != DataSourceError.OK) { return(false); } //for (int row = 0; row < m_NumRows; row++) //{ // for (int col = 0; col < m_NumCols; col++) // { // DataSourceData data = new DataSourceData(); // GetActualCell(row, col, out data); // } //} return(true); }
private void runAlltraxThread(object com, object dummy_data) { string com_p = (string) com; bool dummy = (bool) dummy_data; bool finCp; float batteryCurrentCp; float batteryVoltageCp; float diodeTempCp; DataSourceError errorStatusCp; float outputCurrentCp; float throttlePosCp; DataSource alltrax; try { if (dummy){ alltrax = new TestDataSource(); } else { if (com_p.Equals("")){ alltrax = new ControllerDataSource(); } else { alltrax = new ControllerDataSource(com_p); } } alltrax.InitDataSource(); lock(finishedLock) finCp = finished; while(!finCp){ //read the COM port - slow! batteryCurrentCp = alltrax.GetBatteryCurrent(); batteryVoltageCp = alltrax.GetBatteryVoltage(); diodeTempCp = alltrax.GetDiodeTemp(); errorStatusCp = alltrax.getErrorStatus(); outputCurrentCp = alltrax.GetOutputCurrent(); throttlePosCp = alltrax.GetThrottlePos(); //copy the results into shared memory lock (alltraxLock){ batteryCurrent = batteryCurrentCp; batteryVoltage = batteryVoltageCp; diodeTemp = diodeTempCp; errorStatus = errorStatusCp; outputCurrent = outputCurrentCp; throttlePos = throttlePosCp; } lock(finishedLock) finCp = finished; } alltrax.CloseDataSource(); //If there is an exception, signal that to the GUI //thread and then terminate this one. } catch (Exception e){ lock (alltraxLock) alltraxExp = e; } // System.Console.WriteLine("Terminating worker thread."); }