12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526 |
- // KonicaObject2.cpp: CKonicaObject2 的实现
- #include "pch.h"
- #include "KonicaObject2.h"
- #include <comutil.h>
- #pragma comment(lib, "comsuppw.lib")
- #define IMAGE_START_ADDRESS 500
- CKonicaObject2* 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);
- }
- }
- // CKonicaObject2
- CKonicaObject2::CKonicaObject2()
- {
- m_pDataBuffer = nullptr;
- m_pDataBuffer = new CShareMem("KonicaDetectorBuffer2");
- 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----------------------");
- }
- CKonicaObject2::~CKonicaObject2()
- {
- 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 CKonicaObject2::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 CKonicaObject2::StopWaiting(const char* szAction)
- {
- char temp[512] = { 0 };
- sprintf("--- Stop waiting respond, {%s}----------------------", szAction);
- OutputDebugString(temp);
- SetEvent(m_hRespond);
- }
- STDMETHODIMP CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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----------------------");
- 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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::CloseSdk()
- {
- OutputDebugString("CloseSdk----------------------");
-
- int nRet = AerosdkClose(AEROSDK_OFF, AEROSDK_OFF);
- if (TestError(nRet, "API_AerosdkClose"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject2::ClosePanel()
- {
- OutputDebugString("ClosePanel----------------------");
-
- int nRet = AerosdkClosePanel((char*)m_strPanelType.c_str());
- if (TestError(nRet, "API_AerosdkClosePanel"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- STDMETHODIMP CKonicaObject2::CloseXgBox()
- {
- OutputDebugString("CloseXgBox----------------------");
-
- int nRet = AerosdkCloseXgbox(m_nXgboxNo);
- if (TestError(nRet, "API_AerosdkCloseXgbox"))
- {
- return S_FALSE;
- }
-
- return S_OK;
- }
- //设置当前探测器使用的分辨率
- STDMETHODIMP CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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 CKonicaObject2::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;
- }
|