1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- // KonicaObject.cpp: CKonicaObject 的实现
- #include "pch.h"
- #include "KonicaObject.h"
- #include <comutil.h>
- #pragma comment(lib, "comsuppw.lib")
- #define IMAGE_START_ADDRESS 500
- #define LOAD_PROC_ADDRESS(handle,func) \
- if ((API_##func = (Konica##func)GetProcAddress(handle, #func)) == NULL) \
- { \
- OutputDebugString("Error occurs while loading entry point!!! [%s]", #func);\
- }\
- CKonicaObject* g_pKonicaObject = nullptr;
- void _stdcall AeroSDKCallBack(int nType, unsigned int uintParam, char* pstrPanelId, int nXgboxNo)
- {
- if (nullptr != g_pKonicaObject)
- {
- g_pKonicaObject->CallBackEvent(nType, uintParam, pstrPanelId, nXgboxNo);
- }
- }
- // CKonicaObject
- CKonicaObject::CKonicaObject()
- {
- m_pCallBackObject = nullptr;
- m_pDataBuffer = nullptr;
- m_pDataBuffer = new CShareMem("KonicaDetectorBuffer");
- OutputDebugString("Create share memory----------------------");
- m_pDataBuffer->CreateShareMem(20 * 1024 * 1024 * sizeof(WORD));//40MB 2张预览图+1张正式图
- g_pKonicaObject = this;
- m_strSdkPath = "";
- m_strPanelType = "";
- m_nXgboxNo = 1;
- m_nSyncMode = SYNC_AED;
- m_bOpenSdk = false;
- m_bConnect = false;
- m_nDetectorStatus = AEROSDK_PANEL_STATUS_UNKNOWN;
- m_bConnectXgbox = false;
- m_nImageNo = 0;
- m_nPreImgWidth = 0;
- m_nPreImgHeight = 0;
- m_nRawImgWidth = 0;
- m_nRawImgHeight = 0;
- m_pPreImgBuffer1 = nullptr;
- m_pPreImgBuffer2 = nullptr;
- m_pRawImgBuffer = nullptr;
- m_hRespond = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_nResolution = AEROSDK_RESOLUTION_NORMAL;
- m_bHaveImageInDetector = false;
- OutputDebugString("Init KonicaCom End----------------------");
- }
- CKonicaObject::~CKonicaObject()
- {
- OutputDebugString("destruction----------------------");
- m_pDataBuffer->CloseShareMemMap();
- if (m_pPreImgBuffer1 != nullptr)
- {
- delete[]m_pPreImgBuffer1;
- m_pPreImgBuffer1 = nullptr;
- }
- if (m_pPreImgBuffer2 != nullptr)
- {
- delete[]m_pPreImgBuffer2;
- m_pPreImgBuffer2 = nullptr;
- }
- if (m_pRawImgBuffer != nullptr)
- {
- delete[]m_pRawImgBuffer;
- m_pRawImgBuffer = nullptr;
- }
- if (m_hRespond)
- {
- CloseHandle(m_hRespond);
- m_hRespond = nullptr;
- }
- }
- /***
- ** 等待探测器操作执行完毕
- ***/
- bool CKonicaObject::WaitRespond(int nTimeOut, const char* szAction)
- {
- char temp[512] = { 0 };
- sprintf(temp, "--- WaitRespond({%s}), {%d}ms----------------------", szAction, nTimeOut);
- OutputDebugString(temp);
- DWORD dwRet = WaitForSingleObject(m_hRespond, nTimeOut);
- if (dwRet == WAIT_TIMEOUT)
- {
- sprintf(temp, "time out in wait response, action:{%s}----------------------", szAction);
- OutputDebugString(temp);
- return false;
- }
- return true;
- }
- void CKonicaObject::StopWaiting(const char* szAction)
- {
- char temp[512] = { 0 };
- sprintf("--- Stop waiting respond, {%s}----------------------", szAction);
- OutputDebugString(temp);
- SetEvent(m_hRespond);
- }
- STDMETHODIMP CKonicaObject::LoadDLL(BSTR strSdkPath)
- {
- OutputDebugString("LoadDLL start----------------------");
- char* pSdkPath = _com_util::ConvertBSTRToString(strSdkPath);//需要手动释放内存
- string strWorkPath = pSdkPath;
- m_strSdkPath = strWorkPath;//D:\SVNDownload\CCOS_DROC_TRUNK\Device\OEMDrivers\Detector\Konica\KonicaHDDetector\SDK
- SetDllDirectory(strWorkPath.c_str());
- /*strWorkPath = strWorkPath + "\\Aerosdk.dll";
- HMODULE m_hSDKModule = LoadLibraryEx(strWorkPath.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
- OutputDebugString("LoadLibrary----------------------");
- if (m_hSDKModule == nullptr)
- {
- DWORD dw = GetLastError();
- char temp[1024] = { 0 };
- sOutputDebugString("Load %s fail! error code:%ld----------------------", strWorkPath.c_str(), dw);
- OutputDebugString(temp);
- return S_FALSE;
- }*/
- delete[] pSdkPath;
- Initialize();
- OutputDebugString("LoadDLL end----------------------");
- return S_OK;
- }
- void CKonicaObject::Initialize()
- {
- ZeroMemory(&m_stLogInfo, sizeof(StAerosdkLogInfo));
- m_stLogInfo.intLogLevel = AEROSDK_LOG_DEBUG;
- sprintf_s(m_stLogInfo.strSdkLog, sizeof(m_stLogInfo.strSdkLog), "%s%s", m_strSdkPath.c_str(), "\\Log\\AeroSDK.log");
- sprintf_s(m_stLogInfo.strKmfLog, sizeof(m_stLogInfo.strKmfLog), "%s%s", m_strSdkPath.c_str(), "\\Log\\KmfLog.log");
- std::string temp;
- if (strAeroSDKini)
- {
- sprintf_s(strAeroSDKini, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Conf\\AerosdkSetting.ini");
- temp = "strAeroSDKini:";
- temp = temp + strAeroSDKini;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- }
- if (strPanelLog)
- {
- sprintf_s(strPanelLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\Panel.log");
- temp = "strPanelLog:";
- temp = temp + strPanelLog;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- }
- if (strXGBOXLog)
- {
- sprintf_s(strXGBOXLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\XGBOX.log");
- temp = "strXGBOXLog:";
- temp = temp + strXGBOXLog;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- }
- if (strECBLog)
- {
- sprintf_s(strECBLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\ECB.log");
- temp = "strECBLog:";
- temp = temp + strECBLog;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- }
- }
- STDMETHODIMP CKonicaObject::SetPanelType(BSTR strPanelType)
- {
- OutputDebugString("SetPanelType----------------------");
- char* pPanelType = _com_util::ConvertBSTRToString(strPanelType);//需要手动释放内存
- m_strPanelType = pPanelType;
- std::string temp = "m_strPanelType:";
- temp = temp + m_strPanelType;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- delete[] pPanelType;
- return S_OK;
- }
- string CKonicaObject::GetStrEventType(int nEventType)
- {
- string temp = "";
- switch (nEventType)
- {
- case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE:
- temp = "AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE";
- break;
- case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS:
- temp = "AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS";
- break;
- case AEROSDK_CBTYPE_PANEL_DISCONNECT:
- temp = "AEROSDK_CBTYPE_PANEL_DISCONNECT";
- break;
- case AEROSDK_CBTYPE_PANEL_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_BATTERY_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_BATTERY_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_MOUNTED:
- temp = "AEROSDK_CBTYPE_PANEL_MOUNTED";
- break;
- case AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED:
- temp = "AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED";
- break;
- case AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_READY_TIMEOUT:
- temp = "AEROSDK_CBTYPE_PANEL_READY_TIMEOUT";
- break;
- case AEROSDK_CBTYPE_PANEL_START_IMAGE:
- temp = "AEROSDK_CBTYPE_PANEL_START_IMAGE";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_IMAGE:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_IMAGE";
- break;
- case AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER:
- temp = "AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER";
- break;
- case AEROSDK_CBTYPE_PANEL_UPDATE_STATUS:
- temp = "AEROSDK_CBTYPE_PANEL_UPDATE_STATUS";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_UPDATE:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_UPDATE";
- break;
- case AEROSDK_CBTYPE_PANEL_UPDATE_ERROR:
- temp = "AEROSDK_CBTYPE_PANEL_UPDATE_ERROR";
- break;
- case AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT:
- temp = "AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT";
- break;
- case AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE:
- temp = "AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE";
- break;
- case AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT:
- temp = "AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT";
- break;
- case AEROSDK_CBTYPE_PANEL_OPEN_ERROR:
- temp = "AEROSDK_CBTYPE_PANEL_OPEN_ERROR";
- break;
- case AEROSDK_CBTYPE_PANEL_DETECT_ERROR:
- temp = "AEROSDK_CBTYPE_PANEL_DETECT_ERROR";
- break;
- case AEROSDK_CBTYPE_PANEL_ERROR_CANCELED:
- temp = "AEROSDK_CBTYPE_PANEL_ERROR_CANCELED";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE";
- break;
- case AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT:
- temp = "AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT";
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER:
- temp = "AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER";
- break;
- case AEROSDK_CBTYPE_XGBOX_CONNECTTED:
- temp = "AEROSDK_CBTYPE_XGBOX_CONNECTTED";
- break;
- case AEROSDK_CBTYPE_XGBOX_DISCONNECT:
- temp = "AEROSDK_CBTYPE_XGBOX_DISCONNECT";
- break;
- case AEROSDK_CBTYPE_XGBOX_PREPARE_ON:
- temp = "AEROSDK_CBTYPE_XGBOX_PREPARE_ON";
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON:
- temp = "AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON";
- break;
- case AEROSDK_CBTYPE_XGBOX_KMREADY_ON:
- temp = "AEROSDK_CBTYPE_XGBOX_KMREADY_ON";
- break;
- case AEROSDK_CBTYPE_XGBOX_KMREADY_OFF:
- temp = "AEROSDK_CBTYPE_XGBOX_KMREADY_OFF";
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF:
- temp = "AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF";
- break;
- case AEROSDK_CBTYPE_XGBOX_PREPARE_OFF:
- temp = "AEROSDK_CBTYPE_XGBOX_PREPARE_OFF";
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT:
- temp = "AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT";
- break;
- case AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE:
- temp = "AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS:
- temp = "AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS";
- break;
- case AEROSDK_CBTYPE_XGBOX_DONE_UPDATE:
- temp = "AEROSDK_CBTYPE_XGBOX_DONE_UPDATE";
- break;
- case AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR:
- temp = "AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR";
- break;
- case AEROSDK_CBTYPE_XGBOX_OPEN_ERROR:
- temp = "AEROSDK_CBTYPE_XGBOX_OPEN_ERROR";
- break;
- case AEROSDK_CBTYPE_XGBOX_DETECT_ERROR:
- temp = "AEROSDK_CBTYPE_XGBOX_DETECT_ERROR";
- break;
- case AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED:
- temp = "AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED";
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE:
- temp = "AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE";
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS:
- temp = "AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS";
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT:
- temp = "AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT";
- break;
- case AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION:
- temp = "AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION";
- break;
- case AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE";
- break;
- case AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE:
- temp = "AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE";
- break;
- }
- return temp;
- }
- bool CKonicaObject::WriteNotifyMessageToShareMemory(int nEventType, long nStartPosition, int nParam, WORD* pImageBuffer, int nBufferSize)
- {
- std::string strResult = GetStrEventType(nEventType);
- std::string strtemp = "WriteNotifyMessageToShareMemory nEventType:";
- strtemp = strtemp + strResult;
- strtemp = strtemp + "----------------------";
- OutputDebugString(strtemp.c_str());
- int temp = 0;
- bool bRet = false;
- if (nEventType == AEROSDK_CBTYPE_PANEL_STATUS || nEventType == AEROSDK_CBTYPE_PANEL_BATTERY_STATUS || nEventType == AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS)
- {
- temp = nParam;
- bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, &temp, sizeof(int));
- if (!bRet)
- {
- return false;
- }
- }
- else if (nEventType == AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1 || nEventType == AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2 || nEventType == AEROSDK_CBTYPE_PANEL_DONE_IMAGE)
- {
- bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, pImageBuffer, nBufferSize);
- if (!bRet)
- {
- return false;
- }
- }
- else
- {
- temp = nEventType;
- bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, &temp, sizeof(int));
- if (!bRet)
- {
- return false;
- }
- }
- return true;
- }
- void CKonicaObject::CallBackEvent(int nType, unsigned int uintParam, char* pstrPanelId, int nXgboxNo)
- {
- int nRet = AEROSDK_OK;
- std::lock_guard<std::mutex> lock(mtx);
- m_queue.push(nType);
- std::string temp;
- switch (nType)
- {
- case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE:
- // AeroSDK-Panel connection detection [wired]
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- m_bConnect = true;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE, 0, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS:
- // AeroSDK-Panel connection detection [wireless]
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- m_bConnect = true;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS, 4, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_DISCONNECT:
- // AeroSDK-Panel disconnection detection
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- m_bConnect = false;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DISCONNECT, 8, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_STATUS:
- // Panel status notification
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- m_nDetectorStatus = uintParam;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_STATUS, 12, m_nDetectorStatus, nullptr, 0);
- // In order to know the change of Panel status and show on GUI (outside of AeroSDKCallBack), the event should be set as follows.
- // Especially, when AerosdkStartExposureSequenceIt () is used, this code is needed in order to handle "Wait Ready" or "Read Out" event at outside of AeroSDKCallBack.
- switch (m_nDetectorStatus)
- {
- case AEROSDK_PANEL_STATUS_UNKNOWN:
- OutputDebugString("Detector status: UNKNOWN----------------------");
- break;
- case AEROSDK_PANEL_STATUS_INITIALIZE:
- OutputDebugString("Detector status: INITIALIZE----------------------");
- break;
- case AEROSDK_PANEL_STATUS_SLEEP:
- OutputDebugString("Detector status: SLEEP----------------------");
- break;
- case AEROSDK_PANEL_STATUS_STANDBY:
- OutputDebugString("Detector status: STANDBY----------------------");
- break;
- case AEROSDK_PANEL_STATUS_READY:
- OutputDebugString("Detector status: READY----------------------");
- //if (m_nSyncMode == SYNC_HARDWARE)
- //{
- // temp = "";
- // temp = temp + "nXgboxNo:";
- // temp = temp + std::to_string(nXgboxNo);
- // temp = temp + "----------------------";
- // OutputDebugString(temp.c_str());
- // if (m_bConnectXgbox == true)
- // {
- // OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_READY----------------------");
- // nRet = AerosdkSetReadyBusy(m_nXgboxNo, 1, m_nImageNo, AEROSDK_READY);
- // if (TestError(nRet, "AerosdkSetReadyBusy"))
- // {
- // OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
- // }
- // }
- // else
- // {
- // // This means your User Program blocks (does not allow) XG-IFBOX and generator to turn on Exposure signal.
- // // Please refer Section 3.4.1 and 8.4.3 of AeroSDK Library Manual.
- // OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_BUSY----------------------");
- // nRet = AerosdkSetReadyBusy(m_nXgboxNo, 1, 0, AEROSDK_BUSY);
- // if (TestError(nRet, "AerosdkSetReadyBusy"))
- // {
- // OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
- // }
- // }
- //}
- break;
- case AEROSDK_PANEL_STATUS_EXPOSURE:
- OutputDebugString("Detector status: EXPOSURE----------------------");
- break;
- case AEROSDK_PANEL_STATUS_SHUTDOWN:
- OutputDebugString("Detector status: SHUTDOWN----------------------");
- break;
- case AEROSDK_PANEL_STATUS_UPDATE:
- OutputDebugString("Detector status: UPDATE----------------------");
- break;
- case AEROSDK_PANEL_STATUS_MAINTENANCE:
- OutputDebugString("Detector status: MAINTENANCE----------------------");
- break;
- case AEROSDK_PANEL_STATUS_WAIT_READY:
- OutputDebugString("Detector status: WAIT_READY----------------------");
- if (m_nSyncMode == SYNC_AED)
- {
- // When AeroSync Button is pushed, User Program has to make the Panel Ready status.
- temp = "Call API_AerosdkSetPanelReady m_strPanelType:";
- temp = temp + m_strPanelType;
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- //调完接口后很快就ready,但是目前没有回调,就认为ready了
- nRet = AerosdkSetPanelReady((char*)m_strPanelType.c_str());
- if (TestError(nRet, "API_AerosdkSetPanelReady"))
- {
- OutputDebugString("AerosdkSetPanelReady Failure!----------------------");
- }
- else
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_STATUS, 12, AEROSDK_PANEL_STATUS_READY, nullptr, 0);
- }
- }
- break;
- case AEROSDK_PANEL_STATUS_READOUT:
- OutputDebugString("Detector status: READOUT----------------------");
- break;
- case AEROSDK_PANEL_STATUS_ERROR:
- OutputDebugString("Detector status: ERROR----------------------");
- break;
- default:
- break;
- }
- }
- break;
- case AEROSDK_CBTYPE_PANEL_BATTERY_STATUS:
- // Panel battery status notification
- // Panel wireless signal strength notification
- OutputDebugString("Detector battery status notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_BATTERY_STATUS, 16, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS:
- // Panel mounted notification
- OutputDebugString("Detector signal status notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS, 20, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_MOUNTED:
- // Panel switch pressed-down notification
- OutputDebugString("Detector mounted notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_MOUNTED, 24, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED:
- OutputDebugString("Switch pushed notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED, 28, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS:
- OutputDebugString("AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS, 32, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS:
- OutputDebugString("AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS, 36, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_READY_TIMEOUT:
- // Ready timeout notification
- // After several minutes has passed, the Wiress Panel will enter into Standby mode.
- temp = m_strPanelType;
- temp = temp + " Ready timeout notification----------------------";
- OutputDebugString(temp.c_str());
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- //set ready timeout error
- // Difference from AeroSDKSampleIt.cpp <ADD COMMENT>
- // If you want to know when this timeout happens (at READY or WAIT READY), you have to check the "uintParam";
- // If you want to enter into exposure sequence, call AerosdkStartExposureSequenceIt function again.
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_READY_TIMEOUT, 40, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_START_IMAGE:
- // Image transfer start notification
- OutputDebugString("Image transfer start notnotificationify----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_START_IMAGE, 44, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1:
- // Preview1 image receiving completion notification
- OutputDebugString("Preview1 image arrived----------------------");
- if (m_pPreImgBuffer1 != nullptr)
- {
- delete[]m_pPreImgBuffer1;
- m_pPreImgBuffer1 = nullptr;
- OutputDebugString("delete m_pPreImgBuffer1!----------------------");
- }
- OutputDebugString("m_pPreImgBuffer1 new space----------------------");
- m_pPreImgBuffer1 = new WORD[m_nPreImgWidth * m_nPreImgHeight];
- // Receiving Preview1 image from SDK (refer Section 4.4.1 and 8.9.3 of AeroSDK Library Manual)
- OutputDebugString("Call AerosdkGetPreviewImage----------------------");
- nRet = AerosdkGetPreviewImage((char*)m_strPanelType.c_str(), m_nImageNo, AEROSDK_IMAGE_PREVIEW1, m_nPreImgWidth, m_nPreImgHeight, m_pPreImgBuffer1);
- if (TestError(nRet, "AerosdkGetPreviewImage"))
- {
- OutputDebugString("AerosdkGetPreviewImage PREVIEW1 Failure!----------------------");
- break;
- }
- //把图保存到本地
- SaveRawFunc(m_pPreImgBuffer1,"C:\\Konica\\Image\\preview1.raw", m_nPreImgWidth, m_nPreImgHeight);
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1, 300, uintParam, m_pPreImgBuffer1, m_nPreImgWidth * m_nPreImgHeight *2);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2:
- // Preview2 image receiving completion notification
- OutputDebugString("Preview2 image arrived----------------------");
- if (m_pPreImgBuffer2 != nullptr)
- {
- delete[]m_pPreImgBuffer2;
- m_pPreImgBuffer2 = nullptr;
- OutputDebugString("delete m_pPreImgBuffer2!----------------------");
- }
- OutputDebugString("m_pPreImgBuffer2 new space----------------------");
- m_pPreImgBuffer2 = new WORD[m_nPreImgWidth * m_nPreImgHeight];
- OutputDebugString("Call AerosdkGetPreviewImage----------------------");
- nRet = AerosdkGetPreviewImage((char*)m_strPanelType.c_str(), m_nImageNo, AEROSDK_IMAGE_PREVIEW2, m_nPreImgWidth, m_nPreImgHeight, m_pPreImgBuffer2);
- if (TestError(nRet, "AerosdkGetPreviewImage"))
- {
- OutputDebugString("AerosdkGetPreviewImage PREVIEW2 Failure!----------------------");
- break;
- }
- //SaveRawFunc(m_pPreImgBuffer2, "C:\\Konica\\Image\\preview2.raw", m_nPreImgWidth, m_nPreImgHeight);
- //WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2, 300 + 2 * 1024 * 1024, uintParam, m_pPreImgBuffer2, m_nPreImgWidth * m_nPreImgHeight * 2);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_IMAGE:
- // Final image receiving completion notification
- OutputDebugString("Final image arrived----------------------");
- if (m_pRawImgBuffer != nullptr)
- {
- delete[]m_pRawImgBuffer;
- m_pRawImgBuffer = nullptr;
- OutputDebugString("delete m_pRawImgBuffer!----------------------");
- }
- m_pRawImgBuffer = new WORD[m_nRawImgWidth * m_nRawImgHeight];
- OutputDebugString("m_pRawImgBuffer new space----------------------");
- // Receiving final image from SDK (refer Section 4.4.1 and 8.9.4 of AeroSDK Library Manual)
- OutputDebugString("Call API_AerosdkGetImage----------------------");
- nRet = AerosdkGetImage((char*)m_strPanelType.c_str(), m_nImageNo, m_nRawImgWidth, m_nRawImgHeight, m_pRawImgBuffer);
- if (TestError(nRet, "API_AerosdkGetImage"))
- {
- OutputDebugString("Get final image Failure!----------------------");
- break;
- }
- SaveRawFunc(m_pRawImgBuffer, "C:\\Konica\\Image\\FinalImage.raw", m_nRawImgWidth, m_nRawImgHeight);
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_IMAGE, 300 + 4 * 1024 * 1024, uintParam, m_pRawImgBuffer, m_nRawImgWidth * m_nRawImgHeight * 2);
- break;
- case AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER:
- // Image transfer error
- OutputDebugString("Image transfer error notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- // set image transfer error
- //g_intImageTransferError = uintParam;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER, 48, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER:
- // Image resending completion notification
- OutputDebugString("Image resending completion notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER, 52, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_UPDATE_STATUS:
- // Panel firmware update status notification
- OutputDebugString("Panel firmware update status notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_UPDATE_STATUS, 56, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_UPDATE:
- OutputDebugString("Panel firmware update success----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_UPDATE, 60, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_UPDATE_ERROR:
- // Panel firmware update error notification
- OutputDebugString("Panel firmware update error notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_UPDATE_ERROR, 64, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT:
- // Gain calibration result notification
- OutputDebugString("Gain calibration result notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT, 68, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE:
- // Dark calibration progress notification
- OutputDebugString("Dark calibration progress notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE, 72, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT:
- // Dark calibration result notification
- OutputDebugString("Dark calibration result notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT, 76, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_OPEN_ERROR:
- // Panel open error after retry
- OutputDebugString("Panel open fail!----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_OPEN_ERROR, 80, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DETECT_ERROR:
- // Panel error detection
- OutputDebugString("Panel error detection----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DETECT_ERROR, 84, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_ERROR_CANCELED:
- // Panel error cancellation
- OutputDebugString("Panel error cancellation----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ERROR_CANCELED, 88, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE:
- OutputDebugString("AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE, 92, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT:
- OutputDebugString("AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT, 96, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER:
- OutputDebugString("AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER, 100, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_CONNECTTED:
- // AeroSDK - XG-IFBOX connection detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("XgBox connect notification----------------------");
- if (m_nXgboxNo == nXgboxNo)
- {
- m_bConnectXgbox = true;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_CONNECTTED, 104, m_nXgboxNo, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_XGBOX_DISCONNECT:
- // AeroSDK - XG-IFBOX disconnection detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("XgBox disconnect notification----------------------");
- if (m_nXgboxNo == nXgboxNo)
- {
- m_bConnectXgbox = false;
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DISCONNECT, 108, m_nXgboxNo, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_XGBOX_PREPARE_ON:
- // Prepare Signal On Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_PREPARE_ON----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_PREPARE_ON, 112, nXgboxNo, nullptr, 0);
- temp = "";
- temp = temp + "nXgboxNo:";
- temp = temp + std::to_string(nXgboxNo);
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- if (m_nSyncMode == SYNC_HARDWARE
- && m_nXgboxNo == nXgboxNo
- && m_nDetectorStatus == AEROSDK_PANEL_STATUS_READY
- && m_bConnect == true
- && m_bConnectXgbox == true)
- {
- OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_READY----------------------");
- nRet = AerosdkSetReadyBusy(nXgboxNo, uintParam, m_nImageNo, AEROSDK_READY);
- if (TestError(nRet, "AerosdkSetReadyBusy"))
- {
- OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
- }
- }
- else
- {
- // This means your User Program blocks (does not allow) XG-IFBOX and generator to turn on Exposure signal.
- // Please refer Section 3.4.1 and 8.4.3 of AeroSDK Library Manual.
- OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_BUSY----------------------");
- nRet = AerosdkSetReadyBusy(nXgboxNo, uintParam, 0, AEROSDK_BUSY);
- if (TestError(nRet, "AerosdkSetReadyBusy"))
- {
- OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
- }
- }
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON:
- // Exposure Signal On Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON, 116, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_KMREADY_ON:
- // KM_Ready Signal On Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_KMREADY_ON----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_KMREADY_ON, 120, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_KMREADY_OFF:
- // KM_Ready Signal Off Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_KMREADY_OFF----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_KMREADY_OFF, 124, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF:
- // Exposure Signal Off Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF, 128, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_PREPARE_OFF:
- // Prepare Signal Off Detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_PREPARE_OFF----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_PREPARE_OFF, 132, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT:
- // Exposure switch pressed down timeout; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT, 136, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE:
- // Switch sequence interruption; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE, 140, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS:
- // XG-IFBOX firmware update status notification; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS, 144, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_DONE_UPDATE:
- // XG-IFBOX firmware update completion notification; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_DONE_UPDATE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DONE_UPDATE, 148, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR:
- // XG-IFBOX firmware update error notification; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR, 152, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_OPEN_ERROR:
- // XG-IFBOX open error; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_OPEN_ERROR----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_OPEN_ERROR, 156, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_DETECT_ERROR:
- // XG-IFBOX error detection; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_DETECT_ERROR----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DETECT_ERROR, 160, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED:
- // XG-IFBOX error cancellation; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED, 164, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE:
- // Panel -- XG-IFBOX connection is detected (in wired mode) after it was disconnected.
- OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE, 168, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS:
- // Panel -- XG-IFBOX connection is detected (in wireless mode) after it was disconnected.
- OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS, 172, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT:
- // Panel -- XG-IFBOX is disconnected.
- OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT, 176, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION:
- // Warning to let User Program prompt end-users to make calibration of Panel
- OutputDebugString("AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION, 180, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE:
- // Exposure sequence end notification
- OutputDebugString("Exposure sequence end notification----------------------");
- if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
- {
- // Append callback queue
- // These need much processing time, so the code should be written at outside of AeroSDKCallBack().
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE, 184, uintParam, nullptr, 0);
- }
- break;
- case AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE:
- // Image resending sequence end notification
- OutputDebugString("Image resending sequence end notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE, 188, uintParam, nullptr, 0);
- if (m_bHaveImageInDetector)
- {
- m_bHaveImageInDetector = false;
- StopWaiting("ImageResendingSequence");
- }
- break;
- case AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE:
- // Image discarding sequence end notification
- OutputDebugString("Image discarding sequence end notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE, 192, uintParam, nullptr, 0);
- if (m_bHaveImageInDetector)
- {
- m_bHaveImageInDetector = false;
- StopWaiting("ImageDeleteSequence");
- }
- break;
- case AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE:
- // Panel firmware update sequence end notification
- OutputDebugString("Panel firmware update sequence end notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE, 196, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE:
- // XG-IFBOX firmware update sequence end notification; In AeroSync Mode, this callback does not happen.
- OutputDebugString("AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE, 200, nXgboxNo, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE:
- // Gain calibration sequence end notification
- OutputDebugString("Gain calibration sequence end notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE, 204, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE:
- // Dark calibration sequence end notification
- OutputDebugString("Dark calibration sequence end notification----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE, 208, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE:
- OutputDebugString("AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE, 212, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE:
- OutputDebugString("AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE, 216, uintParam, nullptr, 0);
- break;
- case AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE:
- OutputDebugString("AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE----------------------");
- WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE, 220, uintParam, nullptr, 0);
- break;
- default:
- temp = "CallBackEvent default type:";
- temp = temp + std::to_string(nType);
- temp = temp + "----------------------";
- OutputDebugString(temp.c_str());
- WriteNotifyMessageToShareMemory(nType, 224, uintParam, nullptr, 0);
- break;
- }
- }
- /***
- ** 检测接口是否有错误,true:有错;false:没错
- ***/
- bool CKonicaObject::TestError(int nRet, const char* szFuncName, bool bShowTrue)
- {
- char temp[1024] = { 0 };
- if (nRet == AEROSDK_OK)
- {
- if (bShowTrue)
- {
- sprintf(temp, "%s executed successfully----------------------", szFuncName);
- OutputDebugString(temp);
- }
- return false;
- }
- else
- {
- char strPanelErrorInfo[16] = { 0 };
- char strXgboxErrorInfo[16] = { 0 };
- AerosdkGetPanelLastError((char*)m_strPanelType.c_str(), strPanelErrorInfo);
- AerosdkGetXgboxLastError(m_nXgboxNo, strXgboxErrorInfo);
-
- sprintf(temp,"{%s} return error, error code:{%d}, panel error info:{%s}, xgbox error info:{%s}----------------------",
- szFuncName, nRet, strPanelErrorInfo, strXgboxErrorInfo);
- OutputDebugString(temp);
- return true;
- }
- }
- STDMETHODIMP CKonicaObject::OpenSdk()
- {
- OutputDebugString("OpenSdk----------------------");
- if (!m_bOpenSdk)
- {
- int nRet = AerosdkOpen(AeroSDKCallBack, strAeroSDKini, AEROSDK_ON, &m_stLogInfo);
- if (nRet == AEROSDK_ERROR_OPEN_ALREADY)
- {
- m_bOpenSdk = true;
- return S_OK;
- }
- if (TestError(nRet, "API_AerosdkOpen"))
- {
- return S_FALSE;
- }
- else
- {
- m_bOpenSdk = true;
- }
- }
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::OpenPanel()
- {
- OutputDebugString("OpenPanel----------------------");
- if (!m_bConnect)
- {
- int nRet = AerosdkOpenPanel((char*)m_strPanelType.c_str(), NULL, NULL, strPanelLog, NULL);
- if (nRet == AEROSDK_ERROR_PANEL_OPEN_ALREADY)
- {
- m_bConnect = true;
- return S_OK;
- }
- if (TestError(nRet, "API_AerosdkOpenPanel"))
- {
- return S_FALSE;
- }
- }
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::OpenXgBox(int nXgBoxNo)
- {
- OutputDebugString("OpenXgBox----------------------");
- m_nXgboxNo = nXgBoxNo;
- /*if (!m_bConnectXgbox)
- {*/
- int nRet = AerosdkOpenXgbox(m_nXgboxNo, NULL, strECBLog, strXGBOXLog, NULL);
- if (nRet == AEROSDK_ERROR_XGBOX_DOUBLE_OPEN)
- {
- OutputDebugString("Xgbox double open----------------------");
- m_bConnectXgbox = true;
- return S_OK;
- }
- else if (nRet == AEROSDK_WARN_RETRY)
- {
- //SDK retrying connection
- OutputDebugString("SDK Retrying Open Xgbox----------------------");
- }
- else
- {
- if (TestError(nRet, "API_AerosdkOpenXgbox"))
- {
- return S_FALSE;
- }
- }
- //}
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::CloseSdk()
- {
- OutputDebugString("CloseSdk----------------------");
-
- int nRet = AerosdkClose(AEROSDK_OFF, AEROSDK_OFF);
- if (TestError(nRet, "API_AerosdkClose"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::ClosePanel()
- {
- OutputDebugString("ClosePanel----------------------");
-
- int nRet = AerosdkClosePanel((char*)m_strPanelType.c_str());
- if (TestError(nRet, "API_AerosdkClosePanel"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::CloseXgBox()
- {
- OutputDebugString("CloseXgBox----------------------");
-
- int nRet = AerosdkCloseXgbox(m_nXgboxNo);
- if (TestError(nRet, "API_AerosdkCloseXgbox"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- //设置当前探测器使用的分辨率
- STDMETHODIMP CKonicaObject::SetPanelResolution(int nResolution)
- {
- m_nResolution = nResolution;
- char temp[512] = { 0 };
- sprintf(temp, "SetPanelResolution nResolution:%d----------------------", nResolution);
- OutputDebugString(temp);
- /*int nRet = AerosdkSetPanelResolution((char*)m_strPanelType.c_str(), m_nResolution);
- if (TestError(nRet, "AerosdkSetPanelResolution"))
- {
- return S_FALSE;
- }*/
- return S_OK;
- }
- //主要用于区分是否支持正常分辨率和高分辨率,并不是当前探测器使用的分辨率
- STDMETHODIMP CKonicaObject::GetPanelResolution(int* pResolution)
- {
- OutputDebugString("GetPanelResolution----------------------");
- int nRet = AerosdkGetPanelResolutionInfo((char*)m_strPanelType.c_str(), pResolution);
- if (TestError(nRet, "AerosdkGetPanelResolutionInfo"))
- {
- return S_FALSE;
- }
- char temp[512] = { 0 };
- sprintf(temp,"GetPanelResolution resolution:%d----------------------",*pResolution);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetImageSize(int nSizeMode, int nResolution, int* pWidth, int* pHeight)
- {
- OutputDebugString("GetImageSize----------------------");
- char temp[512] = { 0 };
- int nRet = AerosdkGetImageSizeEx((char*)m_strPanelType.c_str(), nSizeMode, nResolution, pWidth, pHeight);
- if (TestError(nRet, "API_AerosdkGetImageSizeEx"))
- {
- return S_FALSE;
- }
- if (AEROSDK_IMAGE_PREVIEW == nSizeMode)
- {
- m_nPreImgWidth = *pWidth;
- m_nPreImgHeight = *pHeight;
- sprintf(temp, "m_nPreImgWidth:%d,m_nPreImgHeight:%d----------------------", m_nPreImgWidth, m_nPreImgHeight);
- OutputDebugString(temp);
- }
- else if (AEROSDK_IMAGE_EXPOSURE == nSizeMode)
- {
- m_nRawImgWidth = *pWidth;
- m_nRawImgHeight = *pHeight;
- sprintf(temp, "m_nRawImgWidth:%d,m_nRawImgHeight:%d----------------------", m_nRawImgWidth, m_nRawImgHeight);
- OutputDebugString(temp);
- }
- else
- {
- return S_FALSE;
- }
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetPanelSettingInfo(CHAR* strPanelID, int* nPanelSize)
- {
- OutputDebugString("GetPanelSettingInfo----------------------");
- StAerosdkPanelSettingInfo settingInfo;
- int nRet = AerosdkGetPanelSettingInfo((char*)m_strPanelType.c_str(), &settingInfo);
- if (TestError(nRet, "API_AerosdkGetPanelSettingInfo"))
- {
- return S_FALSE;
- }
- memcpy(strPanelID, settingInfo.strPanelId, sizeof(settingInfo.strPanelId));
- *nPanelSize = settingInfo.intPanelSize;
- char temp[512] = { 0 };
- sprintf(temp, "strPanelID:%s,nPanelSize:%d----------------------", strPanelID, *nPanelSize);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetPanelVersionInfo(unsigned char* pDllVersion, unsigned char* pAllVersion, unsigned char* pFwComnBootVersion, unsigned char* pFwComnVersion, unsigned char* pFwPowerBootVersion, unsigned char* pFwPowerVersion, unsigned char* pFpgaVersion)
- {
- OutputDebugString("GetPanelVersionInfo----------------------");
- StAerosdkPanelVersionInfo versionInfo;
- int nRet = AerosdkGetPanelVersionInfo((char*)m_strPanelType.c_str(), &versionInfo);
- if (TestError(nRet, "API_AerosdkGetPanelVersionInfo"))
- {
- return S_FALSE;
- }
- memcpy(pDllVersion, versionInfo.ucharDllVersion, sizeof(versionInfo.ucharDllVersion));
- memcpy(pAllVersion, versionInfo.ucharAllVersion, sizeof(versionInfo.ucharAllVersion));
- memcpy(pFwComnBootVersion, versionInfo.ucharFwComnBootVersion, sizeof(versionInfo.ucharFwComnBootVersion));
- memcpy(pFwComnVersion, versionInfo.ucharFwComnVersion, sizeof(versionInfo.ucharFwComnVersion));
- memcpy(pFwPowerBootVersion, versionInfo.ucharFwPowerBootVersion, sizeof(versionInfo.ucharFwPowerBootVersion));
- memcpy(pFwPowerVersion, versionInfo.ucharFwPowerVersion, sizeof(versionInfo.ucharFwPowerVersion));
- memcpy(pFpgaVersion, versionInfo.ucharFpgaVersion, sizeof(versionInfo.ucharFpgaVersion));
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetPanelConservationInfo(unsigned int* pShootCount)
- {
- OutputDebugString("GetPanelConservationInfo----------------------");
- int nRet = AerosdkGetPanelConservationInfo((char*)m_strPanelType.c_str(), pShootCount);
- if (TestError(nRet, "API_AerosdkGetPanelConservationInfo"))
- {
- return S_FALSE;
- }
- char temp[512] = { 0 };
- sprintf(temp, "nShootCount:%d----------------------", *pShootCount);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetCradleConservationInfo(int* pConnectCount)
- {
- OutputDebugString("GetCradleConservationInfo----------------------");
- int nRet = AerosdkGetCradleConservationInfo((char*)m_strPanelType.c_str(), pConnectCount);
- if (TestError(nRet, "API_AerosdkGetCradleConservationInfo"))
- {
- return S_FALSE;
- }
- char temp[512] = { 0 };
- sprintf(temp, "nConnectCount:%d----------------------", *pConnectCount);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::StartExposureSequenceIt(int nXgBoxNo, int nImageNo, int nSyncMode, int nIntegrationTime)
- {
- OutputDebugString("StartExposureSequenceIt----------------------");
- m_nImageNo = nImageNo;
- char temp[512] = { 0 };
- sprintf(temp, "StartExposureSequenceIt nXgBoxNo:%d,nImageNo:%d,nSyncMode:%d,nIntegrationTime:%d----------------------", nXgBoxNo, nImageNo, nSyncMode, nIntegrationTime);
- OutputDebugString(temp);
- int nRet = AEROSDK_OK;
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "StartExposureSequenceIt m_nResolution:%d----------------------", m_nResolution);
- OutputDebugString(temp);
- //开始采集前设置分辨率
- OutputDebugString("Call AerosdkSetPanelResolution----------------------");
- nRet = AerosdkSetPanelResolution((char*)m_strPanelType.c_str(), m_nResolution);
- if (TestError(nRet, "AerosdkSetPanelResolution"))
- {
- return S_FALSE;
- }
- if (nSyncMode == AEROSDK_COOPERATION_SRM)//硬同步
- {
- StAerosdkXgboxStatusInfo xgboxStatusInfo;
- nRet = AerosdkGetXgboxStatusInfo(nXgBoxNo,1,&xgboxStatusInfo);
- if (TestError(nRet, "AerosdkGetXgboxStatusInfo"))
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "GetXgboxStatusInfo return error code:%d----------------------", nRet);
- OutputDebugString(temp);
- }
- else
- {
- if (xgboxStatusInfo.intCrMode == AEROSDK_ON)
- {
- OutputDebugString("Xgbox is CR mode----------------------");
- }
- else
- {
- OutputDebugString("Xgbox is DR mode----------------------");
- }
- }
- }
- nRet = AerosdkStartExposureSequenceIt((char*)m_strPanelType.c_str(), nXgBoxNo, nImageNo, nSyncMode, nIntegrationTime, AEROSDK_MOVEMODE_NORMAL);
- if (TestError(nRet, "AerosdkStartExposureSequenceIt"))
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp,"StartExposureSequenceIt return error code:%d----------------------",nRet);
- OutputDebugString(temp);
- return S_FALSE;
- }
- return S_OK;
- }
- string CKonicaObject::GetStrPanelStatus(int nPanelStatus)
- {
- string temp = "";
- switch (nPanelStatus)
- {
- case AEROSDK_PANEL_STATUS_INITIALIZE:
- temp = "AEROSDK_PANEL_STATUS_INITIALIZE";
- break;
- case AEROSDK_PANEL_STATUS_SLEEP:
- temp = "AEROSDK_PANEL_STATUS_SLEEP";
- break;
- case AEROSDK_PANEL_STATUS_STANDBY:
- temp = "AEROSDK_PANEL_STATUS_STANDBY";
- break;
- case AEROSDK_PANEL_STATUS_READY:
- temp = "AEROSDK_PANEL_STATUS_READY";
- break;
- case AEROSDK_PANEL_STATUS_EXPOSURE:
- temp = "AEROSDK_PANEL_STATUS_EXPOSURE";
- break;
- case AEROSDK_PANEL_STATUS_SHUTDOWN:
- temp = "AEROSDK_PANEL_STATUS_SHUTDOWN";
- break;
- case AEROSDK_PANEL_STATUS_UPDATE:
- temp = "AEROSDK_PANEL_STATUS_UPDATE";
- break;
- case AEROSDK_PANEL_STATUS_MAINTENANCE:
- temp = "AEROSDK_PANEL_STATUS_MAINTENANCE";
- break;
- case AEROSDK_PANEL_STATUS_WAIT_READY:
- temp = "AEROSDK_PANEL_STATUS_WAIT_READY";
- break;
- case AEROSDK_PANEL_STATUS_READOUT:
- temp = "AEROSDK_PANEL_STATUS_READOUT";
- break;
- case AEROSDK_PANEL_STATUS_ERROR:
- temp = "AEROSDK_PANEL_STATUS_ERROR";
- break;
- case AEROSDK_PANEL_STATUS_UNKNOWN:
- temp = "AEROSDK_PANEL_STATUS_UNKNOWN";
- break;
- }
- return temp;
- }
- STDMETHODIMP CKonicaObject::GetPanelStatusInfo(int* pPanelStatus)
- {
- OutputDebugString("GetPanelStatusInfo----------------------");
- int nRet = AerosdkGetPanelStatusInfo((char*)m_strPanelType.c_str(), pPanelStatus);
- if (TestError(nRet, "AerosdkGetPanelStatusInfo"))
- {
- return S_FALSE;
- }
- int nPanelStatus = *pPanelStatus;
- string strPanelStatus = GetStrPanelStatus(nPanelStatus);
- char temp[512] = { 0 };
- sprintf(temp, "PanelStatus:%s----------------------", strPanelStatus.c_str());
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::CancelExposureSequence(int nImageNo)
- {
- OutputDebugString("CancelExposureSequence----------------------");
- char temp[512] = { 0 };
- sprintf(temp, "nImageNo:%d----------------------", nImageNo);
- OutputDebugString(temp);
- int nRet = AerosdkCancelExposureSequence((char*)m_strPanelType.c_str(), nImageNo);
- if (TestError(nRet, "API_AerosdkCancelExposureSequence"))
- {
- return S_FALSE;
- }
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::SetSyncMode(int nSyncMode)
- {
- OutputDebugString("SetSyncMode----------------------");
- m_nSyncMode = nSyncMode;
- char temp[512] = { 0 };
- sprintf(temp, "m_nSyncMode:%d----------------------", m_nSyncMode);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetPanelBatteryInfo(int* pBatteryValue, int* pBatteryStatus)
- {
- OutputDebugString("GetPanelBatteryInfo----------------------");
- int nRet = AerosdkGetPanelBatteryInfo((char*)m_strPanelType.c_str(), pBatteryValue, pBatteryStatus);
- if (TestError(nRet, "API_AerosdkGetPanelBatteryInfo"))
- {
- return S_FALSE;
- }
- char temp[512] = { 0 };
- sprintf(temp, "BatteryValue:%d,BatteryStatus:%d----------------------", *pBatteryValue, *pBatteryStatus);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetPanelSignalInfo(int* pSignalStrength)
- {
- OutputDebugString("GetPanelSignalInfo----------------------");
- int nRet = AerosdkGetPanelSignalInfo((char*)m_strPanelType.c_str(), pSignalStrength);
- if (TestError(nRet, "API_AerosdkGetPanelSignalInfo"))
- {
- return S_FALSE;
- }
- char temp[512] = { 0 };
- sprintf(temp, "SignalStrength:%d----------------------", *pSignalStrength);
- OutputDebugString(temp);
- return S_OK;
- }
- STDMETHODIMP CKonicaObject::GetQueueData(int* pMessageType)
- {
- std::lock_guard<std::mutex> lock(mtx);
- if (!m_queue.empty())
- {
- int type = m_queue.front();
- *pMessageType = type;
- m_queue.pop();
- return S_OK;
- }
- else
- {
- return S_FALSE;
- }
- }
- void CKonicaObject::SaveRawFunc(WORD* pInImg,char* strFileName, int nImgWidth, int nImgHeight)
- {
- FILE* fp;
- std::string fileName = strFileName;
- fileName = fileName + "----------------------";
- OutputDebugString(fileName.c_str());
- if ((fp = fopen(strFileName, "wb")) == NULL)
- {
- DWORD dw = GetLastError();
- char temp[512] = { 0 };
- sprintf(temp, "fopen {%s} failed, error code:{%ld}", strFileName, dw);
- OutputDebugString(temp);
- return;
- }
- fwrite(pInImg, sizeof(WORD), (size_t)nImgWidth * (size_t)nImgHeight, fp);
- fclose(fp);
- OutputDebugString("Save image over----------------------");
- }
- STDMETHODIMP CKonicaObject::CheckImageEx(int* pImageNo, int* pResolution)
- {
- unsigned int nInputImageNo = 0;
- int nResolution = 0;//AEROSDK_RESOLUTION_NORMAL AEROSDK_RESOLUTION_HIGH
- int nRet = 0;
- char temp[256] = { 0 };
- OutputDebugString("CheckImageEx----------------------");
- nRet = AerosdkCheckImageEx((char*)m_strPanelType.c_str(), &nInputImageNo, &nResolution);
- if (TestError(nRet, "AerosdkCheckImageEx"))
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "CheckImageEx return error code:%d----------------------", nRet);
- OutputDebugString(temp);
- return S_FALSE;
- }
- else
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "CheckImageEx nInputImageNo:%d,nResolution:%d----------------------", nInputImageNo, nResolution);
- OutputDebugString(temp);
- *pImageNo = nInputImageNo;
- if (nInputImageNo)
- {
- *pResolution = nResolution;
- OutputDebugString("Have image in detector!----------------------");
- m_bHaveImageInDetector = true;
- /*if (ImageResend(nInputImageNo))
- {
- OutputDebugString("ImageResend Success!----------------------");
- }
- else
- {
- OutputDebugString("ImageResend Fail!----------------------");
- return S_FALSE;
- }*/
- if (ImageDelete(nInputImageNo))
- {
- OutputDebugString("ImageDelete Success!----------------------");
- }
- else
- {
- OutputDebugString("ImageDelete Fail!----------------------");
- return S_FALSE;
- }
- }
- else
- {
- OutputDebugString("NO image in detector!----------------------");
- }
- return S_OK;
- }
- }
- bool CKonicaObject::ImageResend(int nImageNo)
- {
- char temp[256] = { 0 };
- sprintf(temp, "ImageResend nImageNo:%d----------------------", nImageNo);
- OutputDebugString(temp);
- int nRet = 0;
- if (m_nSyncMode == SYNC_HARDWARE)
- {
- nRet = AerosdkStartImageResendingSequenceWithMode((char*)m_strPanelType.c_str(), nImageNo, AEROSDK_COOPERATION_SRM);// Triggered
- }
- else if (m_nSyncMode == SYNC_AED)
- {
- nRet = AerosdkStartImageResendingSequenceWithMode((char*)m_strPanelType.c_str(), nImageNo, AEROSDK_COOPERATION_AEROSYNC);// AeroSync
- }
- else
- {
- OutputDebugString("Wrong sync mode!----------------------");
- return false;
- }
- if (TestError(nRet, "AerosdkStartImageResendingSequenceWithMode"))
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "ImageResendingSequence return error code:%d----------------------", nRet);
- OutputDebugString(temp);
- return false;
- }
- bool bRet = WaitRespond(20000, "ImageResendingSequence");
- if (!bRet)
- {
- return false;
- }
- return true;
- }
- bool CKonicaObject::ImageDelete(int nImageNo)
- {
- char temp[256] = { 0 };
- sprintf(temp, "ImageDelete nImageNo:%d----------------------", nImageNo);
- OutputDebugString(temp);
- int nRet = 0;
- nRet = AerosdkStartImageDeleteSequence((char*)m_strPanelType.c_str(), nImageNo);
- if (TestError(nRet, "AerosdkStartImageDeleteSequence"))
- {
- memset(temp, 0, sizeof(temp));
- sprintf(temp, "ImageDeleteSequence return error code:%d----------------------", nRet);
- OutputDebugString(temp);
- return false;
- }
- bool bRet = WaitRespond(10000, "ImageDeleteSequence");
- if (!bRet)
- {
- return false;
- }
- return true;
- }
|