summaryrefslogtreecommitdiff
path: root/riff/DutManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'riff/DutManager.cpp')
-rwxr-xr-xriff/DutManager.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/riff/DutManager.cpp b/riff/DutManager.cpp
new file mode 100755
index 0000000..86a96c4
--- /dev/null
+++ b/riff/DutManager.cpp
@@ -0,0 +1,65 @@
+/*
+ * DUTManager.cpp
+ *
+ * Copyright (C) ST-Ericsson SA 2011
+ * Authors: Srimanta Panda <srimanta.panda@stericsson.com>,
+ * Ola Borgelin <ola.borgelin@stericsson.com>,
+ * Karin Hedlund <karin.hedlund@stericsson.com>,
+ * Markus Andersson <markus.m.andersson@stericsson.com> for ST-Ericsson.
+ * License terms: 3-clause BSD license
+ *
+ */
+
+/*
+ * @addtogroup DUT Manager
+ * @{
+ */
+
+#include "DutManager.h"
+#include "Utilities.h"
+#include <vector>
+using namespace std;
+
+vector<DUT*> DutManager::devices_;
+
+DUT* DutManager::createDut(Device_t device)
+{
+ string dutId = getDutId(device);
+
+ DUT* dut = new DUT(device, dutId, SequenceFactory::getProfileSequence());
+ devices_.push_back(dut);
+
+ dut->startExecution();
+
+ return dut;
+}
+
+const DUT* DutManager::getDut(Device_t device)
+{
+ for (vector<DUT*>::iterator i = devices_.begin(); i != devices_.end(); ++i) {
+ if ((*i)->getCommDevice() == device) {
+ return *i;
+ }
+ }
+
+ return 0;
+}
+
+void DutManager::destroyDut(Device_t device)
+{
+ for (vector<DUT*>::iterator i = devices_.begin(); i != devices_.end(); ++i) {
+ if ((*i)->getCommDevice() == device) {
+ delete *i;
+ devices_.erase(i);
+ break;
+ }
+ }
+}
+
+string DutManager::getDutId(Device_t device)
+{
+ string physicalId = "Device@" + Utilities::convert<string>(comm_get_physical_address(device));
+ return physicalId;
+}
+
+/* @} */