123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- #include "stdafx.h"
- #include "DIOS.Dev.MechanicalMoudle.hpp"
- #include "DIOSDICOMInfo.h"
- using namespace DIOS::Dev;
- using namespace DIOS::Dev::Detail::MECH;
- namespace nsMech = DIOS::Dev::Detail::MECH;
- nsMech::MechanicalDevice::MechanicalDevice(std::shared_ptr <DIOS::Dev::IOEventCenter> EventCenter) :super(EventCenter)
- {
- m_EventCenter = EventCenter;
- m_Grid = 0;
- m_Mammo_AE = 0;
- m_Mammo_FT = 0;
- m_Mammo_PressureState = 35;
- m_Mammo_CompPressureDEC = 0;
- m_Mammo_Depress = 0;
- m_Mammo_MechAngle = 0.0f;
- m_Mammo_MechHeight = 0.0f;
- m_Mammo_PressureValue = 0.0f;
- m_Mammo_AGD = 0.0f;
- m_Mammo_MAG = 1.0f;
- m_Mammo_CompressPaddle = "";
- }
- nsMech::MechanicalDevice::~MechanicalDevice()
- {
- }
- void nsMech::MechanicalDevice::FireNotify(string key, unsigned int value)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", value);
- std::string str = szInfo;
- m_EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
- }
- void nsMech::MechanicalDevice::FireNotify(string key, float value)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", value);
- std::string str = szInfo;
- m_EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
- }
- void nsMech::MechanicalDevice::FireNotify(string key, string value)
- {
- std::string str = value;
- m_EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
- }
- void nsMech::MechanicalDevice::Register()
- {
- auto Disp = Dispatch.Lock().As();
- Disp->Action.Push("SetGrid", this, &nsMech::MechanicalDevice::JSSetGrid);
- Disp->Action.Push("SetAutoTracking", this, &nsMech::MechanicalDevice::JSSetAutoTracking);
- Disp->Action.Push("GetTomoResults", this, &nsMech::MechanicalDevice::JSGetTomoResults);
- Disp->Get.Push("GRID", this, &nsMech::MechanicalDevice::JSGetGrid);
- Disp->Get.Push("AE", this, &nsMech::MechanicalDevice::JSGetMammo_AE);
- Disp->Get.Push("Filter", this, &nsMech::MechanicalDevice::JSGetMammo_FT);
- Disp->Get.Push("Thickness", this, &nsMech::MechanicalDevice::JSGetMammo_PressureState);
- Disp->Get.Push("CompPressureDEC", this, &nsMech::MechanicalDevice::JSGetMammo_CompPressureDEC);
- Disp->Get.Push("Depress", this, &nsMech::MechanicalDevice::JSGetMammo_Depress);
- Disp->Get.Push("MechanicalAngle", this, &nsMech::MechanicalDevice::JSGetMammo_MechAngle);
- Disp->Get.Push("MechanicalHeight", this, &nsMech::MechanicalDevice::JSGetMammo_MechHeight);
- Disp->Get.Push("CompPressure", this, &nsMech::MechanicalDevice::JSGetMammo_PressureValue);
- Disp->Get.Push("AGD", this, &nsMech::MechanicalDevice::JSGetMammo_AGD);
- Disp->Get.Push("MAG", this, &nsMech::MechanicalDevice::JSGetMammo_MAG);
- Disp->Get.Push("CompressPaddle", this, &nsMech::MechanicalDevice::JSGetMammo_CompressPaddle);
- }
- bool nsMech::MechanicalDevice::Prepare()
- {
- Register();
- return true;
- }
- std::string nsMech::MechanicalDevice::GetGUID() const
- {
- return MechanicalUnitType;
- }
- RET_STATUS nsMech::MechanicalDevice::JSSetGrid(std::string in, std::string& out)
- {
- ResDataObject json;
- json.decode(in.c_str());
- unsigned int nValue = json[0];
- return SetGrid(nValue);
- }
- RET_STATUS nsMech::MechanicalDevice::JSSetAutoTracking(std::string in, std::string& out)
- {
- ResDataObject json;
- json.decode(in.c_str());
- unsigned int nValue = json[0];
- return SetAutoTracking(nValue);
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetTomoResults(std::string in, std::string& out)
- {
- ResDataObject json;
- ResDataObject resultAngle;
- ResDataObject resultHeight;
- RET_STATUS ret = GetTomoResults(resultAngle, resultHeight);
- if(ret != nsDev::RET_STATUS::RET_SUCCEED)
- {
- return nsDev::RET_STATUS::RET_FAILED;
- }
- json.add("P0", resultAngle);
- json.add("P1", resultHeight);
- out = json.encode();
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetGrid(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Grid);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_AE(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Mammo_AE);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_FT(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Mammo_FT);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_PressureState(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Mammo_PressureState);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_CompPressureDEC(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Mammo_CompPressureDEC);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_Depress(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%d", m_Mammo_Depress);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MechAngle(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", m_Mammo_MechAngle);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MechHeight(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", m_Mammo_MechHeight);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_PressureValue(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", m_Mammo_PressureValue);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_AGD(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", m_Mammo_AGD);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MAG(std::string& out)
- {
- char szInfo[64] = { 0 };
- sprintf_s(szInfo, "%f", m_Mammo_MAG);
- out = szInfo;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsMech::MechanicalDevice::JSGetMammo_CompressPaddle(std::string& out)
- {
- //char szInfo[64] = { 0 };
- //sprintf_s(szInfo, "%s", m_Mammo_CompressPaddle);
- out = m_Mammo_CompressPaddle;
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- void MechanicalDevice::UpdateGrid(unsigned int Value)
- {
- m_Grid = Value;
- FireNotify("GRID", Value);
- }
- void MechanicalDevice::UpdateMammo_AE(unsigned int Value)
- {
- m_Mammo_AE = Value;
- FireNotify("AE", Value);
- }
- void MechanicalDevice::UpdateMammo_FT(unsigned int Value)
- {
- m_Mammo_FT = Value;
- FireNotify("Filter", Value);
- }
- void MechanicalDevice::UpdateMammo_PressureState(unsigned int Value)
- {
- m_Mammo_PressureState = Value;
- FireNotify("Thickness", Value);
- }
- void MechanicalDevice::UpdateMammo_CompPressureDEC(unsigned int Value)
- {
- m_Mammo_CompPressureDEC = Value;
- FireNotify("CompPressureDEC", Value);
- }
- void MechanicalDevice::UpdateMammo_Depress(unsigned int Value)
- {
- m_Mammo_Depress = Value;
- FireNotify("Depress", Value);
- }
- void MechanicalDevice::UpdateMammo_MechAngle(float Value)
- {
- m_Mammo_MechAngle = Value;
- FireNotify("MechanicalAngle", Value);
- }
- void MechanicalDevice::UpdateMammo_MechHeight(float Value)
- {
- m_Mammo_MechHeight = Value;
- FireNotify("MechanicalHeight", Value);
- }
- void MechanicalDevice::UpdateMammo_PressureValue(float Value)
- {
- m_Mammo_PressureValue = Value;
- FireNotify("CompPressure", Value);
- }
- void MechanicalDevice::UpdateMammo_AGD(float Value)
- {
- m_Mammo_AGD = Value;
- FireNotify("AGD", Value);
- }
- void MechanicalDevice::UpdateMammo_MAG(float Value)
- {
- m_Mammo_MAG = Value;
- FireNotify("MAG", Value);
- }
- void MechanicalDevice::UpdateMammo_CompressPaddle(std::string Value)
- {
- m_Mammo_CompressPaddle = Value;
- FireNotify("CompressPaddle", Value);
- }
- nsDev::RET_STATUS MechanicalDevice::SetGrid(unsigned int GridType)
- {
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
- nsDev::RET_STATUS MechanicalDevice::SetAutoTracking(unsigned int nAutoTracking)
- {
- return nsDev::RET_STATUS::RET_FAILED;
- }
- nsDev::RET_STATUS MechanicalDevice::GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight)
- {
- return nsDev::RET_STATUS::RET_SUCCEED;
- }
|