CustusX  22.04-rc5
An IGT application
cxAcquisitionServiceProxy.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 
14 #include <boost/bind.hpp>
15 #include <ctkPluginContext.h>
16 #include "cxNullDeleter.h"
17 #include "cxLogger.h"
18 
19 namespace cx
20 {
21 
22 //AcquisitionServicePtr AcquisitionServiceProxy::create(ctkPluginContext *pluginContext)
23 //{
24 // return AcquisitionServicePtr(new AcquisitionServiceProxy(pluginContext));
25 //}
26 
28  mPluginContext(context),
29  mAcquisitionService(AcquisitionService::getNullObject())
30 {
31  this->initServiceListener();
32 }
33 
34 void AcquisitionServiceProxy::initServiceListener()
35 {
36  mServiceListener.reset(new ServiceTrackerListener<AcquisitionService>(
37  mPluginContext,
38  boost::bind(&AcquisitionServiceProxy::onServiceAdded, this, _1),
39  boost::function<void (AcquisitionService*)>(),
40  boost::bind(&AcquisitionServiceProxy::onServiceRemoved, this, _1)
41  ));
42  mServiceListener->open();
43 }
44 void AcquisitionServiceProxy::onServiceAdded(AcquisitionService* service)
45 {
46  mAcquisitionService.reset(service, null_deleter());
47 
54 
57 
58  if(mAcquisitionService->isNull())
59  reportWarning("AcquisitionServiceProxy::onServiceAdded mAcquisitionService->isNull()");
60 
61  emit stateChanged();
62  emit usReadinessChanged();
64 }
65 
66 void AcquisitionServiceProxy::onServiceRemoved(AcquisitionService *service)
67 {
68  disconnect(service, &AcquisitionService::started, this, &AcquisitionService::started);
74 
77 
78  mAcquisitionService = AcquisitionService::getNullObject();
79 
80  emit stateChanged();
81  emit usReadinessChanged();
83 }
84 
86 {
87  return mAcquisitionService->isNull();
88 }
89 
91 {
92  return mAcquisitionService->getLatestSession();
93 }
94 
95 std::vector<RecordSessionPtr> AcquisitionServiceProxy::getSessions()
96 {
97  return mAcquisitionService->getSessions();
98 }
99 
101 {
102  return mAcquisitionService->isReady(context);
103 }
104 
106 {
107  return mAcquisitionService->getInfoText(context);
108 }
109 
111 {
112  return mAcquisitionService->getState();
113 }
114 
115 void AcquisitionServiceProxy::startRecord(TYPES context, QString category, RecordSessionPtr session)
116 {
117  mAcquisitionService->startRecord(context, category, session);
118 }
119 
121 {
122  mAcquisitionService->stopRecord();
123 }
124 
126 {
127  mAcquisitionService->cancelRecord();
128 }
129 
131 {
132  mAcquisitionService->startPostProcessing();
133 }
134 
136 {
137  mAcquisitionService->stopPostProcessing();
138 }
139 
141 {
142  return mAcquisitionService->getNumberOfSavingThreads();
143 }
144 
145 } //cx
Acqusition services abstract interface.
virtual RecordSessionPtr getLatestSession()
void saveDataCompleted(QString mhdFilename)
emitted when data has been saved to file
virtual void startRecord(TYPES context, QString category, RecordSessionPtr session)
virtual QString getInfoText(TYPES context) const
boost::shared_ptr< class RecordSession > RecordSessionPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
virtual bool isReady(TYPES context) const
static AcquisitionServicePtr getNullObject()
Helper class for listening to services being added, modified and removed.
AcquisitionServiceProxy(ctkPluginContext *context)
void acquisitionDataReady()
emitted when data is acquired and sent to the reconstruction module
virtual std::vector< RecordSessionPtr > getSessions()
Namespace for all CustusX production code.