Scope
GalilController.cpp
1 #include "StdAfx.h"
2 #include "GalilController.h"
3 #include "helpers/ScopeException.h"
4 #include "helpers/helpers.h"
5 
6 // Only use this code if we need it
7 #ifdef SCOPE_USE_GALIL_XYZSTAGE
8 
9 namespace scope {
10 
11 std::mutex GalilController::mutex;
12 
13 GalilController::GalilController(const std::wstring& _comstring)
14  : comstring(_comstring) {
15 }
16 
17 std::wstring GalilController::LibraryVersion() {
18  std::lock_guard<std::mutex> lock(mutex);
19  std::wstring cstr(CA2W(Ctrl().libraryVersion().c_str()));
20  return cstr;
21 }
22 
23 std::wstring GalilController::Connection() {
24  std::lock_guard<std::mutex> lock(mutex);
25  std::wstring cstr(CA2W(Ctrl().connection().c_str()));
26  return cstr;
27 }
28 
29 void GalilController::SetTimeout(const int32_t& _milliseconds) {
30  Ctrl().timeout_ms = _milliseconds;
31 }
32 
33 std::wstring GalilController::Command(const std::wstring& _cmd) {
34  std::lock_guard<std::mutex> lock(mutex);
35  std::string cmd(CW2A(_cmd.c_str()));
36  std::string ret("");
37  ret = Ctrl().command(cmd);
38  std::wstring cret(CA2W(ret.c_str()));
39  return cret;
40 }
41 
42 double GalilController::CommandValue(const std::wstring& _cmd) {
43  std::lock_guard<std::mutex> lock(mutex);
44  std::string cmd = CW2A(_cmd.c_str());
45  return Ctrl().commandValue(cmd);
46 }
47 
48 Galil& GalilController::Ctrl() {
49  try {
50  std::string str = CW2A(comstring.c_str());
51  return CreateInstance(str);
52  } catch(...) { ScopeExceptionHandler(__FUNCTION__, true, true, true, true); }
53 }
54 
55 Galil& GalilController::CreateInstance(const std::string& stdcomstring) {
56  std::string tmp(stdcomstring);
57  static std::unique_ptr<Galil> _instance(new Galil(tmp));
58  return *_instance;
59 
60 }
61 
62 }
63 
64 #endif
This is the include file for standard system include files, or project specific include files that ar...
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
Various helper functions and classes for Scope.