NorMIT-nav  22.09
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
cx::AcquisitionService::acquisitionStopped
void acquisitionStopped()
cxLogger.h
cx::AcquisitionServiceProxy::cancelRecord
virtual void cancelRecord()
Definition: cxAcquisitionServiceProxy.cpp:125
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::AcquisitionService::saveDataCompleted
void saveDataCompleted(QString mhdFilename)
emitted when data has been saved to file
cx::AcquisitionServiceProxy::getSessions
virtual std::vector< RecordSessionPtr > getSessions()
Definition: cxAcquisitionServiceProxy.cpp:95
cx::AcquisitionServiceProxy::getNumberOfSavingThreads
virtual int getNumberOfSavingThreads() const
Definition: cxAcquisitionServiceProxy.cpp:140
cx::AcquisitionService::stateChanged
void stateChanged()
cx::AcquisitionServiceProxy::getInfoText
virtual QString getInfoText(TYPES context) const
Definition: cxAcquisitionServiceProxy.cpp:105
cx::AcquisitionServiceProxy::stopPostProcessing
virtual void stopPostProcessing()
Definition: cxAcquisitionServiceProxy.cpp:135
cx::AcquisitionServiceProxy::startPostProcessing
virtual void startPostProcessing()
Definition: cxAcquisitionServiceProxy.cpp:130
cxAcquisitionServiceProxy.h
cxNullDeleter.h
cx::AcquisitionService
Acqusition services abstract interface.
Definition: cxAcquisitionService.h:36
cx::AcquisitionServiceProxy::getState
virtual STATE getState() const
Definition: cxAcquisitionServiceProxy.cpp:110
cx::AcquisitionService::recordedSessionsChanged
void recordedSessionsChanged()
cx::AcquisitionService::TYPES
QFlags< TYPE > TYPES
Definition: cxAcquisitionService.h:48
cx::AcquisitionService::usReadinessChanged
void usReadinessChanged()
cx::AcquisitionService::cancelled
void cancelled()
cx::AcquisitionService::acquisitionDataReady
void acquisitionDataReady()
emitted when data is acquired and sent to the reconstruction module
cx::AcquisitionServiceProxy::isReady
virtual bool isReady(TYPES context) const
Definition: cxAcquisitionServiceProxy.cpp:100
cx::AcquisitionService::started
void started()
cx::AcquisitionService::getNullObject
static AcquisitionServicePtr getNullObject()
Definition: cxAcquisitionService.cpp:21
cx::AcquisitionServiceProxy::startRecord
virtual void startRecord(TYPES context, QString category, RecordSessionPtr session)
Definition: cxAcquisitionServiceProxy.cpp:115
cx::AcquisitionServiceProxy::AcquisitionServiceProxy
AcquisitionServiceProxy(ctkPluginContext *context)
Definition: cxAcquisitionServiceProxy.cpp:27
cx::RecordSessionPtr
boost::shared_ptr< class RecordSession > RecordSessionPtr
Definition: cxAcquisitionService.h:28
cx::reportWarning
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
cx::AcquisitionService::STATE
STATE
Definition: cxAcquisitionService.h:51
cx::AcquisitionServiceProxy::isNull
virtual bool isNull()
Definition: cxAcquisitionServiceProxy.cpp:85
cx::AcquisitionServiceProxy::getLatestSession
virtual RecordSessionPtr getLatestSession()
Definition: cxAcquisitionServiceProxy.cpp:90
cx::AcquisitionServiceProxy::stopRecord
virtual void stopRecord()
Definition: cxAcquisitionServiceProxy.cpp:120