DIOS.SynBox.Device.Test.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // DIOS.Device.Test.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. #include <Windows.h>
  5. #include <assert.h>
  6. #include "DIOS.Dev.IODevice.hpp"
  7. #include "ResDataObject.h"
  8. namespace nsDEV = DIOS::Dev;
  9. static void OnNotify (int NotifyCode, std::string key, std::string context)
  10. {
  11. printf ("OnNotify : %s :%s \n", key.c_str (), context.c_str ());
  12. return;
  13. }
  14. int _tmain ()
  15. {
  16. //auto libFN = L"DIOS.Dev.SyncBoxe.DYN64D.dll";
  17. //auto libFN = L"DIOS.Dev.SyncBox.V2COM64.dll";
  18. auto libFN = L"DIOS.Dev.SyncBox.V2COM64D.dll";
  19. //auto libFN = L"DIOS.Dev.SyncBoxe.DYN64.dll";
  20. auto h = LoadLibrary (libFN);
  21. if (! h)
  22. return 3;
  23. auto fun = GetProcAddress (h, "GetIODriver");
  24. if (!fun)
  25. return 5;
  26. auto pDriver = reinterpret_cast <nsDEV::IODriver*> (fun ());
  27. assert (pDriver);
  28. pDriver->EventCenter->OnNotify.Push (OnNotify);
  29. //pDriver->DriverEntry (R"(C:\SVN Packaging\DIOS DELWORKS\Device\DriverConfig\UCBSyncBoxdrv.xml)");
  30. pDriver->DriverEntry(R"(C:\Code\Dios 2022\NewDIOS\Deliver\Bin\DebugX64\SyncBoxdrv.xml)");
  31. pDriver->Prepare ();
  32. string resResource = pDriver->GetResource ();
  33. printf ("GetDriverResource: %s \n", resResource.c_str ());
  34. pDriver->Connect ();
  35. auto bConnected = pDriver->isConnected ();
  36. if (! bConnected)
  37. return 9;
  38. bConnected = pDriver->isConnected ();
  39. bConnected = pDriver->isConnected ();
  40. bConnected = pDriver->isConnected ();
  41. bConnected = pDriver->isConnected ();
  42. bConnected = pDriver->isConnected ();
  43. bConnected = pDriver->isConnected ();
  44. bConnected = pDriver->isConnected ();
  45. auto pDevice = pDriver->CreateDevice (0);
  46. if (! bConnected)
  47. assert (! pDevice);
  48. else
  49. assert (pDevice);
  50. if (! pDevice)
  51. return 12;
  52. bool result=pDevice->Prepare();
  53. std::string rsp;
  54. ResDataObject json;
  55. json.add("P0", "Table");
  56. auto rc0 = pDevice->Action("SetValue_WORKSTATION", json.encode(), rsp);
  57. assert(rc0 == nsDEV::RET_STATUS::RET_SUCCEED);
  58. json.update("P0", "SingleRad");
  59. auto rc1 = pDevice->Action("SetExpMode", json.encode(), rsp);
  60. assert(rc1 == nsDEV::RET_STATUS::RET_SUCCEED);
  61. json.update("P0", "3");
  62. auto rc2 = pDevice->Action("SetGeneratortoSyncStatus", json.encode(), rsp);
  63. assert(rc2 == nsDEV::RET_STATUS::RET_SUCCEED);
  64. //json.update("P0", "1");
  65. //auto rc3 = pDevice->Action("SetCollimatorMode", json.encode(), rsp);
  66. //assert(rc3 == nsDEV::RET_STATUS::RET_SUCCEED);
  67. //json.update("P0", "23");
  68. //json.update("P1", "30");
  69. //auto rc4 = pDevice->Action("SetCollimatorSize", json.encode(), rsp);
  70. //assert(rc4 == nsDEV::RET_STATUS::RET_SUCCEED);
  71. puts ("Hit any key to quit");
  72. getchar ();
  73. return 0;
  74. }