123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- // DIOS.Device.Test.cpp : 定义控制台应用程序的入口点。
- //
- #include "stdafx.h"
- #include <Windows.h>
- #include <assert.h>
- #include "DIOS.Dev.IODevice.hpp"
- #include "ResDataObject.h"
- namespace nsDEV = DIOS::Dev;
- static void OnNotify (int NotifyCode, std::string key, std::string context)
- {
- printf ("OnNotify : %s :%s \n", key.c_str (), context.c_str ());
- return;
- }
- int _tmain ()
- {
- //auto libFN = L"DIOS.Dev.SyncBoxe.DYN64D.dll";
- //auto libFN = L"DIOS.Dev.SyncBox.V2COM64.dll";
- auto libFN = L"DIOS.Dev.SyncBox.V2COM64D.dll";
- //auto libFN = L"DIOS.Dev.SyncBoxe.DYN64.dll";
- auto h = LoadLibrary (libFN);
- if (! h)
- return 3;
- auto fun = GetProcAddress (h, "GetIODriver");
- if (!fun)
- return 5;
- auto pDriver = reinterpret_cast <nsDEV::IODriver*> (fun ());
- assert (pDriver);
- pDriver->EventCenter->OnNotify.Push (OnNotify);
- //pDriver->DriverEntry (R"(C:\SVN Packaging\DIOS DELWORKS\Device\DriverConfig\UCBSyncBoxdrv.xml)");
- pDriver->DriverEntry(R"(C:\Code\Dios 2022\NewDIOS\Deliver\Bin\DebugX64\SyncBoxdrv.xml)");
- pDriver->Prepare ();
- string resResource = pDriver->GetResource ();
- printf ("GetDriverResource: %s \n", resResource.c_str ());
- pDriver->Connect ();
- auto bConnected = pDriver->isConnected ();
- if (! bConnected)
- return 9;
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- bConnected = pDriver->isConnected ();
- auto pDevice = pDriver->CreateDevice (0);
- if (! bConnected)
- assert (! pDevice);
- else
- assert (pDevice);
- if (! pDevice)
- return 12;
- bool result=pDevice->Prepare();
- std::string rsp;
- ResDataObject json;
- json.add("P0", "Table");
- auto rc0 = pDevice->Action("SetValue_WORKSTATION", json.encode(), rsp);
- assert(rc0 == nsDEV::RET_STATUS::RET_SUCCEED);
- json.update("P0", "SingleRad");
- auto rc1 = pDevice->Action("SetExpMode", json.encode(), rsp);
- assert(rc1 == nsDEV::RET_STATUS::RET_SUCCEED);
- json.update("P0", "3");
- auto rc2 = pDevice->Action("SetGeneratortoSyncStatus", json.encode(), rsp);
- assert(rc2 == nsDEV::RET_STATUS::RET_SUCCEED);
- //json.update("P0", "1");
- //auto rc3 = pDevice->Action("SetCollimatorMode", json.encode(), rsp);
- //assert(rc3 == nsDEV::RET_STATUS::RET_SUCCEED);
- //json.update("P0", "23");
- //json.update("P1", "30");
- //auto rc4 = pDevice->Action("SetCollimatorSize", json.encode(), rsp);
- //assert(rc4 == nsDEV::RET_STATUS::RET_SUCCEED);
- puts ("Hit any key to quit");
- getchar ();
- return 0;
- }
|