14 #include "xrubysupport.h"
18 #include "primarydriver.h"
19 #include "interface.h"
22 #include "recordreader.h"
24 #include "thermometer.h"
28 #include "driverlistconnector.h"
29 #include "interfacelistconnector.h"
30 #include "entrylistconnector.h"
31 #include "graphlistconnector.h"
32 #include "recordreaderconnector.h"
33 #include "nodebrowser.h"
35 #include "ui_caltableform.h"
36 #include "ui_drivercreate.h"
37 #include "ui_nodebrowserform.h"
38 #include "ui_recordreaderform.h"
39 #include "ui_rubythreadtool.h"
40 #include "ui_graphtool.h"
41 #include "ui_interfacetool.h"
42 #include "ui_drivertool.h"
43 #include "ui_scalarentrytool.h"
45 #include <QTextBrowser>
47 shared_ptr<XStatusPrinter> g_statusPrinter;
49 XMeasure::XMeasure(
const char *name,
bool runtime) :
53 m_graphList(create<
XGraphList>(
"GraphList", true, scalarEntries())),
54 m_chartList(create<
XChartList>(
"ChartList", true, scalarEntries())),
56 m_drivers(create<
XDriverList>(
"Drivers", false, static_pointer_cast<
XMeasure>(shared_from_this()))),
57 m_textWriter(create<
XTextWriter>(
"TextWriter", false, drivers(), scalarEntries())),
58 m_rawStreamRecorder(create<
XRawStreamRecorder>(
"RawStreamRecorder", false, drivers())),
62 rawStreamRecordReader(),
63 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmRecordReader)),
65 m_drivers, dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmDriver)),
68 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmInterface->m_tblInterface)),
71 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_tblEntries,
74 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmGraphList->m_tblGraphs,
75 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmGraphList->btnNewGraph,
76 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmGraphList->btnDeleteGraph)),
78 textWriter()->recording(),
79 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_ckbTextWrite)),
81 textWriter()->filename(),
82 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_edTextWriter,
83 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_btnTextWriter,
84 "Data files (*.dat);;All files (*.*)", true)),
86 textWriter()->lastLine(),
87 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_edLastLine)),
89 textWriter()->logRecording(),
90 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_ckbLoggerWrite)),
92 textWriter()->logFilename(),
93 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_edLogFile,
94 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_btnLogFile,
95 "Data files (*.dat);;All files (*.*)", true)),
97 textWriter()->logEvery(),
98 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmScalarEntry->m_edLoggerEvery)),
100 rawStreamRecorder()->filename(),
101 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmDriver->m_edRec,
102 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmDriver->m_btnRec,
103 "Binary files (*.bin);;All files (*.*)", true)),
105 rawStreamRecorder()->recording(),
106 dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmDriver->m_ckbBinRecWrite)),
107 m_conUrlRubyThread(),
109 m_thermometers, dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmCalTable)),
111 shared_from_this(), dynamic_cast<
FrmKameMain*>(g_pFrmMain)->m_pFrmNodeBrowser)) {
113 g_statusPrinter = XStatusPrinter::create();
116 m_lsnOnReleaseDriver = tr[ *drivers()].onRelease().connect(
117 *
this, &XMeasure::onReleaseDriver);
120 m_ruby = createOrphan<XRuby>(
"RubySupport",
true,
121 dynamic_pointer_cast<
XMeasure>(shared_from_this()));
128 XMeasure::~XMeasure() {
129 printf(
"terminate\n");
130 m_rawStreamRecordReader->terminate();
132 m_rawStreamRecordReader->join();
135 g_statusPrinter.reset();
140 interfaces()->releaseAll();
141 drivers()->releaseAll();
142 thermometers()->releaseAll();
149 for(
auto it = list.begin(); it != list.end(); it++) {
157 auto driver = static_pointer_cast<
XDriver>(e.released);
162 shared_ptr<XScalarEntry> entry;
166 for(
auto it = list.begin(); it != list.end(); it++) {
168 if(entr->driver() == driver) {
175 scalarEntries()->release(entry);
178 shared_ptr<XInterface> intf_release;
182 for(
auto it = list.begin(); it != list.end(); it++) {
183 auto intf = dynamic_pointer_cast<
XInterface> ( *it);
184 if(intf->driver() == driver) {
191 interfaces()->release(intf_release);