123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include <DateUtils.hpp>
- #include "PacketHandllingF.h"
- #include "ClientSessionF.h"
- #include "VMSCommLibF.h"
- #include "CenterCommF.h"
- //---------------------------------------------------------------------------
- #define TERROR(args...) ASession->SysLogWrite(eLOG_ERROR, ##args)
- #define TDEBUG(args...) ASession->LogWrite(eLOG_DEBUG, ##args)
- #define TINFO(args...) ASession->LogWrite(eLOG_INFO, ##args)
- #define OK_DEBUG 0
- #pragma package(smart_init)
- extern const unsigned short g_crc16_table[256] =
- {
- 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
- 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
- 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
- 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
- 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
- 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
- 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
- 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
- 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
- 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
- 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
- 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
- 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
- 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
- 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
- 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
- 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
- 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
- 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
- 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
- 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
- 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
- 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
- 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
- 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
- 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
- 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
- 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
- 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
- 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
- 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
- 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
- };
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- static WORD GETCRC16(char *AData, int ALen)
- {
- WORD crc = 0;
- for (int ii = 0; ii < ALen; ii++)
- {
- crc = ( (crc >> 8) ^ g_crc16_table[(crc ^ AData[ii]) & 0x0ff] );
- }
- return crc;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- typedef int (*RecvPktHandlerFunc)(TClientSession *ASession, BYTE *AData, int APktLen);
- //---------------------------------------------------------------------------
- static int UnknownPktHandler(TClientSession *ASession, BYTE *AData, int APktLen)
- {
- if (ASession->CDSLogCtlr)
- {
- TERROR("+CLI Invalid packet handler: %s. will be closed.", ASession->IpAddress.c_str());
- }
- VMS_HEAD *pHd = (VMS_HEAD*)AData;
- if (!pHd) return -1;
- MERROR("+CLI Invalid packet handler: %s. 0x%02X, will be closed.", ASession->IpAddress.c_str(), pHd->OpCode);
- ASession->LogData("RECV", (BYTE*)ASession->GetRecvBuff(), APktLen);
- ASession->Disconnect();
- return -1;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- static RecvPktHandlerFunc G_FuncPktHandler[e_vms_MAX] = {NULL};
- //---------------------------------------------------------------------------
- struct _init_pkt_handler
- {
- //정적 패킷핸들러 함수 초기화
- _init_pkt_handler()
- {
- for (int ii = 0; ii < e_vms_MAX; ii++)
- {
- G_FuncPktHandler[ii] = UnknownPktHandler;
- }
- }
- };
- static _init_pkt_handler init_pkt_handler;
- //---------------------------------------------------------------------------
- struct RegisterHandler
- {
- RegisterHandler(BYTE AOpCode, RecvPktHandlerFunc AFuncHandler)
- {
- G_FuncPktHandler[(int)AOpCode] = AFuncHandler;
- }
- };
- //---------------------------------------------------------------------------
- #define REGISTER_HANDLER(PKT_TYPE) \
- static int Handler_##PKT_TYPE(TClientSession* ASession, BYTE *AData, int APktLen); \
- static RegisterHandler _register_##PKT_TYPE(PKT_TYPE, Handler_##PKT_TYPE); \
- static int Handler_##PKT_TYPE(TClientSession* ASession, BYTE *AData, int APktLen)
- void CALLBACK RecvCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags)
- {
- TClientSession *pSession = static_cast<OverlappedIO*>(lpOverlapped)->FSession;
- if (!pSession->IsConnected)
- {
- MERROR("+SVR RecvCompletion(IsConnected false): %s[%d]", pSession->IpAddress.c_str(), pSession->Socket);
- return;
- }
- /// 에러 발생시 해당 세션 종료
- if (dwError || cbTransferred == 0)
- {
- MERROR("+SVR RecvCompletion(dwError || cbTransferred==0): %s[%d], will be closed", pSession->IpAddress.c_str(), pSession->Socket);
- pSession->Disconnect();
- return;
- }
- /// 받은 데이터 처리
- pSession->OnRead(cbTransferred);
- }
- //---------------------------------------------------------------------------
- #if 0
- void CALLBACK SendCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags)
- {
- TClientSession *pSession = static_cast<OverlappedIO*>(lpOverlapped)->FSession;
- if (!pSession->IsConnected)
- {
- MERROR("+SVR SendCompletion(IsConnected false): %s[%d]", pSession->IpAddress.c_str(), pSession->Socket);
- return;
- }
- /// 에러 발생시 해당 세션 종료
- if (dwError || cbTransferred == 0)
- {
- MERROR("+SVR SendCompletion(dwError || cbTransferred==0): %s[%d], will be closed", pSession->IpAddress.c_str(), pSession->Socket);
- pSession->Disconnect();
- return;
- }
- pSession->OnWriteComplete(cbTransferred, cbTransferred);
- }
- //---------------------------------------------------------------------------
- #endif
- static TCDSCtlr* FindControllerByIpAddr(AnsiString AIpAddress)
- {
- CtlrItr it;
- for(it=CDSCtlrManager->FLists.FObjects.begin(); it != CDSCtlrManager->FLists.FObjects.end(); ++it)
- {
- TCDSCtlr *pObj = (TCDSCtlr*)it->second;
- if (!pObj->Used) continue;
- if (pObj->CTLR_IP.AnsiCompare(AIpAddress) == 0)
- {
- return pObj;
- }
- }
- return NULL;
- }
- //---------------------------------------------------------------------------
- static TCDSCtlr* FindControllerById(AnsiString ACtrlNmbrId)
- {
- CtlrItr it;
- for(it=CDSCtlrManager->FLists.FObjects.begin(); it != CDSCtlrManager->FLists.FObjects.end(); ++it)
- {
- TCDSCtlr *pObj = (TCDSCtlr*)it->second;
- if (!pObj->Used) continue;
- if (pObj->CTLR_NMBR_ID.AnsiCompare(ACtrlNmbrId) == 0)
- {
- return pObj;
- }
- }
- return NULL;
- }
- //---------------------------------------------------------------------------
- static int RequestJob(TClientSession *ASession, int AJob, char *AData, int ALen)
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- pMsg->Type = AJob;
- pMsg->ObjPtr = (DWORD)ASession;
- if (ALen > 0)
- {
- memcpy(pMsg->Buff, AData, ALen);
- }
- pMsg->Len = ALen;
- g_jobQ.PushBlocking((DWORD)pMsg);
- return 0;
- }
- //---------------------------------------------------------------------------
- bool TClientSession::SendPacketDleStuffing(char *AData, int ADataLen)
- {
- int nSendLen;
- int nLen;
- WORD crc;
- BYTE c;
- BYTE *msgPrt;
- BYTE *pData;
- msgPrt = FMsgBuff;
- pData = AData;
- nLen = ADataLen;
- crc = GETCRC16(pData, nLen);
- *msgPrt++ = VMS_DLE;
- *msgPrt++ = VMS_STX;
- // DLE Stuffing
- for (int ii = 0; ii < ADataLen; ii++)
- {
- *msgPrt++ = AData[ii];
- if (pData[ii] == VMS_DLE)
- {
- *msgPrt++ = VMS_DLE;
- }
- }
- *msgPrt++ = VMS_DLE;
- *msgPrt++ = VMS_ETX;
- *msgPrt++ = HIBYTE(crc);
- *msgPrt++ = LOBYTE(crc);
- nSendLen = msgPrt - FMsgBuff;
- if (!SendRequest((char*)FMsgBuff, nSendLen))
- {
- SERROR("+CLI SendPacketDleStuffing send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- MERROR("+CLI SendPacketDleStuffing send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- Disconnect();
- return false;
- }
- return SendFlushComplete();
- }
- //---------------------------------------------------------------------------
- bool TClientSession::SendPacketDLE(char *AData, int ADataLen, bool AIsDle)
- {
- int nSendLen;
- int nLen;
- BYTE c;
- BYTE *msgPrt;
- BYTE *pData;
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- msgPrt = (BYTE*)pMsg->Buff;
- pData = AData;
- *msgPrt++ = AData[0];
- *msgPrt++ = AData[1];
- // DLE Stuffing
- for (int ii = 2; ii < ADataLen-4; ii++)
- {
- *msgPrt++ = AData[ii];
- if (AIsDle && pData[ii] == VMS_DLE)
- {
- *msgPrt++ = VMS_DLE;
- }
- }
- *msgPrt++ = AData[ADataLen-4]; // DLE
- *msgPrt++ = AData[ADataLen-3]; // ETX
- *msgPrt++ = AData[ADataLen-2]; // CRC
- *msgPrt++ = AData[ADataLen-1]; // CRC
- nSendLen = msgPrt - (BYTE*)pMsg->Buff;
- pMsg->Type = eVmsSendPacket;
- pMsg->ObjPtr = (DWORD)this;
- pMsg->Len = nSendLen;
- g_jobQ.PushBlocking((DWORD)pMsg);
- Sleep(20);
- return true;
- }
- //---------------------------------------------------------------------------
- bool TClientSession::SendPacket(char *AData, int ADataLen)
- {
- int nSendLen;
- int nLen;
- WORD crc;
- BYTE c;
- BYTE *msgPtr;
- BYTE *pData;
- msgPtr = FMsgBuff;
- pData = AData;
- nLen = ADataLen;
- crc = GETCRC16(pData, nLen);
- *msgPtr++ = VMS_DLE;
- *msgPtr++ = VMS_STX;
- // DLE Stuffing
- for (int ii = 0; ii < ADataLen; ii++)
- {
- *msgPtr++ = AData[ii];
- if (pData[ii] == VMS_DLE)
- {
- *msgPtr++ = VMS_DLE;
- }
- }
- *msgPtr++ = VMS_DLE;
- *msgPtr++ = VMS_ETX;
- *msgPtr++ = HIBYTE(crc);
- *msgPtr++ = LOBYTE(crc);
- nSendLen = msgPtr - FMsgBuff;
- if (!SendRequest((char*)FMsgBuff, nSendLen))
- {
- SERROR("+CLI SendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- MERROR("+CLI SendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- Disconnect();
- return false;
- }
- return true;
- #if 0
- int nSendLen;
- int nLen;
- WORD crc;
- BYTE c;
- BYTE *msgPtr;
- BYTE *pData;
- msgPtr = FMsgBuff;
- pData = AData;
- nLen = ADataLen;
- crc = GETCRC16(pData, nLen);
- msgPtr[0] = VMS_DLE;
- msgPtr[1] = VMS_STX;
- if (ADataLen > 0)
- {
- memcpy(&msgPtr[2], AData, ADataLen);
- }
- msgPtr[ADataLen+2] = VMS_DLE;
- msgPtr[ADataLen+3] = VMS_ETX;
- msgPtr[ADataLen+4] = HIBYTE(crc);
- msgPtr[ADataLen+5] = LOBYTE(crc);
- #if 0
- for (int ii = 0; ii < ADataLen; ii++)
- {
- *msgPrt++ = AData[ii];
- #if 0
- if (pData[ii] == VMS_DLE)
- {
- *msgPrt++ = VMS_DLE;
- }
- #endif
- }
- #endif
- nSendLen = ADataLen + 6;
- if (!SendRequest((char*)msgPtr, nSendLen))
- {
- SERROR("+CLI SendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- MERROR("+CLI SendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), AData[4]);
- Disconnect();
- return false;
- }
- return true;
- #endif
- }
- //---------------------------------------------------------------------------
- bool TClientSession::CheckLoginClient()
- {
- TCDSCtlr *pCDSCtlr = FindControllerByIpAddr(FIpAddress);
- if (!pCDSCtlr)
- {
- MERROR("+CLI Unknown client address: %s. will be closed.", FIpAddress.c_str());
- return false;
- }
- //이전 접속정보가 있는지 확인한다.
- if (FCDSCtlr)
- {
- TClientSession *pSession = FCDSCtlr->FSession;
- if (pSession)
- {
- //이전 접속을 종료하고 현재 접속을 새로운 VMS 제어기 통신으로 사용한다.
- MERROR("+CLI Client allready connect: %s. old connection will be closed.", FIpAddress.c_str());
- pSession->Disconnect();
- }
- }
- FState = eSS_LoginReq; //최초접속후 폼을 다운로드 하기위해 사용할 플래그(기존에는 로그인체크용으로 사용)
- FCDSCtlr = pCDSCtlr;
- FCDSLogCtlr = pCDSCtlr;
- FCDSCtlr->FSession = this;
- FCDSCtlr->LOGIN_IPADDR = FIpAddress; //연결된 IP주소 설정
- FCDSCtlr->Server.commState = comm_open;
- FCDSCtlr->Server.ConnectTm = Now().FormatString("yyyy-MM-dd hh:nn:ss");
- FCtlrId.printf("%10.010d", FCDSCtlr->CTLR_NMBR.ToIntDef(0));
- POST_MSG(MAINHANDLE, WM_TCP_THREAD, WM_TCP_SERVER_STTS, (int)pCDSCtlr);
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // 최초에 폼정보를 모두 다운로드 해버리자.(TODO: 메모리 할당이 위에서 끝난다음에 초기화해야함)
- FCDSCtlr->InitDownloadFileInfo();
- //최초에 상태정보를 요청하고 상태정보요청 응답이 완료되면 시나리오를 다운로드 하자.
- RequestJob(this, eVmsStatusReq, NULL, 0);
- return true;
- }
- //---------------------------------------------------------------------------
- bool TClientSession::OnDisconnected()
- {
- if (FCDSCtlr)
- {
- if (FCDSCtlr->IsVideo) {
- FCDSCtlr->InitFtpFileInfo(); // TODO: FTP 다운로드 정보를 초기화 한다.
- }
- FCDSCtlr->Server.DisconnectTm = Now().FormatString("yyyy-MM-dd hh:nn:ss");
- FCDSCtlr->Server.commState = comm_close;
- FCDSCtlr->FSession = NULL;
- //FCDSCtlr->LOGIN_IPADDR = "";
- LERROR("VMS %s disconnected.", CtlrId.c_str());
- MERROR("%s.%d, VMS %s disconnected.", FIpAddress.c_str(), FSocket, CtlrId.c_str());
- TCDSCtlr* pCDSCtlr = FCDSCtlr;
- POST_MSG(MAINHANDLE, WM_TCP_THREAD, WM_TCP_SERVER_STTS, (int)pCDSCtlr);
- }
- else
- {
- MERROR("%s.%d, disconnected.", FIpAddress.c_str(), FSocket);
- }
- FState = eSS_Disconnect;
- return true;
- }
- //---------------------------------------------------------------------------
- /*
- * 1개의 패킷을 모두 전송한 후 호출됨
- */
- void TClientSession::OnWrite(char *APktPtr, int ASendLen)
- {
- VMS_HEAD *pHd = (VMS_HEAD*)APktPtr;
- if (!pHd) return;
- if (ASendLen > 0)
- {
- LDEBUG("SEND: %d Bytes", ASendLen);
- LogData("SEND", APktPtr, ASendLen);
- }
- InfoPacket(pHd->OpCode, ASendLen, true, 0);
- #if 0
- switch(pHd->OpCode)
- {
- case VMS_ID_REQ: // 0xFF // server -> client
- case DNLD_SCENARIO_REQ: // 0x02 // server -> client
- case CTRL_RESET_REQ: // 0x03 // server -> client
- case DNLD_FILE_REQ: // 0x04 // server -> client
- case PARAMETER_REQ: // 0x05 // server -> client
- case CTRL_LED_POWER_REQ: // 0x06 // server -> client
- case CTRL_FAN_POWER_REQ: // 0x07 // server -> client
- case CTRL_BRGH_REQ: // 0x08 // server -> client
- case CTRL_CONFIG_REQ: // 0x09 // server -> client
- case CTRL_TIME_REQ: // 0x10 // server -> client
- FTmrSend = Now();
- if (FChkRecvTO == false)
- {
- FTmrRecv = Now();
- }
- FChkRecvTO = true;
- break;
- default:
- FChkRecvTO = false; // 0x01 // server -> client
- break;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- /*
- * 프로토콜에 따른 처리
- */
- void TClientSession::OnRead(int ALen)
- {
- int readIdx;
- int stuffing;
- int dleEtx;
- int msgSize;
- BYTE msgBuff[SESSION_SEND_BUFFER];
- BYTE data;
- WORD crc;
- VMS_RES_HEAD *pHead;
- FRecvIdx += ALen;
- if (FRecvIdx > 0)
- {
- LDEBUG("RECV: %d Bytes", FRecvIdx);
- LogData("RECV", (char*)FRecvBuff, FRecvIdx);
- }
- while(true)
- {
- if (FRecvIdx < (int)sizeof(VMS_HEAD))
- {
- break;
- }
- if (FRecvBuff[0] != VMS_DLE && FRecvBuff[1] != VMS_STX)
- {
- MERROR("+CLI Packet parsing data start command error: %s, 0x%02X, 0x%02X. will be closed.", FIpAddress.c_str(), FRecvBuff[0], FRecvBuff[1]);
- Disconnect();
- return;
- }
- readIdx = 0;
- stuffing = 0; // 연속된 DLE 데이터 체크, 1 이면 DLE Stuffing
- dleEtx = 0; // DLE_ETX, ETX를 체크하기 위함, 1 이고 ETX 데이터를 읽었으면 패킷의 마지막(DLE_ETX, ETX 데이터 임)
- msgSize = 0; // 순수 데이터 사이즈
- while (readIdx < FRecvIdx && msgSize < (int)sizeof(msgBuff))
- {
- data = FRecvBuff[readIdx++];
- if (data == VMS_DLE)
- {
- if (stuffing)
- {
- stuffing = 0;
- dleEtx = 0; // TODO
- }
- else
- {
- msgBuff[msgSize++] = data;
- stuffing = 1;
- dleEtx = 1;
- }
- }
- else
- if (data == VMS_ETX)
- {
- msgBuff[msgSize++] = data;
- if (dleEtx)
- {
- // 이전데이터가 DLE이고 현재 데이터가 ETX이면 패킷의 끝임.
- // 다음 2바이트는 CRC 데이터임, 남아 있는 데이터가 CRC 2바이트를 포함한 크기보다 작으면
- // 하나의 패킷을 완전히 수신하지 못한 것임
- if ((readIdx + 2) > FRecvIdx)
- {
- // 하나의 패킷을 읽지 못함
- return;
- }
- msgBuff[msgSize++] = FRecvBuff[readIdx++]; // CRC1
- msgBuff[msgSize++] = FRecvBuff[readIdx++]; // CRC2
- // 하나의 패킷을 완전히 읽었음.
- ResetPacket(readIdx); // 메모리에서 수신 인덱스 초기화
- #if 0
- // dle, stx 제외, dle,etx,crc(2) 제외
- crc = GETCRC16(&msgBuff[2], msgSize-2-sizeof(VMS_TAIL));
- if (msgBuff[readIdx-2] != HIBYTE(crc) || msgBuff[readIdx-1] != LOBYTE(crc))
- {
- MERROR("+CLI Packet parsing data crc error: %s, 0x%02X, 0x%02X, 0x%02X, 0x%02X. will be closed.",
- FIpAddress.c_str(), msgBuff[readIdx-2], msgBuff[readIdx-1], HIBYTE(crc), LOBYTE(crc));
- Disconnect();
- return;
- }
- #endif
- pHead = (VMS_RES_HEAD*)msgBuff;
- if (pHead->Length != msgSize-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL))
- {
- MERROR("+CLI Packet parsing data length error: %s, %d, %d. will be closed.",
- FIpAddress.c_str(), pHead->Length, msgSize-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL));
- ITSLog->LogData("RECV", FRecvBuff, FRecvIdx);
- if (FCDSCtlr != NULL && FCDSCtlr->FSLog->FLogCfg.Data) FCDSCtlr->FSLog->LogData("RECV", FRecvBuff, FRecvIdx);
- Disconnect();
- return;
- }
- InfoPacket(pHead->OpCode, msgSize, false, 0);
- if (G_FuncPktHandler[pHead->OpCode](this, msgBuff, msgSize) < 0)
- {
- Disconnect();
- return;
- }
- SendFlush();
- break;
- }
- else
- {
- dleEtx = 0;
- }
- }
- else
- {
- // 순수 데이터를 읽음
- msgBuff[msgSize++] = data;
- stuffing = 0;
- dleEtx = 0;
- }
- }
- if (readIdx >= FRecvIdx)
- {
- break;
- }
- }
- }
- //---------------------------------------------------------------------------
- template <class PKT_TYPE>
- bool TClientSession::ParsePacket(PKT_TYPE& pkt, int APktLen)
- {
- if (APktLen > FRecvIdx)
- {
- MERROR("+CLI ParsePacket Error: %s, PktLen: %d, RecvIdx: %d", FIpAddress.c_str(), APktLen, FRecvIdx);
- return false;
- }
- memcpy((char*)&pkt, FRecvBuff, APktLen);
- FRecvIdx -= APktLen;
- if (FRecvIdx > 0)
- {
- memmove(FRecvBuff, FRecvBuff+APktLen, FRecvIdx);
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TClientSession::InfoPacket(BYTE AOpCode, int ALen, bool ASend, int AResult/*=0*/)
- {
- TCDSCtlr* pCDSCtlr = FCDSLogCtlr;
- if (!pCDSCtlr) return -1;
- //if (!pCDSCtlr->FDispLog) return -1;
- //if (!g_LogCfg.Debug) return -1;
- if (!g_LogCfg.Info) return -1;
- AnsiString sCmd;
- switch(AOpCode)
- {
- case e_txt_disp_immediate_text:// = 0x02, // Display Immediate Text Opcode = 2 [0x02] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_disp_immediate_text";
- break;
- case e_txt_disp_immediate_graphic:// = 0x04, // Display Immediate graphics Opcode = 4 [0x04] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_disp_immediate_graphic";
- break;
- case e_txt_disp_lib_message:// = 0x06, // Display Library Message Opcode = 6 [0x06] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_disp_lib_message";
- break;
- case e_txt_download_message_lib:// = 0x08, // Download A Message Library Opcode = 8 [0x08] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_download_message_lib";
- break;
- case e_txt_download_full_graphic_lib:// = 0x0A, // Download Graphics Library Opcode = 10 [0x0A] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_download_full_graphic_lib";
- break;
- case e_txt_download_graphic_symb_lib:// = 0x0C, // Download Graphic Symbol Library Opcode = 12 [0x0C] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_download_graphic_symb_lib";
- break;
- case e_txt_display_schedule_msg:// = 0x0E, // Display Schedule Message Opcode = 14 [0x0E] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_display_schedule_msg";
- break;
- case e_txt_initialize:// = 0x12, // Initailize Opcode = 18 [0x12] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_initialize";
- break;
- case e_txt_disp_test_pattern:// = 0x14, // Display Test Pattern Opcode = 20 [0x14] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_disp_test_pattern";
- break;
- case e_txt_blank:// = 0x16, // Blank Opcode = 22 [0x16] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_blank";
- break;
- case e_txt_download_parameter:// = 0x1C, // Download Parameter Opcode = 28 [0x1C] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_download_parameter";
- break;
- case e_txt_display_default_msg:// = 0x1E, // Display Default Message Opcode = 30 [0x1E] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_display_default_msg";
- break;
- case e_txt_set_luminance_level:// = 0x20, // Set Luminance Level Opcode = 32 [0x20] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_set_luminance_level";
- break;
- case e_txt_signboard_control:// = 0x24, // Signboard Power Control Opcode = 36 [0x24] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_signboard_control";
- break;
- case e_txt_signboard_alarm_control:// = 0x2A, // Signboard Alarm Control Opcode = 42 [0x2A] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_signboard_alarm_control";
- break;
- case e_txt_pan_hetr_temp_control:// = 0x31, // 함체 PAN/HEATER 온도 설정 Opcode = 49 [0x31] ⇔ Opcode = 72 [0x48]
- sCmd = "txt_pan_hetr_temp_control";
- break;
- case e_txt_status_req:// = 0x18, // Status Request Opcode = 24 [0x18] ⇔ Opcode = 64 [0x40]
- sCmd = "txt_status_req";
- break;
- case e_txt_status_res:// = 0x40, // Status Response Opcode = 24 [0x18] ⇔ Opcode = 64 [0x40]
- sCmd = "txt_status_res";
- break;
- case e_txt_upload_modl_status_req:// = 0x28, // Upload Module Status Opcode = 40 [0x28] ⇔ Opcode = 74 [0x4A]
- sCmd = "txt_upload_modl_status_req";
- break;
- case e_txt_upload_modl_status_res:// = 0x4A, // Upload Module Status Opcode = 40 [0x28] ⇔ Opcode = 74 [0x4A]
- sCmd = "txt_upload_modl_status_res";
- break;
- case e_txt_pan_hetr_temp_req:// = 0x32, // 함체 PAN/HEATER 온도 요청 Opcode = 50 [0x32] ⇔ Opcode = 66 [0x42]
- sCmd = "txt_pan_hetr_temp_req";
- break;
- //case e_txt_pan_hetr_temp_res:// = 0x42, // 함체 PAN/HEATER 온도 요청 Opcode = 50 [0x32] ⇔ Opcode = 66 [0x42]
- // sCmd = "txt_pan_hetr_temp_res";
- // break;
- case e_txt_failed_elem_data_req:// = 0x1A, // Failed Element Data Request Opcode = 26 [0x1A] ⇔ Opcode = 66 [0x42]
- sCmd = "txt_failed_elem_data_req";
- break;
- case e_txt_failed_elem_data_res:// = 0x42, // Failed Element Data Response Opcode = 26 [0x1A] ⇔ Opcode = 66 [0x42]
- sCmd = "txt_failed_elem_data_res";
- break;
- case e_txt_upload_msg_req:// = 0x22, // Upload A Message Opcode = 34 [0x22] ⇔ Opcode = 68 [0x44]
- sCmd = "txt_upload_msg_req";
- break;
- case e_txt_upload_msg_res:// = 0x44, // Upload A Message Response Opcode = 34 [0x22] ⇔ Opcode = 68 [0x44]
- sCmd = "txt_upload_msg_res";
- break;
- case e_txt_upload_schedule_msg_req:// = 0x23, // Upload Schedule Message Opcode = 35 [0x23] ⇔ Opcode = 69 [0x45]
- sCmd = "txt_upload_schedule_msg_req";
- break;
- case e_txt_upload_schedule_msg_res:// = 0x45, // Upload Schedule Message Opcode = 35 [0x23] ⇔ Opcode = 69 [0x45]
- sCmd = "txt_upload_schedule_msg_res";
- break;
- case e_txt_msg_echo_back_req:// = 0x26, // Message Echo Back Opcode = 38 [0x26] ⇔ Opcode = 70 [0x46]
- sCmd = "txt_msg_echo_back_req";
- break;
- case e_txt_msg_echo_back_res:// = 0x46, // Message Echo Back Opcode = 38 [0x26] ⇔ Opcode = 70 [0x46]
- sCmd = "txt_msg_echo_back_res";
- break;
- case e_txt_image_req:// = 0x2C, // 영상이미지 요청 Status Opcode = 44 [0x2C] ⇔ Opcode = 76 [0x4C]
- sCmd = "txt_image_req";
- break;
- case e_txt_image_res:// = 0x4C, // 영상이미지 요청 Status Opcode = 44 [0x2C] ⇔ Opcode = 76 [0x4C]
- sCmd = "txt_image_res";
- break;
- //case e_txt_ftp_download:// = 0x2C, // 동영상 파일 FTP 다운로드 Opcode = 44 [0x2C] ⇔ Opcode = 72 [0x48]
- // sCmd = "txt_ftp_download";
- // break;
- case e_txt_ftp_download_completed:// = 0x2E, // 동영상 파일 FTP 다운로드 완료 Opcode = 46 [0x2E]
- sCmd = "txt_ftp_download_completed";
- break;
- case e_txt_response:// = 0x48, // 제어기 응답(ACK/NAK)
- sCmd = "txt_response";
- break;
- case e_vms_form_display:// = 0x80,// 폼 데이터 표출 송신 표출할 폼 데이터 송신 센터 → VMS
- sCmd = "vms_form_display";
- break;
- case e_vms_file_download:// = 0x82,// 데이터 다운로드 송신 INI, CFG , Bitmap , Data파일송신 센터 → VMS
- sCmd = "vms_file_download";
- break;
- case e_vms_data_upload:// = 0x84,// 데이터 업로드 송신 INI, CFG , Bitmap , Data파일 업로드 요구 센터 → VMS
- sCmd = "vms_data_upload";
- break;
- case e_vms_status_control:// = 0x86,// VMS 상태제어 송신 VMS 제어정보 송신 센터 → VMS
- sCmd = "vms_status_control";
- break;
- case e_vms_status:// = 0x88,// VMS Status 요구 송신 VMS 상태정보 요구 송신 센터 → VMS
- sCmd = "vms_status";
- break;
- case e_vms_parameter:// = 0x8A,// VMS 파라미터 요구 송신 VMS 로컬 상태 요구 송신 센터 → VMS
- sCmd = "vms_parameter";
- break;
- case e_vms_power_module_status:// = 0x8C,// 전원 모듈 상태 요구 송신 전원 모듈 상태를 검사 결과를 요청한다 센터 → VMS
- sCmd = "vms_power_module_status";
- break;
- case e_vms_display_module_status:// = 0x8E,// 표출 모듈 상태 요구 송신 표출 모듈 상태를 검사 결과를 요청한다 센터 → VMS
- sCmd = "vms_display_module_status";
- break;
- case e_vms_pixel_image:// = 0x92,// VMS Pixel Image 요구 송신 VMS LED Pixel 상태요구 송신 센터 → VMS
- sCmd = "vms_pixel_image";
- break;
- case e_vms_current_display_form:// = 0x94,// 현재표출폼 Upload 송신 Local에서 표출 중인 폼 Upload요구 센터 → VMS
- sCmd = "vms_current_display_form";
- break;
- case e_vms_download_schedule_form:// = 0x96,// Display Schedule Form 송신 계획된 Form 표출 요구 센터 → VMS
- sCmd = "vms_download_schedule_form";
- break;
- case e_vms_display_default_form:// = 0x98,// Display Default Form 송신 디폴트 From표출 요구 센터 → VMS
- sCmd = "vms_display_default_form";
- break;
- case e_vms_download_form:// = 0x9A,// Download Form 송신 Form download 센터 → VMS
- sCmd = "vms_download_form";
- break;
- case e_vms_upload_schedule_form:// = 0x9C,// Upload Schedule Form 송신 스케줄 메시지 업로드 요구 센터 → VMS
- sCmd = "vms_upload_schedule_form";
- break;
- case e_vms_blank:// = 0x9E,// Blank 송신 schedule 표출 센터 → VMS
- sCmd = "vms_blank";
- break;
- case e_vms_display_form_id:// = 0xA0,// Display Form ID 송신 Form ID에 해당하는 Form 표출 센터 → VMS
- sCmd = "vms_display_form_id";
- break;
- case e_vms_video_ftp_download_req:// = 0xA1, // 동영상 파일 FTP 다운로드 요청 센터 → VMS
- sCmd = "e_vms_video_ftp_download_req";
- break;
- case e_vms_video_ftp_download_completed:// = 0xA2, // 동영상 파일 FTP 다운로드 완료 센터 ← VMS
- sCmd = "e_vms_video_ftp_download_completed";
- break;
- default:
- sCmd.printf("UNKNOWN Packet: %02X", AOpCode);
- return false;
- }
- if (ASend)
- {
- if (AResult == 0) {
- if (pCDSCtlr->IsDle)
- LINFO("SEND: %s, %d Bytes, [DLE Stuffing]", sCmd.c_str(), ALen);
- else
- LINFO("SEND: %s, %d Bytes.", sCmd.c_str(), ALen);
- }
- else {
- if (pCDSCtlr->IsDle)
- LERROR("SEND FAIL: %s, %d Bytes, [DLE Stuffing]", sCmd.c_str(), ALen);
- else
- LERROR("SEND FAIL: %s, %d Bytes.", sCmd.c_str(), ALen);
- }
- }
- else
- {
- if (pCDSCtlr->IsDle)
- LINFO("RECV: %s, %d Bytes, [DLE Stuffing]", sCmd.c_str(), ALen);
- else
- LINFO("RECV: %s, %d Bytes.", sCmd.c_str(), ALen);
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void TClientSession::DisplayResponseError(BYTE *AData)
- {
- BYTE *pData = &AData[sizeof(VMS_RES_HEAD)];
- if (pData[0] != VMS_NAK)
- {
- return;
- }
- AnsiString sErr = "";
- switch(pData[1])
- {
- case 0x30: sErr = "Data Length가 2,047 Byte 보다 크면 보고되는 오류"; break;
- case 0x31: sErr = "Data Length 이후의 데이터가 Data Length + 5Byte가 되지 않는 오류"; break;
- case 0x32: sErr = "데이터 크기 불일치"; break;
- case 0x33: sErr = "작업이전 작업 진행중 작업요구"; break;
- case 0x34: sErr = "파라미터 범위 초과"; break;
- case 0x35: sErr = "저장되지 않은 폼데이터 요구"; break;
- case 0x36: sErr = "업무처리 해당사항 없음"; break;
- case 0x37: sErr = "STN Address 틀림"; break;
- default : sErr.printf("NAK, Unknown Result Code 0x%02X", (int)pData[1]); break;
- }
- LERROR(sErr.c_str());
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_txt_response)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_txt_response Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_txt_response Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_txt_response Length: %d", nLength);
- TDownloadForm *pInfo = NULL;
- VMS_RES_HEAD *pRes = (VMS_RES_HEAD*)AData;
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- if (pRes->Ctlr != (BYTE)AObj->CTLR_LOCAL_NO)
- {
- TERROR("%s.%d, e_txt_response Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- MERROR("%s.%d, e_txt_response Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- return -3;
- }
- if (AObj->FTxtOpCode == e_txt_download_full_graphic_lib)
- {
- //라이브러리폼을 계속 다운로드
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- pInfo = AObj->FDownloadLists.Find(AObj->DownloadFormId);
- if (pInfo)
- {
- pInfo->AlreadyDownload = true;
- pInfo->DownloadTm = Now();
- }
- }
- ASession->download_lib_form_0x0A();
- }
- else
- if (AObj->FTxtOpCode == e_txt_display_schedule_msg)
- {
- //스케쥴다운로드가 완료됐으므로 blank 명령 전송
- ASession->download_blank_0x16();
- }
- else
- if (AObj->FTxtOpCode == e_txt_blank)
- {
- //Blank 명령 전송 완료 수신하면 OpCode 초기화
- AObj->FTxtOpCode == 0x00;
- // 폼 스케쥴 정보 다운로드 완료 메시지 처리
- ASession->download_form_schedule_complete();
- }
- }
- if (nLength == 1 && AData[sizeof(VMS_RES_HEAD)] == VMS_ACK)
- {
- #if OK_DEBUG
- TINFO("e_txt_response : ACK...");
- #endif
- }
- else
- if (nLength == 2 && AData[sizeof(VMS_RES_HEAD)] == VMS_NAK)
- {
- if (AObj && pInfo)
- {
- pInfo->AlreadyDownload = false;
- }
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- TERROR("%s.%d, e_txt_response Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_txt_response Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_txt_response : OK...");
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_txt_status_res)
- {
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (!AObj)
- {
- TERROR("%s.%d, e_txt_status_res Controller NULL. will be closed.", ASession->IpAddress.c_str(), ASession->Socket);
- MERROR("%s.%d, e_txt_status_res Controller NULL. will be closed.", ASession->IpAddress.c_str(), ASession->Socket);
- return -5;
- }
- if (ASession->State == eSS_LoginReq)
- {
- VMS_RES_HEAD *pRes = (VMS_RES_HEAD*)AData;
- if (pRes->Ctlr != (BYTE)AObj->CTLR_LOCAL_NO)
- {
- TERROR("%s.%d, e_txt_status_res Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- MERROR("%s.%d, e_txt_status_res Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- return -4;
- }
- }
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < 2)
- {
- TERROR("%s.%d, e_txt_status_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_txt_status_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_txt_status_res Length: %d", nLength);
- int nReqSize = sizeof(VMS_TXT_STATUS);
- if (nLength != nReqSize)
- {
- TERROR("%s.%d, e_txt_status_res Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_txt_status_res Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- VMS_TXT_STATUS *pStatus = (VMS_TXT_STATUS*)&AData[sizeof(VMS_RES_HEAD)];
- TDEBUG("VMS_TXT_STATUS: Door(%02X), Power(%02X), Fan(%02X), Heater(%02X), Reset(%02X), Temp(%02X,%d)",
- pStatus->DOOR,
- pStatus->POWER,
- pStatus->FAN,
- pStatus->HEATER,
- pStatus->RESET,
- pStatus->CBOX_TEMP,
- pStatus->CBOX_TEMP
- );
- INT_VMS_STATE *FStts = &AObj->RSTATE;
- #if 0
- BYTE DOOR; // Door Open/Close 상태 0x00 : Open, 0x01 : Close, 0x09 : Unknown
- BYTE POWER; // 전원의 ON/OFF 상태 0x00 : On, 0x01 : Off (Sign Board)
- BYTE FAN; // VMS Fan 동작상태 0x00 : On, 0x01 : Off, 0x09: Unknown
- // 함체 Fan 동작상태 0x00 : On, 0x10 : Off, 0x90: Unknown
- BYTE HEATER; // VMS Heater 동작상태 0x00 : On, 0x01 : Off, 0x09: Unknown
- // 함체 Heater 동작상태 x00 : On, 0x10 : Off, 0x90: Unknown
- WORD FORM_NUM; // 표출 폼 번호 0x00 : 통신 폼, 0x01 : 디폴트 폼
- BYTE REBOOT_YN; // 재실행 여부 0x00 : 정상, 0x01 : 재실행
- char CBOX_TEMP; // 함체온도 127 ~ -127 -128 : Unknown
- BYTE BRIGHT[4]; // 화면의 밝기 최대를 100으로 했을 때의 백분율 값 및 기준휘도
- // 0: 현재 휘도(00:주간,01:야간,02:자동)
- // 1: 야간휘도설정값
- // 2: 주간휘도설정값
- // 3: 현재휘도값(이건 나의 추측)
- char DP_TEMP; // 표출부온도 127 ~ -127 -128 : Unknown
- BYTE DP_HUM; // 표출부습도 0~100%, 포항UTIS부터 추가함
- #endif
- if (pStatus->POWER == 0x00) FStts->ModulePowerStatus = vms_module_power_off;
- else if (pStatus->POWER == 0x01) FStts->ModulePowerStatus = vms_module_power_on;
- else FStts->ModulePowerStatus = vms_module_power_unknown;
- if (pStatus->DOOR == 0x00) FStts->DoorStatus = vms_door_close;
- else if (pStatus->DOOR == 0x01) FStts->DoorStatus = vms_door_open;
- else FStts->DoorStatus = vms_door_unknown;
- if (pStatus->FAN == 0x00) FStts->FanStatus = vms_fan_off;
- else if (pStatus->FAN == 0x01) FStts->FanStatus = vms_fan_on;
- else FStts->FanStatus = vms_fan_unknown;
- if (pStatus->HEATER == 0x00) FStts->HeaterStatus = vms_heater_off;
- else if (pStatus->HEATER == 0x01) FStts->HeaterStatus = vms_heater_on;
- else FStts->HeaterStatus = vms_heater_unknown;
- FStts->PowerCtrlStatus = FStts->ModulePowerStatus; // 문자식은 받아오는게 없으니까 모듈전원상태와 동일한것으로 하자
- FStts->BodyTemp = (short)pStatus->CBOX_TEMP; /* 함체온도값(℃), 범위(-128~127) */
- //FStts->LuminanceStatus = (BYTE)pStatus->BRIGHT[3]; /* 화면의 밝기값 (최대 휘도값을 100으로 했을 때의 백분율 값), 범위(0~100) */
- FStts->Wcomm = vms_comm_normal;// : vms_comm_error; /* 무선통신상태, 0:정상 1:장애 */
- //AObj->BRGH_WEEK_STEP = pStatus->BRIGHT[2];
- //AObj->BRGH_NGHT_STEP = pStatus->BRIGHT[1];
- RequestJob(ASession, eVmsDisplayModuleStatusReq, NULL, 0);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_txt_failed_elem_data_res)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_TXT_MODL_STATUE)) // module count 2 byte
- {
- TERROR("%s.%d, e_txt_failed_elem_data_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_txt_failed_elem_data_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_txt_failed_elem_data_res Length: %d", nLength);
- VMS_TXT_MODL_STATUE *pData = (VMS_TXT_MODL_STATUE*)&AData[sizeof(VMS_RES_HEAD)];
- int idx = 0;
- int xCnt = 0;
- int yCnt = 0;
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- INT_VMS_STATE *FStts = &AObj->RSTATE;
- yCnt = AObj->ROW_NUM;
- xCnt = AObj->COL_NUM;
- FStts->ModuleHorizontal = xCnt; /* 가로 모듈수 */
- FStts->ModuleVertical = yCnt; /* 세로 모듈수 */
- idx = 0;
- for (int ii = 0; ii < yCnt && ii < MAX_TXT_MODL_ROWS; ii++)
- {
- for (int jj = 0; jj < xCnt && jj < MAX_TXT_MODL_COLS; jj++)
- {
- CComm_SetBitValue(FStts->ModuleStatus, idx, pData->Modl[ii][jj] == 0 ? 1 : 0);
- idx++;
- }
- }
- }
- TDEBUG("VMS_DISPLAY_MODULE : X(%d) Y(%d)", xCnt, yCnt);
- AnsiString sModSts = "";
- AnsiString sTmp;
- AnsiString MODL_STTS = "";
- idx = 0;
- for (int ii = 0; ii < yCnt && ii < MAX_TXT_MODL_ROWS; ii++)
- {
- sModSts = "";
- for (int jj = 0; jj < xCnt && jj < MAX_TXT_MODL_COLS; jj++)
- {
- sTmp.printf("%d", pData->Modl[ii][jj]); //0x00 : Off, 0x01 : On, 0x02 : Unknown,
- sModSts += sTmp;
- idx++;
- }
- MODL_STTS += sModSts;
- TDEBUG("VMS_DISPLAY_MODULE: %02d, %s", ii+1, sModSts.c_str());
- }
- if (AObj) AObj->MODL_STTS = MODL_STTS;
- POST_MSG(MAINHANDLE, WM_TCP_THREAD, WM_CTLR_STATE_STTS, (int)ASession->CDSCtlr); // 상태정보 업데이트
- #if 0
- // 설정온도 요청하면 응답으로 모듈상태정보가 올라와서 사용할 수 없음.
- RequestJob(ASession, eVmsParamReq, NULL, 0);
- #else
- if (ASession->State == eSS_LoginReq)
- {
- ASession->State = eSS_Connected;
- // 제어기가 최초 접속했을 때 마지막으로 시나리오를 전송한 시각과 다음 전송할 시각을 계산해서
- // 1분 이상 차이가 있을때에 시나리오를 전송하도록 한다.
- RequestJob(ASession, eVmsScenarioDownload, NULL, 0);
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- #if 0
- //TODO: 이거 사용하면 OpCode가 중복이 되어 모듈상태정보 처리를 하지 못한다.
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_txt_pan_hetr_temp_res)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_TXT_PARAMETER)) // module count 2 byte
- {
- TERROR("%s.%d, e_txt_pan_hetr_temp_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_txt_pan_hetr_temp_res Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_txt_pan_hetr_temp_res Length: %d", nLength);
- VMS_TXT_PARAMETER *pParam = (VMS_TXT_PARAMETER*)&AData[sizeof(VMS_RES_HEAD)];
- int nReqSize = sizeof(VMS_TXT_PARAMETER);
- if (nLength != nReqSize) // module count 2 byte
- {
- TERROR("%s.%d, e_txt_pan_hetr_temp_res Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_txt_pan_hetr_temp_res Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- AObj->FAN_RUN_TMPR = pParam->FanRunTemp; // Fan의 동작개시온도 1 Byte 온도( 0x00 ~0x03f )
- AObj->HETR_RUN_TMPR = pParam->HeaterRunTemp; // Heater 의 동작개시온도 1 Byte 온도(0x00 ~ 0x3f )
- TDEBUG("VMS_TXT_PARAMETER: ");
- TDEBUG(" FAN_RUN_TMPR: %d", AObj->FAN_RUN_TMPR);
- TDEBUG(" HETR_RUN_TMPR: %02X", AObj->HETR_RUN_TMPR);
- CTLR_STTS stts;
- stts.Type = 2;
- stts.ObjPtr = (void*)AObj;
- INT_VMS_STATE *FStts = &ASession->CDSCtlr->RSTATE;
- if (AObj->MODULE.IsOnOff)
- {
- if (AObj->MODULE.OnOff != AObj->PANL_PWER_MODE)
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- pMsg->Type = eVmsStatusControl;
- pMsg->ObjPtr = (DWORD)ASession;
- pMsg->Buff[0] = 0x01;
- pMsg->Buff[1] = ASession->CDSCtlr->MODULE.OnOff;// == vms_module_power_off ? 0x00 : 0x01;
- pMsg->Len = 2;
- g_jobQ.PushBlocking((DWORD)pMsg);
- }
- else
- {
- AObj->MODULE.IsOnOff = false;
- }
- }
- //1분마다 주기적으로 상태정보를 업데이트 하니까 실시간으로 업데이트 할 필요가 없다.
- //운영단말로 실시간으로 데이터만 보내도록 하자
- APP_PostDbThreadMessage(dbm_parma_res, sizeof(stts), &stts); // 파라미터 저장
- POST_MSG(MAINHANDLE, WM_TCP_THREAD, WM_CTLR_STATE_STTS, (int)ASession->CDSCtlr); // 상태정보 업데이트
- }
- if (ASession->State == eSS_LoginReq)
- {
- ASession->State = eSS_Connected;
- // 제어기가 최초 접속했을 때 마지막으로 시나리오를 전송한 시각과 다음 전송할 시각을 계산해서
- // 1분 이상 차이가 있을때에 시나리오를 전송하도록 한다.
- RequestJob(ASession, eVmsScenarioDownload, NULL, 0);
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- #endif
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_status)
- {
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (!AObj)
- {
- TERROR("%s.%d, e_vms_status Controller NULL. will be closed.", ASession->IpAddress.c_str(), ASession->Socket);
- MERROR("%s.%d, e_vms_status Controller NULL. will be closed.", ASession->IpAddress.c_str(), ASession->Socket);
- return -5;
- }
- if (ASession->State == eSS_LoginReq)
- {
- VMS_RES_HEAD *pRes = (VMS_RES_HEAD*)AData;
- if (pRes->Ctlr != (BYTE)AObj->CTLR_LOCAL_NO)
- {
- TERROR("%s.%d, e_vms_status Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- MERROR("%s.%d, e_vms_status Controller No Error: %d, %d.", ASession->IpAddress.c_str(), ASession->Socket, AObj->CTLR_LOCAL_NO, (int)pRes->Ctlr);
- return -4;
- }
- }
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < 2)
- {
- TERROR("%s.%d, e_vms_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_status Length: %d", nLength);
- int nReqSize = sizeof(VMS_STATUS);
- if (nLength != nReqSize)
- {
- TERROR("%s.%d, e_vms_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- VMS_STATUS *pStatus = (VMS_STATUS*)&AData[sizeof(VMS_RES_HEAD)];
- pStatus->FORM_NO = htons(pStatus->FORM_NO);
- //pStatus->BRIGHT = htonl(pStatus->BRIGHT);
- TDEBUG("VMS_STATUS: Door(%02X), Power(%02X), Fan(%02X), Heater(%02X), FormNo(%d), Reboot(%02X), Temp(%02X,%d), Bright(%02X,%02X,%02X,%02X), ExtTemp(%02X,%d), ExtHum(%02X,%d)",
- pStatus->DOOR,
- pStatus->POWER,
- pStatus->FAN,
- pStatus->HEATER,
- pStatus->FORM_NO,
- pStatus->REBOOT_YN,
- pStatus->CBOX_TEMP,
- pStatus->CBOX_TEMP,
- pStatus->BRIGHT[0],
- pStatus->BRIGHT[1],
- pStatus->BRIGHT[2],
- pStatus->BRIGHT[3],
- pStatus->DP_TEMP,
- pStatus->DP_TEMP,
- pStatus->DP_HUM,
- pStatus->DP_HUM
- );
- INT_VMS_STATE *FStts = &AObj->RSTATE;
- #if 0
- BYTE DOOR; // Door Open/Close 상태 0x00 : Open, 0x01 : Close, 0x09 : Unknown
- BYTE POWER; // 전원의 ON/OFF 상태 0x00 : On, 0x01 : Off (Sign Board)
- BYTE FAN; // VMS Fan 동작상태 0x00 : On, 0x01 : Off, 0x09: Unknown
- // 함체 Fan 동작상태 0x00 : On, 0x10 : Off, 0x90: Unknown
- BYTE HEATER; // VMS Heater 동작상태 0x00 : On, 0x01 : Off, 0x09: Unknown
- // 함체 Heater 동작상태 x00 : On, 0x10 : Off, 0x90: Unknown
- WORD FORM_NUM; // 표출 폼 번호 0x00 : 통신 폼, 0x01 : 디폴트 폼
- BYTE REBOOT_YN; // 재실행 여부 0x00 : 정상, 0x01 : 재실행
- char CBOX_TEMP; // 함체온도 127 ~ -127 -128 : Unknown
- BYTE BRIGHT[4]; // 화면의 밝기 최대를 100으로 했을 때의 백분율 값 및 기준휘도
- // 0: 현재 휘도(00:주간,01:야간,02:자동)
- // 1: 야간휘도설정값
- // 2: 주간휘도설정값
- // 3: 현재휘도값(이건 나의 추측)
- char DP_TEMP; // 표출부온도 127 ~ -127 -128 : Unknown
- BYTE DP_HUM; // 표출부습도 0~100%, 포항UTIS부터 추가함
- #endif
- if (pStatus->POWER == 0x01) FStts->ModulePowerStatus = vms_module_power_off;
- else if (pStatus->POWER == 0x00) FStts->ModulePowerStatus = vms_module_power_on;
- else FStts->ModulePowerStatus = vms_module_power_unknown;
- if (pStatus->DOOR == 0x01) FStts->DoorStatus = vms_door_close;
- else if (pStatus->DOOR == 0x00) FStts->DoorStatus = vms_door_open;
- else FStts->DoorStatus = vms_door_unknown;
- // 2021.03.25 신규 추가 VMS
- // 랩에서 테스트시 장비가 연결되어 있지 않아서 9로 올라옴. ==> 현장에서는 정상적으로 올라올거라함.
- int S1, S2;
- // 둘다 꺼져 있으면 OFF, 하나라도 켜져 있으면 ON
- S1 = (pStatus->FAN & 0x0F);
- S2 = (pStatus->FAN & 0xF0) >> 4;
- if (S1 != 0 && S1 != 1) S1 = 1;
- if (S2 != 0 && S2 != 1) S2 = 1;
- if (S1 == 1 && S2 == 1)
- pStatus->FAN = 0x01;
- else
- pStatus->FAN = 0x00;
- //VMS : 0x00 : On, 0x01 : Off, 0x09: Unknown
- //함체: 0x00 : On, 0x10 : Off, 0x90: Unknown
- if (pStatus->FAN == 0x00) FStts->FanStatus = vms_fan_on;
- else if (pStatus->FAN == 0x01) FStts->FanStatus = vms_fan_off;
- else if (pStatus->FAN == 0x10) FStts->FanStatus = vms_fan_off;
- else if (pStatus->FAN == 0x11) FStts->FanStatus = vms_fan_off; // ??? 실제 현장 상황에 맞게
- else FStts->FanStatus = vms_fan_unknown;
- // 둘다 꺼져 있으면 OFF, 하나라도 켜져 있으면 ON
- S1 = (pStatus->HEATER & 0x0F);
- S2 = (pStatus->HEATER & 0xF0) >> 4;
- if (S1 != 0 && S1 != 1) S1 = 1;
- if (S2 != 0 && S2 != 1) S2 = 1;
- if (S1 == 1 && S2 == 1)
- pStatus->HEATER = 0x01;
- else
- pStatus->HEATER = 0x00;
- //VMS : 0x00 : On, 0x01 : Off, 0x09: Unknown
- //함체: 0x00 : On, 0x10 : Off, 0x90: Unknown
- if (pStatus->HEATER == 0x00) FStts->HeaterStatus = vms_heater_on;
- else if (pStatus->HEATER == 0x01) FStts->HeaterStatus = vms_heater_off;
- else if (pStatus->HEATER == 0x10) FStts->HeaterStatus = vms_heater_off;
- else if (pStatus->HEATER == 0x11) FStts->HeaterStatus = vms_heater_off; // // ??? 실제 현장 상황에 맞게
- else FStts->HeaterStatus = vms_heater_unknown;
- FStts->BodyTemp = (short)pStatus->CBOX_TEMP; /* 함체온도값(℃), 범위(-128~127) */
- FStts->LuminanceStatus = (BYTE)pStatus->BRIGHT[3]; /* 화면의 밝기값 (최대 휘도값을 100으로 했을 때의 백분율 값), 범위(0~100) */
- FStts->Wcomm = vms_comm_normal;// : vms_comm_error; /* 무선통신상태, 0:정상 1:장애 */
- AObj->BRGH_WEEK_STEP = pStatus->BRIGHT[2];
- AObj->BRGH_NGHT_STEP = pStatus->BRIGHT[1];
- RequestJob(ASession, eVmsPowerModuleStautsReq, NULL, 0);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_power_module_status)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < 1) // module count 1 byte
- {
- TERROR("%s.%d, e_vms_power_module_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_power_module_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_power_module_status Length: %d", nLength);
- BYTE *pData = &AData[sizeof(VMS_RES_HEAD)];
- int nModCnt = pData[0];
- // pData[1] ==> Reserved area
- int nReqSize = (nModCnt+2);
- if (nLength != nReqSize)
- {
- TERROR("%s.%d, e_vms_power_module_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_power_module_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- INT_VMS_STATE *FStts = &ASession->CDSCtlr->RSTATE;
- FStts->PowerCount = nModCnt;
- for (int ii = 0; ii < nModCnt; ii++)
- {
- CComm_SetBitValue(FStts->PowerStatus, ii, pData[2+ii]);
- }
- }
- TDEBUG("VMS_POWER_MODULE COUNT: %d", nModCnt);
- AnsiString sModSts = "";
- AnsiString sTmp;
- AnsiString PWER_STTS = "";
- for (int ii = 0; ii < nModCnt; ii++)
- {
- sTmp.printf("%d", pData[2+ii]); //0x00 : Off, 0x01 : On, 0x02 : Unknown,
- sModSts += sTmp;
- }
- PWER_STTS += sModSts;
- if (AObj) AObj->PWER_STTS = PWER_STTS;
- TDEBUG("VMS_POWER_MODULE STATUS: %s", sModSts.c_str());
- RequestJob(ASession, eVmsDisplayModuleStatusReq, NULL, 0);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_display_module_status)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < 2) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_display_module_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_display_module_status Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_display_module_status Length: %d", nLength);
- BYTE *pData = (BYTE*)&AData[sizeof(VMS_RES_HEAD)];
- int xCnt = pData[0]; // 1 Byte(X축) VMS 모듈수 //가로
- int yCnt = pData[1]; // 1 Byte(Y축) VMS 모듈수 //세로
- // 예)VMS 모듈수 : 2단 5열일 경우 모듈개수 (5(x), 2(y))를 표지한다.
- int nReqSize = (xCnt*yCnt+2);
- if (nLength < nReqSize) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_display_module_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_display_module_status Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- int idx = 0;
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- INT_VMS_STATE *FStts = &AObj->RSTATE;
- FStts->ModuleHorizontal = xCnt; /* 가로 모듈수 */
- FStts->ModuleVertical = yCnt; /* 세로 모듈수 */
- idx = 0;
- for (int ii = 0; ii < yCnt; ii++)
- {
- for (int jj = 0; jj < xCnt; jj++)
- {
- //CComm_SetBitValue(FStts->ModuleStatus, idx, pData[2+idx]);
- CComm_SetBitValue(FStts->ModuleStatus, idx, pData[2+idx] == 0 ? 1 : 0);
- idx++;
- }
- }
- }
- TDEBUG("VMS_DISPLAY_MODULE : X(%d) Y(%d)", xCnt, yCnt);
- AnsiString sModSts = "";
- AnsiString sTmp;
- AnsiString MODL_STTS = "";
- idx = 0;
- for (int ii = 0; ii < yCnt; ii++)
- {
- sModSts = "";
- for (int jj = 0; jj < xCnt; jj++)
- {
- sTmp.printf("%d", pData[2+idx]); //0x00 : Off, 0x01 : On, 0x02 : Unknown,
- sModSts += sTmp;
- idx++;
- }
- MODL_STTS += sModSts;
- TDEBUG("VMS_DISPLAY_MODULE: %02d, %s", ii+1, sModSts.c_str());
- }
- if (AObj) AObj->MODL_STTS = MODL_STTS;
- //백분율 컬럼 없음(프로토콜 문서에는 있는데 제어기에서 올리지 않음)
- //TDEBUG("VMS_DISPLAY_MODULE: Error Rate: 0x%02X, 0x%02X", pData[2+(xCnt*yCnt)], pData[2+(xCnt*yCnt)+1];
- RequestJob(ASession, eVmsParamReq, NULL, 0);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_parameter)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_PARAMETER)) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_parameter Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_parameter Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_parameter Length: %d", nLength);
- VMS_PARAMETER *pParam = (VMS_PARAMETER*)&AData[sizeof(VMS_RES_HEAD)];
- int nReqSize = sizeof(VMS_PARAMETER);
- if (nLength != nReqSize) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_parameter Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_parameter Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- AObj->PANL_PWER_MODE = pParam->PowerCtrlMode; // 전원제어 모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐,
- AObj->FAN_MODE = pParam->FanRunMode; // Fan 동작모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐, 0x02 : 자동, 0x09: Unknown
- AObj->FAN_RUN_TMPR = pParam->FanRunTemp; // Fan의 동작개시온도 1 Byte 온도( 0x00 ~0x03f )
- AObj->HETR_MODE = pParam->HeaterRunMode; // Heater의 동작모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐, 0x02 : 자동, 0x09: Unknown
- AObj->HETR_RUN_TMPR = pParam->HeaterRunTemp; // Heater 의 동작개시온도 1 Byte 온도(0x00 ~ 0x3f )
- AObj->BRGH_MODE = pParam->BrightMode; // 밝기 모드 2 Byte 0x0 : 수동, 0x1 : 자동, 비율 : 0-100
- AObj->BRGH_CURR_STEP = pParam->BrightRate; // 밝기 모드 2 Byte 0x0 : 수동, 0x1 : 자동, 비율 : 0-100
- //AObj->BRGH_WEEK_STEP = 0x00; // res.para.brghDay; // N NUMBER(3) Y 64 휘도 주간 단계(0~100)
- //AObj->BRGH_NGHT_STEP = 0x00; // res.para.brghNight; // N NUMBER(3) Y 48 휘도 야간 단계(0~100)
- AObj->ParamResTime.printf("%04d%02d%02d%02d%02d%02d",
- pParam->Year+2000, // 년 1 Byte 0x00 ~ 0x32
- pParam->Mon, // 월 1 Byte 0x01 ~ 0x0c
- pParam->Day, // 일 1 Byte 0x01 ~ 0x1f
- pParam->Hour, // 시 1 Byte 0x00 ~ 0x17
- pParam->Min, // 분 1 Byte 0x00 ~ 0x3b
- pParam->Sec // 초 1 Byte 0x00 ~ 0x3b
- );
- #if 0
- pParam->BlinkTime; // 깜빡이는 시간주기 1 Byte 문자 비트맵의 깜빡이는 시간주기 0x00 ~ 0x1e( 0.1 ~3.0 )
- pParam->ScnTurnTime; // 디폴트 시나리오로 전환시간 2 Byte 디폴트 시나리오로 전환될 때까지 기다리는 시간, 단위 : 초
- pParam->Reserved; // 기타 1 Byte
- #endif
- TDEBUG("VMS_PARAMETER: PANL_PWER_MODE: 0x%02X", AObj->PANL_PWER_MODE);
- TDEBUG(" FAN_MODE: 0x%02X", AObj->FAN_MODE);
- TDEBUG(" FAN_RUN_TMPR: 0x%02X, %d", AObj->FAN_RUN_TMPR);
- TDEBUG(" HETR_MODE: 0x%02X", AObj->HETR_MODE);
- TDEBUG(" HETR_RUN_TMPR: 0x%02X", AObj->HETR_RUN_TMPR);
- TDEBUG(" BRGH_MODE: 0x%02X", AObj->BRGH_MODE);
- TDEBUG(" BRGH_CURR_STEP: 0x%02X, %d", AObj->BRGH_CURR_STEP, AObj->BRGH_CURR_STEP);
- TDEBUG(" LOCAL_TIME: %s", AObj->ParamResTime.c_str());
- CTLR_STTS stts;
- stts.Type = 2;
- stts.ObjPtr = (void*)AObj;
- // AObj->PANL_PWER_MODE 여기 정보가 모듈전원이 On/Off 된 것을 저장하고 있다.
- INT_VMS_STATE *FStts = &ASession->CDSCtlr->RSTATE;
- //FStts->PowerCtrlStatus = pParam->PowerCtrlMode; // 전원제어 모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐,
- if (pParam->PowerCtrlMode == 0x00) FStts->PowerCtrlStatus = vms_module_power_off;
- else if (pParam->PowerCtrlMode == 0x01) FStts->PowerCtrlStatus = vms_module_power_on;
- else FStts->PowerCtrlStatus = vms_module_power_unknown;
- memcpy(FStts->ControllerCurrentTime, AObj->ParamResTime.c_str(), INT_VMS_MAX_DATETIME);
- if (AObj->MODULE.IsOnOff)
- {
- if (AObj->MODULE.OnOff != AObj->PANL_PWER_MODE)
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- pMsg->Type = eVmsStatusControl;
- pMsg->ObjPtr = (DWORD)ASession;
- pMsg->Buff[0] = 0x01;
- pMsg->Buff[1] = ASession->CDSCtlr->MODULE.OnOff;// == vms_module_power_off ? 0x00 : 0x01;
- pMsg->Len = 2;
- g_jobQ.PushBlocking((DWORD)pMsg);
- }
- else
- {
- AObj->MODULE.IsOnOff = false;
- }
- }
- //1분마다 주기적으로 상태정보를 업데이트 하니까 실시간으로 업데이트 할 필요가 없다.
- //운영단말로 실시간으로 데이터만 보내도록 하자
- APP_PostDbThreadMessage(dbm_parma_res, sizeof(stts), &stts); // 파라미터 저장
- POST_MSG(MAINHANDLE, WM_TCP_THREAD, WM_CTLR_STATE_STTS, (int)ASession->CDSCtlr); // 상태정보 업데이트
- }
- // TODO: 동영상 VMS 인 경우 동영상 파일을 다운로드 하도록 명령을 전송한다.
- if (AObj->IsVideo && AObj->RemainFtpFile()) {
- TINFO("ftp-file-download request to jobQ-1.");
- RequestJob(ASession, eVmsFtpFileDownload, NULL, 0);
- }
- if (ASession->State == eSS_LoginReq)
- {
- ASession->State = eSS_Connected;
- // 제어기가 최초 접속했을 때 마지막으로 시나리오를 전송한 시각과 다음 전송할 시각을 계산해서
- // 1분 이상 차이가 있을때에 시나리오를 전송하도록 한다.
- RequestJob(ASession, eVmsScenarioDownload, NULL, 0);
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_pixel_image)
- {
- // 요거는 제어기에서 응답을 하지 않음.
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_PARAMETER)) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_parameter Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_parameter Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_parameter Length: %d", nLength);
- VMS_PARAMETER *pParam = (VMS_PARAMETER*)&AData[sizeof(VMS_RES_HEAD)];
- int nReqSize = sizeof(VMS_PARAMETER);
- if (nLength != nReqSize) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_parameter Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_parameter Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_current_display_form)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_PARAMETER)) // module count 2 byte
- {
- TERROR("%s.%d, e_vms_current_display_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_current_display_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- TDEBUG("e_vms_current_display_form Length: %d", nLength);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_display_default_form)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_display_default_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_display_default_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_display_default_form Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_display_default_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_display_default_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_display_default_form : OK...");
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_upload_schedule_form)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_upload_schedule_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_upload_schedule_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_upload_schedule_form Length: %d", nLength);
- VMS_SCHEDULE_FORM *pRes = (VMS_SCHEDULE_FORM*)&AData[sizeof(VMS_RES_HEAD)];
- int nReqSize = sizeof(VMS_SCHEDULE_FORM);
- if (nLength < nReqSize)
- {
- TERROR("%s.%d, e_vms_upload_schedule_form Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- MERROR("%s.%d, e_vms_upload_schedule_form Data Size error(%d, %d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength, nReqSize);
- if (nLength == 2)
- {
- ASession->DisplayResponseError(AData);
- }
- return -2;
- }
- for (int ii = 0; ii < MAX_VMS_SCENARIO_FORM; ii++)
- {
- TDEBUG("e_vms_upload_schedule_form %02d: FormNo: %d, Display Second: %d", ii+1, ntohs(pRes->Form[ii].FormNo), pRes->Form[ii].DispSec);
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_display_form_id)
- {
- //프로토콜에는 있으나 제어기에서 반응을 하지 않음
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_display_form_id Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_display_form_id Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_display_form_id Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_display_form_id Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_display_form_id Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_display_form_id : OK...");
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_status_control)
- {
- //프로토콜에는 있으나 제어기에서 반응을 하지 않음
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_status_control Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_status_control Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_status_control Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_status_control Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_status_control Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_status_control : OK...");
- }
- #endif
- RequestJob(ASession, eVmsStatusReq, NULL, 0);
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_download_form)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_download_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_download_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_download_form Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_download_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_download_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_download_form : OK...");
- }
- #endif
- // 폼정보를 계속해서 다운로드 한다.
- // 스케쥴 모드가 기본모드인 경우에는 폼정보가 하나만 내려가기때문에
- // 폼파일을 다운로드 해야 하고
- // 일반모드(자동, 고정) 인경우에는 폼정보를 계속해서 다운로드 해야 한다.
- if (ASession->CDSCtlr->FormDownload.IsDefault)
- {
- ASession->download_file_0x82();
- }
- else
- {
- ASession->download_form_0x9A();
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_form_display)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_form_display Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_form_display Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_form_display Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_form_display Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_form_display Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_form_display : OK...");
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_download_schedule_form)
- {
- //프로토콜에는 있으나 제어기에서 반응을 하지 않음
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_download_schedule_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_download_schedule_form Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_download_schedule_form Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_download_schedule_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_download_schedule_form Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_download_schedule_form : OK...");
- }
- #endif
- // 스케쥴 표출 마지막 데이터 전송
- ASession->download_blank_0x9E();
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_file_download)
- {
- //프로토콜에는 있으나 제어기에서 반응을 하지 않음
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_file_download Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_file_download Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_file_download Length: %d", nLength);
- TDownloadForm *pInfo = NULL;
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- pInfo = AObj->FDownloadLists.Find(AObj->DownloadFormId);
- }
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- if (pInfo)
- {
- pInfo->AlreadyDownload = false;
- }
- TERROR("%s.%d, e_vms_file_download Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_file_download Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- else
- {
- if (pInfo)
- {
- pInfo->AlreadyDownload = true;
- pInfo->DownloadTm = Now();
- }
- #if OK_DEBUG
- TINFO("e_vms_file_download : OK...");
- #endif
- }
- // 폼이미지를 계속해서 다운로드 한다.
- ASession->download_file_0x82();
- return 0;
- }
- //---------------------------------------------------------------------------
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_blank)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- #if 0
- if (nLength < 1) // ACK or NAK
- {
- TERROR("%s.%d, e_vms_blank Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_blank Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- #endif
- TDEBUG("e_vms_blank Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_blank Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_blank Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_blank : OK...");
- }
- #endif
- if (ASession->CDSCtlr && ASession->CDSCtlr->FormDownload.IsDefault)
- {
- // 기본스케쥴인 경우에는 BLANK 명령을 내려보내지 말아야 한다.
- //ASession->ReqDisplayDefaultForm();
- //return download_form_schedule_complete();
- }
- // 폼 스케쥴 정보 다운로드 완료 메시지 처리
- ASession->download_form_schedule_complete();
- return 0;
- }
- //---------------------------------------------------------------------------
- // TODO: 20241220 ==> FTP 다운로드 전송 메시지를 VMS에서 정상적으로 수신하였다는 메시지
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_video_ftp_download_req)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- TDEBUG("e_vms_video_ftp_download_req Length: %d", nLength);
- VMS_RESULT *pRes = (VMS_RESULT*)&AData[sizeof(VMS_RES_HEAD)];
- if (pRes->Result != VMS_ACK)
- {
- TERROR("%s.%d, e_vms_video_ftp_download_req Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- MERROR("%s.%d, e_vms_video_ftp_download_req Result Error. Error: 0x%02X.", ASession->IpAddress.c_str(), ASession->Socket, pRes->Error);
- ASession->DisplayResponseError(AData);
- return -2;
- }
- #if OK_DEBUG
- else
- {
- TINFO("e_vms_video_ftp_download_req : OK...");
- }
- #endif
- return 0;
- }
- //---------------------------------------------------------------------------
- // TODO: 20241220 ==> FTP 다운로드 전송 메시지를 VMS에서 정상적으로 수신 후 FTP 까지 완료하였다는 메시지
- /////////////////////////////////////////////////////////
- REGISTER_HANDLER(e_vms_video_ftp_download_completed)
- {
- int nLength = APktLen-sizeof(VMS_RES_HEAD)-sizeof(VMS_TAIL);
- if (nLength < (int)sizeof(VMS_FILE_FTP_DATA))
- {
- TERROR("%s.%d, e_vms_video_ftp_download_completed Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- MERROR("%s.%d, e_vms_video_ftp_download_completed Data Length error(%d). will be closed.", ASession->IpAddress.c_str(), ASession->Socket, nLength);
- return -1;
- }
- VMS_FILE_FTP_DATA *pFtpFile = (VMS_FILE_FTP_DATA*)&AData[sizeof(VMS_RES_HEAD)];
- AnsiString sFtpFileName = AnsiString(pFtpFile->FILE_NM);
- TINFO("e_vms_video_ftp_download_completed: %s", sFtpFileName.c_str());
- TCDSCtlr *AObj = ASession->CDSCtlr;
- if (AObj)
- {
- TFtpFile *ftpFile = AObj->FFtpFileLists.Find(sFtpFileName);
- if (ftpFile != NULL) {
- ftpFile->IsFtpOk = true;
- ftpFile->UpdateTm = Now();
- }
- // TODO: 동영상 파일을 다운로드 하도록 명령을 전송한다.
- //if (AObj->RemainFtpFile())
- {
- //TINFO("ftp-file-download request to jobQ-2.");
- RequestJob(ASession, eVmsFtpFileDownload, NULL, 0);
- }
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqStauts()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = (AObj->PROTOCOL_VER == 1) ? e_txt_status_req : e_vms_status;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqStauts send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqStauts send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqPowerModuleStatus()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = e_vms_power_module_status;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqPowerModuleStatus send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqPowerModuleStatus send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqDisplayModuelStatus()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = (AObj->PROTOCOL_VER == 1) ? e_txt_failed_elem_data_req : e_vms_display_module_status;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqDisplayModuelStatus send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqDisplayModuelStatus send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
-
int TClientSession::ReqParameter()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- #if 0
- // 설정온도 요청하면 모듈상태정보가 응답으로 올라온다
- // 프로토콜의 OpCode도 동일하다.
- req.OpCode = (AObj->PROTOCOL_VER == 1) ? e_txt_pan_hetr_temp_req : e_vms_parameter;
- #else
- req.OpCode = e_vms_parameter;
- #endif
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqParameter send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqParameter send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqPixelImage(char *ACmd)
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_INFO_DATA req;
- req.OpCode = e_vms_pixel_image;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- req.Data[0] = ACmd[0];
- req.Length = 1;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)+1))
- {
- SERROR("+CLI ReqPixelImage send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqPixelImage send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqUploadCurrentForm()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = e_vms_current_display_form;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqUploadCurrentForm send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqUploadCurrentForm send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqDisplayDefaultForm()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = e_vms_display_default_form;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqDisplayDefaultForm send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqDisplayDefaultForm send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqUploadScheduleForm()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_DATA req;
- req.OpCode = e_vms_upload_schedule_form;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)))
- {
- SERROR("+CLI ReqUploadScheduleForm send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqUploadScheduleForm send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqDisplayFormId(char *ACmd)
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- VMS_REQ_INFO_DATA req;
- req.OpCode = e_vms_display_form_id;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- req.Data[0] = 0;//ACmd[0];
- req.Data[1] = 0;//ACmd[2];
- req.Length = 2;
- if (!SendPacket((char*)&req, sizeof(VMS_REQ_DATA)+2))
- {
- SERROR("+CLI ReqDisplayFormId send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqDisplayFormId send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqStatusControl(char *ACmd, int ALen)
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- char *pSendData = NULL;
- int nSendByte = 0;
- if (AObj->PROTOCOL_VER == 1)
- {
- VMS_REQ_INFO_DATA req;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- if (ACmd[0] == 0x01)
- {
- //SignBoard On/Off
- req.OpCode = e_txt_signboard_control;
- req.Length = 1;
- req.Data[0] = ACmd[1]; //Power Off=0, Power On = 1
- pSendData = (char*)&req;
- nSendByte = sizeof(VMS_REQ_DATA)+req.Length;
- }
- else
- if (ACmd[0] == 0x02)
- {
- //Initialize(Reset)
- req.OpCode = e_txt_initialize;
- req.Length = 0;
- pSendData = (char*)&req;
- nSendByte = sizeof(VMS_REQ_DATA)+req.Length;
- }
- else
- if (ACmd[0] == 0x06)
- {
- //Set luminance Level
- req.OpCode = e_txt_set_luminance_level;
- req.Length = 1;
- req.Data[0] = ACmd[1];
- switch(ACmd[1]) //도형식과 비교해서 값이 다름
- {
- case 0x00: //주간
- req.Data[0] = 1;
- break;
- case 0x01: //야간
- req.Data[0] = 2;
- break;
- case 0x02: //자동
- req.Data[0] = 0;
- break;
- }
- pSendData = (char*)&req;
- nSendByte = sizeof(VMS_REQ_DATA)+req.Length;
- }
- }
- else
- {
- VMS_REQ_INFO_DATA req;
- req.OpCode = e_vms_status_control;
- req.Group = AObj->GROUP_NO;
- req.Ctlr = AObj->CTLR_LOCAL_NO;
- memcpy(req.Data, ACmd, ALen);
- req.Length = ALen;
- pSendData = (char*)&req;
- nSendByte = sizeof(VMS_REQ_DATA)+ALen;
- }
- if (pSendData == NULL || nSendByte == 0)
- {
- return 1;
- }
- if (!SendPacket(pSendData, nSendByte))
- {
- SERROR("+CLI ReqStatusControl send request faild: %s will be closed.", FIpAddress.c_str());
- MERROR("+CLI ReqStatusControl send request faild: %s will be closed.", FIpAddress.c_str());
- Disconnect();
- return -1;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_form_schedule_complete()
- {
- // VMS 메시지 다운로드 완료
- TCDSCtlr *AObj = FCDSCtlr;
- if (AObj)
- {
- if (AObj->CTRLMODE->Schedule)
- {
- VMS_PROVIDE_RESULE ProvideSave;
- memset(&ProvideSave, 0x00, sizeof(ProvideSave));
- ProvideSave.Type = provide_form;
- ProvideSave.Count = 1;
- ProvideSave.pObj[0] = (void*)AObj;
- AObj->CTRLMODE->Enable = object_disable;
- AObj->CTRLMODE->SvcDate = Now().FormatString("yyyymmddhhnnss");
- AObj->CTRLMODE->SaveFlag = true;
- AObj->CTRLMODE->Result = true;
- APP_PostDbThreadMessage(dbm_provide_result, sizeof(ProvideSave), &ProvideSave);
- }
- }
- return 0;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_form_schedule(bool ASchedule/*=true*/)
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- if (ASchedule)
- {
- LDEBUG("Download Form Schedule by schedule...");
- }
- else
- {
- LDEBUG("Download Form Schedule by user control...");
- }
- AObj->CTRLMODE->Schedule = ASchedule; // 스케쥴 모드인 경우 디비에 저장한다.
- //다운로드 정보만 초기화 한다.
- memset((char*)&AObj->FormDownload, 0x00, sizeof(VMS_DOWNLOAD_DATA));
- AObj->FTxtOpCode == 0x00;
- int nForms = 0;
- int nFormCnt = 0;
- AObj->pForms->Lock();
- try
- {
- nFormCnt = AObj->pForms->Count();
- if (nFormCnt == 0)
- {
- return 0;
- }
- for (int ii = 0; ii < nFormCnt; ii++)
- {
- TVmsForm *pForm = AObj->pForms->GetItem(ii);
- if (!pForm->Success)
- {
- continue;
- }
- // TODO: 20241220
- //if (pForm->fileType == P_FILE_TYPE_VIDEO || pForm->fileType == P_FILE_TYPE_STREAM)
- if (pForm->fileType == P_FILE_TYPE_STREAM)
- {
- continue;
- }
- if (AObj->PROTOCOL_VER == 1 && pForm->fileType == P_FILE_TYPE_VIDEO)
- {
- // 문자식이면서 동영상 폼이면 표출하지 못함
- continue;
- }
- if (!pForm->pStream || pForm->pStream->Size == 0)
- {
- continue;
- }
- AObj->FormDownload.Info[nForms].fileType = pForm->fileType;
- AObj->FormDownload.Info[nForms].STRM_ADDR = pForm->STRM_ADDR;
- AObj->FormDownload.Info[nForms].VMS_FORM_ID = pForm->VMS_FORM_ID;
- AObj->FormDownload.Info[nForms].IsDownload = true;
- AObj->FormDownload.Info[nForms].FormIdx = ii; // 리스트상의 순서
- if (AObj->PROTOCOL_VER == 1)
- {
- //문자식 프로토콜 적용
- //AObj->FormDownload.Info[nForms].BitmapId = (pForm->VMS_FORM_ID.ToIntDef(0) % 1000) + TEXT_BASE_FORMID; // 리스트상의 순서
- AObj->FormDownload.Info[nForms].BitmapId = nForms + TEXT_BASE_FORMID; // 리스트상의 순서
- AObj->FormDownload.Info[nForms].FormNo = AObj->FormDownload.Info[nForms].BitmapId; // 실재 다운로드되는 순서
- }
- else
- {
- //도형식 프로토콜 적용
- //AObj->FormDownload.Info[nForms].BitmapId = (pForm->VMS_FORM_ID.ToIntDef(0) % 1000) + 1000; // 리스트상의 순서
- AObj->FormDownload.Info[nForms].BitmapId = nForms + 1000; // 리스트상의 순서
- AObj->FormDownload.Info[nForms].FormNo = PICTURE_BASE_FORMID+nForms; // 실재 다운로드되는 순서
- }
- AObj->FormDownload.Info[nForms].DispSec = (BYTE)pForm->DSPL_HH;
- TDownloadForm *pInfo = AObj->FDownloadLists.Find(pForm->VMS_FORM_ID);
- TCDSForm *pCDSForm = CDSFormManager->FLists.Find(pForm->VMS_FORM_ID);
- if (pCDSForm)
- {
- if (pCDSForm->VMS_FORM_TYPE_CD == eFormTp_hongbo)
- {
- if (AObj->PROTOCOL_VER == 1)
- {
- //문자식 프로토콜 적용
- AObj->FormDownload.Info[nForms].BitmapId = (pForm->VMS_FORM_ID.ToIntDef(0) % 1000) + TEXT_BASE_FORMID; // 리스트상의 순서
- AObj->FormDownload.Info[nForms].FormNo = AObj->FormDownload.Info[nForms].BitmapId; // 실재 다운로드되는 순서
- }
- else
- {
- //도형식 프로토콜 적용
- AObj->FormDownload.Info[nForms].BitmapId = (pForm->VMS_FORM_ID.ToIntDef(0) % 1000) + 1000; // 리스트상의 순서
- }
- }
- //홍보폼이면서 신규폼이 아니면서 이전 다운로드 목록이 존재하는 경우에 다운로드 여부를 체크한다.
- if (pCDSForm->VMS_FORM_TYPE_CD == eFormTp_hongbo && pCDSForm->IsNewForm == false && pInfo)
- {
- if (pInfo->AlreadyDownload)
- {
- // 이미 이전에 다운로드를 했기때문에 이번에는 제어기로 다운로드를 하지 않는다.
- AObj->FormDownload.Info[nForms].IsDownload = false;
- }
- }
- //이전에 다운로드한 정보가 존재하면
- if (pInfo)
- {
- if (pInfo->UPDT_DT != pCDSForm->UPDT_DT)
- {
- // 업데이트시각이 다르기때문에 신규폼으로 판단한다.
- pInfo->AlreadyDownload = false;
- AObj->FormDownload.Info[nForms].IsDownload = true;
- pInfo->UPDT_DT = pCDSForm->UPDT_DT;
- }
- }
- }
- if (!pInfo && pCDSForm)
- {
- pInfo = AObj->FDownloadLists.Find(pForm->VMS_FORM_ID);
- if (!pInfo)
- {
- pInfo = new TDownloadForm();
- if (pInfo)
- {
- //신규로추가
- pInfo->VMS_FORM_ID = pForm->VMS_FORM_ID;
- AObj->FDownloadLists.Push(pInfo->VMS_FORM_ID, pInfo);
- }
- }
- if (pInfo)
- {
- //다운로드정보설정
- pInfo->AlreadyDownload = false;
- pInfo->UPDT_DT = pCDSForm->UPDT_DT;
- }
- }
- nForms++;
- if (nForms >= MAX_VMS_SCENARIO_FORM)
- {
- // 최대폼까지 다운로드
- break;
- }
- }
- }
- __finally
- {
- AObj->pForms->UnLock();
- }
- for (int jj = 0; jj < nFormCnt; jj++)
- {
- LDEBUG("Form schedule(%2d), VMS_FORM_ID: %s, FormIdx: %d, FormId: %d, BitmapId: %d, IsDownload: %s",
- jj,
- AObj->FormDownload.Info[jj].VMS_FORM_ID.c_str(),
- AObj->FormDownload.Info[jj].FormIdx,
- AObj->FormDownload.Info[jj].FormNo,
- AObj->FormDownload.Info[jj].BitmapId,
- AObj->FormDownload.Info[jj].IsDownload ? "true" : "false");
- }
- if (nForms <= 0)
- {
- return 0;
- }
- AObj->FormDownload.MaxSchedule = nForms;
- AObj->FormDownload.DownloadCnt = 0;
- if (AObj->PROTOCOL_VER == 1)
- {
- //문자식 프로토콜 적용
- AObj->FormDownload.IsDefault = false;
- download_lib_form_0x0A();
- }
- else
- {
- //도형식 프로토콜 적용
- if (AObj->OPER_MODE == "B")
- {
- // 기본모드인 경우
- //e_vms_download_form = 0x9A,// Download Form 송신 Form download 센터 → VMS
- //e_vms_file_download = 0x82,// 데이터 다운로드 송신 INI, CFG , Bitmap , Data파일송신 센터 → VMS
- //e_vms_download_schedule_form = 0x96,// Display Schedule Form 송신 계획된 Form 표출 요구 센터 → VMS
- //e_vms_blank = 0x9E,// Blank 송신 schedule 표출 센터 → VMS
- AObj->FormDownload.IsDefault = true;
- download_default_form_0x9A(); // Download Form (기본폼은 하나의 폼에 여러폼을 다운로드한다.)
- }
- else
- {
- // 스케쥴 모드인 경우(A:자동, F:고정)
- //e_vms_download_form = 0x9A,// Download Form 송신 Form download 센터 → VMS
- //e_vms_file_download = 0x82,// 데이터 다운로드 송신 INI, CFG , Bitmap , Data파일송신 센터 → VMS
- //e_vms_download_schedule_form = 0x96,// Display Schedule Form 송신 계획된 Form 표출 요구 센터 → VMS
- //e_vms_blank = 0x9E,// Blank 송신 schedule 표출 센터 → VMS
- AObj->FormDownload.IsDefault = false;
- download_form_0x9A(); // Download Form (기본폼은 하나의 폼에 여러폼을 다운로드한다.)
- }
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- // TODO: 20241220
- int TClientSession::download_ftp_file()
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- //if (!AObj->RemainFtpFile()) return -2;
- TFtpFile *pFtpFile = NULL;
- FOR_STL(TFtpFile*, pInfo, AObj->FFtpFileLists)
- {
- if (!pInfo->IsFtpOk) {
- pFtpFile = pInfo;
- LINFO("download_ftp_file_0xA1: %s, try download.", pFtpFile->FtpFileName.c_str());
- break;
- }
- else {
- LINFO("download_ftp_file_0xA1: %s, already download.", pInfo->FtpFileName.c_str());
- }
- }
- if (pFtpFile == NULL) {
- LINFO("download_ftp_file_0xA1: ftp download completed.");
- return -3;
- }
- BYTE *msgPtr;
- VMS_HEAD *pHead;
- VMS_FILE_FTP_DATA *pData;
- WORD crc;
- int nPktSize;
- msgPtr = (BYTE*)pMsg->Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pData = (VMS_FILE_FTP_DATA*)&msgPtr[sizeof(VMS_HEAD)];
- memset((char*)pData, 0x00, sizeof(VMS_FILE_FTP_DATA));
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_video_ftp_download_req;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- sprintf(pData->FILE_NM, "%s", pFtpFile->FtpFileName.c_str());
- LINFO("download_ftp_file_0xA1: %s, %s", pFtpFile->FtpFileName.c_str(), pData->FILE_NM);
- pHead->Length = sizeof(VMS_FILE_FTP_DATA);
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_default_form_0x9A()
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- BYTE *msgPtr;
- // 파일다운로드
- VMS_HEAD *pHead;
- VMS_FILE_DATA *pFile;
- // 폼다운로드
- VMS_FORM_HEAD *pForm;
- VMS_FORM_BMPID_DATA *pBmpIdData;
- WORD crc;
- int nPktSize;
- int nPktIdx;
- nPktIdx = sizeof(VMS_HEAD)+sizeof(VMS_FORM_HEAD);
- msgPtr = (BYTE*)pMsg->Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pForm = (VMS_FORM_HEAD*)&msgPtr[sizeof(VMS_HEAD)];
- pBmpIdData = (VMS_FORM_BMPID_DATA*)&msgPtr[nPktIdx];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_download_form;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- int nFormId = DEFAULT_FORMID;
- int nFormCnt = AObj->FormDownload.MaxSchedule; // 폼정보는 하나만 내려보내야 한다. 제어기에서 수용하지 못함
- if (nFormCnt > MAX_VMS_SCENARIO_FORM) {
- nFormCnt = MAX_VMS_SCENARIO_FORM;
- }
- LDEBUG("download_default_form_0x9A: FormId: %d, FormCnt: %d", nFormId, nFormCnt);
- pForm->FORM_ID = htons(nFormId);
- pForm->FORM_CNT = htons(nFormCnt);
- pHead->Length = sizeof(VMS_FORM_HEAD)+(sizeof(VMS_FORM_BMPID_INFO)*nFormCnt);
- for (int ii = 0; ii < nFormCnt; ii++)
- {
- pBmpIdData = (VMS_FORM_BMPID_DATA*)&msgPtr[nPktIdx];
- memset(pBmpIdData, 0x00, sizeof(VMS_FORM_BMPID_DATA));
- pBmpIdData->INFO.data.FORM_SEQ = htons(ii); // 폼 표출 일련번호, 2Byte
- pBmpIdData->INFO.data.DISPLAY_TIME = 4; // 폼의 표출시간을 지정, 1Byte( 0x00 이면 계속 표출 ) ==> 제어기에서 사용안함
- pBmpIdData->INFO.data.DISPLAY_TYPE = e_static_normal; // 폼의 표출유형을 지정, 1Byte
- pBmpIdData->INFO.data.BG_RGB = e_bg_black; // 폼의 배경색을 지정, 1Byte
- pBmpIdData->INFO.data.OBJ_CNT = 1; // 표출할 오브젝트 전체 수, 1Byte
- pBmpIdData->INFO.obj.OBJ_TYPE = e_obj_bitmapid; // 오브젝트 종류
- pBmpIdData->INFO.obj.OBJ_SIZE = htons(sizeof(VMS_OBJ_BITMAPID)); // 오브젝트 데이터 크기
- pBmpIdData->INFO.obj.FLASH = 0x00; // 점멸여부, 1Byte(0x00 : 고정, 0x01 : 점멸)
- pBmpIdData->INFO.obj.X = htons(0); // 좌표 X
- pBmpIdData->INFO.obj.Y = htons(0); // 좌표 Y
- pBmpIdData->INFO.obj.TEXT_BG_RGB = e_bg_black; // 문자열 배경색을 지정
- pBmpIdData->INFO.bmpid.WIDTH = htons(AObj->WIDTH); // 비트맵 표시 Width, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pBmpIdData->INFO.bmpid.HEIGHT = htons(AObj->HEIGHT); // 비트맵 표시 Heitht, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pBmpIdData->INFO.bmpid.IMG_TYPE = e_img_bitmap; // e_img_type
- pBmpIdData->INFO.bmpid.BITMAP_ID = htons(AObj->FormDownload.Info[ii].BitmapId); // 표출할 비트맵 ID, 2 Byte, 0~ 9999 : 표출할 비트맵 ID
- LDEBUG("download_default_form_0x9A: FormSeq: %d, FormId: %d", ii, AObj->FormDownload.Info[ii].BitmapId);
- nPktIdx += sizeof(VMS_FORM_BMPID_DATA);
- }
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_form_0x9A()
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- if (AObj->FormDownload.DownloadCnt && AObj->FormDownload.MaxSchedule &&
- AObj->FormDownload.DownloadCnt >= AObj->FormDownload.MaxSchedule)
- {
- // 폼정보를 모두 다운로드 했기때문에
- // 폼파일을 다운로드 해야 한다.
- AObj->FormDownload.DownloadCnt = 0; // 폼이미지파일을 다운로드해야 하기때문에 다운로드 인덱스를 다시 0으로 리셋
- download_file_0x82();
- return 1;
- }
- BYTE *msgPtr;
- // 파일다운로드
- VMS_HEAD *pHead;
- VMS_FILE_DATA *pFile;
- // 폼다운로드
- VMS_FORM_HEAD *pForm;
- VMS_FORM_BMPID_DATA *pBmpIdData;
- VMS_FORM_VIDEO_DATA *pVideoData;
- WORD crc;
- int nPktSize;
- int nPktIdx;
- nPktIdx = sizeof(VMS_HEAD)+sizeof(VMS_FORM_HEAD);
- msgPtr = (BYTE*)pMsg->Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pForm = (VMS_FORM_HEAD*)&msgPtr[sizeof(VMS_HEAD)];
- pBmpIdData = (VMS_FORM_BMPID_DATA*)&msgPtr[nPktIdx];
- pVideoData = (VMS_FORM_VIDEO_DATA*)&msgPtr[nPktIdx];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_download_form;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- // 폼아이디는 제어기가 최초에 접속했을때 한번만 내려보내기 때문에
- // 폼아이디를 여기서 설정해 주어야 한다.
- BYTE fileType = AObj->FormDownload.Info[AObj->FormDownload.DownloadCnt].fileType;
- AnsiString STRM_ADDR = AObj->FormDownload.Info[AObj->FormDownload.DownloadCnt].STRM_ADDR;
- int nFormId = AObj->FormDownload.Info[AObj->FormDownload.DownloadCnt].FormNo;
- int nBitmapId = AObj->FormDownload.Info[AObj->FormDownload.DownloadCnt].BitmapId;
- int nFormCnt = 1; // 폼정보는 하나만 내려보내야 한다. 제어기에서 수용하지 못함
- pForm->FORM_ID = htons(nFormId);
- pForm->FORM_CNT = htons(nFormCnt);
- // TODO: 20241220
- if (fileType == P_FILE_TYPE_VIDEO) {
- // 동영상 표출
- //LDEBUG("download_form_0x9A: DownloadCnt: %d, FormId: %d, VideoId: %s", AObj->FormDownload.DownloadCnt, nFormId, STRM_ADDR.c_str());
- pHead->Length = sizeof(VMS_FORM_HEAD)+(sizeof(VMS_FORM_VIDEO_INFO)*nFormCnt);
- }
- else {
- //LDEBUG("download_form_0x9A: DownloadCnt: %d, FormId: %d, BitmapId: %d", AObj->FormDownload.DownloadCnt, nFormId, nBitmapId);
- pHead->Length = sizeof(VMS_FORM_HEAD)+(sizeof(VMS_FORM_BMPID_INFO)*nFormCnt);
- }
- //for (int ii = 0; ii < nFormCnt; ii++) {
- if (fileType == P_FILE_TYPE_VIDEO) {
- // 동영상 표출
- pVideoData = (VMS_FORM_VIDEO_DATA*)&msgPtr[nPktIdx];
- memset(pVideoData, 0x00, sizeof(VMS_FORM_VIDEO_DATA));
- pVideoData->INFO.data.FORM_SEQ = htons(nFormId); // 폼 표출 일련번호, 2Byte
- pVideoData->INFO.data.DISPLAY_TIME = 1; // 폼의 표출시간을 지정, 1Byte( 0x00 이면 계속 표출 ) ==> 제어기에서 사용안함
- pVideoData->INFO.data.DISPLAY_TYPE = e_static_normal; // 폼의 표출유형을 지정, 1Byte
- pVideoData->INFO.data.BG_RGB = e_bg_black; // 폼의 배경색을 지정, 1Byte
- pVideoData->INFO.data.OBJ_CNT = 1; // 표출할 오브젝트 전체 수, 1Byte
- pVideoData->INFO.obj.OBJ_TYPE = e_obj_video; // 오브젝트 종류
- pVideoData->INFO.obj.OBJ_SIZE = htons(sizeof(VMS_OBJ_VIDEO)); // 오브젝트 데이터 크기
- pVideoData->INFO.obj.FLASH = 0x00; // 점멸여부, 1Byte(0x00 : 고정, 0x01 : 점멸)
- pVideoData->INFO.obj.X = htons(0); // 좌표 X
- pVideoData->INFO.obj.Y = htons(0); // 좌표 Y
- pVideoData->INFO.obj.TEXT_BG_RGB = e_bg_black; // 문자열 배경색을 지정
- pVideoData->INFO.video.WIDTH = htons(AObj->WIDTH); // 비트맵 표시 Width, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pVideoData->INFO.video.HEIGHT = htons(AObj->HEIGHT); // 비트맵 표시 Heitht, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pVideoData->INFO.video.ETC = 0x00; // 기타
- sprintf(pVideoData->INFO.video.FILE_NM, "%s", STRM_ADDR.c_str()); // 동영상 파일 이름
- nPktIdx += sizeof(VMS_FORM_VIDEO_DATA);
- LINFO("download_form_0x9A: DownloadCnt: %d, FormId: %d, VideoId: %s", AObj->FormDownload.DownloadCnt, nFormId, pVideoData->INFO.video.FILE_NM);
- }
- else {
- pBmpIdData = (VMS_FORM_BMPID_DATA*)&msgPtr[nPktIdx];
- memset(pBmpIdData, 0x00, sizeof(VMS_FORM_BMPID_DATA));
- pBmpIdData->INFO.data.FORM_SEQ = htons(nFormId); // 폼 표출 일련번호, 2Byte
- pBmpIdData->INFO.data.DISPLAY_TIME = 1; // 폼의 표출시간을 지정, 1Byte( 0x00 이면 계속 표출 ) ==> 제어기에서 사용안함
- pBmpIdData->INFO.data.DISPLAY_TYPE = e_static_normal; // 폼의 표출유형을 지정, 1Byte
- pBmpIdData->INFO.data.BG_RGB = e_bg_black; // 폼의 배경색을 지정, 1Byte
- pBmpIdData->INFO.data.OBJ_CNT = 1; // 표출할 오브젝트 전체 수, 1Byte
- pBmpIdData->INFO.obj.OBJ_TYPE = e_obj_bitmapid; // 오브젝트 종류
- pBmpIdData->INFO.obj.OBJ_SIZE = htons(sizeof(VMS_OBJ_BITMAPID)); // 오브젝트 데이터 크기
- pBmpIdData->INFO.obj.FLASH = 0x00; // 점멸여부, 1Byte(0x00 : 고정, 0x01 : 점멸)
- pBmpIdData->INFO.obj.X = htons(0); // 좌표 X
- pBmpIdData->INFO.obj.Y = htons(0); // 좌표 Y
- pBmpIdData->INFO.obj.TEXT_BG_RGB = e_bg_black; // 문자열 배경색을 지정
- pBmpIdData->INFO.bmpid.WIDTH = htons(AObj->WIDTH); // 비트맵 표시 Width, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pBmpIdData->INFO.bmpid.HEIGHT = htons(AObj->HEIGHT); // 비트맵 표시 Heitht, 2 Byte, 0 ~ 1023 : 표출 비트맵 Width
- pBmpIdData->INFO.bmpid.IMG_TYPE = e_img_bitmap; // e_img_type
- pBmpIdData->INFO.bmpid.BITMAP_ID = htons(nBitmapId); // 표출할 비트맵 ID, 2 Byte, 0~ 9999 : 표출할 비트맵 ID
- nPktIdx += sizeof(VMS_FORM_BMPID_DATA);
- LINFO("download_form_0x9A: DownloadCnt: %d, FormId: %d, BitmapId: %d", AObj->FormDownload.DownloadCnt, nFormId, nBitmapId);
- }
- //}
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- AObj->FormDownload.DownloadCnt++;
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_file_0x82()
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- if (AObj->FormDownload.MaxSchedule == 0)
- {
- // 여기 들어오면 안됌, 다운로드할 폼정보가 존해해야 여기 함수를 호출하게 돼있음
- return 0;
- }
- int nDownloadCnt = AObj->FormDownload.DownloadCnt;
- if (nDownloadCnt >= AObj->FormDownload.MaxSchedule)
- {
- // 폼파일이(폼이미지파일) 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
- download_schedule_form_0x96(); // Display Schedule Form
- return 0;
- }
- bool bResult = true;
- BYTE *msgPtr;
- // 파일다운로드
- VMS_HEAD *pHead;
- VMS_FILE_DATA *pFile;
- char *pStrm;
- // 폼다운로드
- VMS_FORM_HEAD *pForm;
- VMS_FORM_BMPID_DATA *pData;
- WORD crc;
- int nPktSize;
- int ii;
- bool isEndDownload = true;
- AObj->pForms->Lock();
- try
- {
- for (ii = nDownloadCnt; ii < AObj->FormDownload.MaxSchedule; ii++)
- {
- AObj->FormDownload.DownloadCnt++;
- int nFormId = AObj->FormDownload.Info[ii].FormNo;
- int nBitmapId = AObj->FormDownload.Info[ii].BitmapId;
- int nFormIdx = AObj->FormDownload.Info[ii].FormIdx;
- if (g_AppCfg.IsCheckNewForm && AObj->FormDownload.Info[ii].IsDownload == false)
- {
- // 이미 다운로드 했기 때문에 다시 다운로드 하지 않는다.
- LDEBUG("download_file_0x82: DownloadCnt: %d, FormId: %d, BitmapId: %d, already download...", ii, nFormId, nBitmapId);
- continue;
- }
- TVmsForm *pForm = AObj->pForms->FLists.Find(nFormIdx);
- if (!pForm)
- {
- continue;
- }
- if (!pForm->Success)
- {
- continue;
- }
- // TODO: 20241220
- if (pForm->fileType == P_FILE_TYPE_STREAM)
- {
- continue;
- }
- if (!pForm->pStream || pForm->pStream->Size == 0)
- {
- continue;
- }
- if (pForm->fileType == P_FILE_TYPE_VIDEO)
- {
- // 필요에 따라서 동영상 FTP 다운로드 프로토콜을 여기서도 사용하자.....
- continue;
- }
- isEndDownload = false;
- AObj->DownloadFormId = AObj->FormDownload.Info[ii].VMS_FORM_ID;
- LDEBUG("download_file_0x82: DownloadCnt: %d, FormId: %d, BitmapId: %d, VMS_FORM_ID: %s", ii, nFormId, nBitmapId, AObj->DownloadFormId.c_str());
- // 다운로드
- msgPtr = (BYTE*)pMsg->Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pFile = (VMS_FILE_DATA*)&msgPtr[sizeof(VMS_HEAD)];
- pStrm = (char*)&msgPtr[sizeof(VMS_HEAD)+sizeof(VMS_FILE_DATA)];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_file_download;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- int nFileNameSize = 11;
- int nFileSize = pForm->pStream->Size;
- nFileNameSize = 11;
- pHead->Length = sizeof(VMS_FILE_DATA)+nFileNameSize+nFileSize;
- pFile->head.SAVE_LOC = e_download_prog_image; // Download Data 저장위치 Code, 1 Byte
- pFile->head.NAME_SIZE = 11; // 파일명 길이, 1 Byte, 1~ 255
- pFile->head.SIZE = nFileSize; // 저장하여야 할 데이터의 크기, 4 Byte
- pForm->pStream->Position = 0;
- try
- {
- sprintf((char*)&pStrm[0], "BID%04d.BMP", nBitmapId);
- memcpy((char*)&pStrm[pFile->head.NAME_SIZE], (char*)pForm->pStream->Memory, nFileSize);
- // 바이트 오더링 변환
- pFile->head.SIZE = htonl(pFile->head.SIZE);
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- break;
- }
- catch(Exception &e)
- {
- bResult = false;
- }
- }
- }
- __finally
- {
- AObj->pForms->UnLock();
- }
- if (isEndDownload)
- {
- // 폼이미지 정보가 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
- download_schedule_form_0x96(); // Display Schedule Form
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_schedule_form_0x96()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- char Buff[1024];
- BYTE *msgPtr;
- VMS_HEAD *pHead;
- VMS_SCHEDULE_FORM *pSche;
- WORD crc;
- int nPktSize;
- msgPtr = Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pSche = (VMS_SCHEDULE_FORM*)&msgPtr[sizeof(VMS_HEAD)];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_download_schedule_form;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = sizeof(VMS_SCHEDULE_FORM);
- memset((char*)pSche, 0x00, sizeof(VMS_SCHEDULE_FORM));
- if (AObj->FormDownload.IsDefault)
- {
- pSche->Form[0].FormNo = htons(DEFAULT_FORMID);
- pSche->Form[0].DispSec = 4;
- LINFO("download_schedule_form_0x96: 0, DEFAULT_FORMID: %d, DispSec: %d", DEFAULT_FORMID, pSche->Form[0].DispSec);
- }
- else
- {
- for (int ii = 0; ii < AObj->FormDownload.MaxSchedule && ii < MAX_VMS_SCENARIO_FORM; ii++)
- {
- pSche->Form[ii].FormNo = htons(AObj->FormDownload.Info[ii].FormNo);
- pSche->Form[ii].DispSec = AObj->FormDownload.Info[ii].DispSec;
- LINFO("download_schedule_form_0x96: %d, FormId: %d, DispSec: %d", ii, AObj->FormDownload.Info[ii].FormNo, AObj->FormDownload.Info[ii].DispSec);
- }
- }
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_blank_0x9E()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- char Buff[1024];
- BYTE *msgPtr;
- VMS_HEAD *pHead;
- WORD crc;
- int nPktSize;
- LDEBUG("download_blank_0x9E: .................");
- msgPtr = Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_vms_blank;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_lib_form_0x0A()
- {
- IPC_JOB_MESSAGE *pMsg = g_jobBuff.GetBuff();
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- if (AObj->FormDownload.MaxSchedule == 0)
- {
- // 여기 들어오면 안됌, 다운로드할 폼정보가 존해해야 여기 함수를 호출하게 돼있음
- return 0;
- }
- int nDownloadCnt = AObj->FormDownload.DownloadCnt;
- if (nDownloadCnt >= AObj->FormDownload.MaxSchedule)
- {
- // 폼파일이(폼이미지파일) 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
- download_schedule_form_0x0E(); // Display Schedule Form
- return 0;
- }
- bool bResult = true;
- BYTE *msgPtr;
- // Download Graphics Library (Full Graphic Data)
- VMS_HEAD *pHead;
- VMS_FULL_GRAPHIC_LIB *pFile;
- WORD crc;
- int nPktSize;
- int ii;
- bool isEndDownload = true;
- AObj->pForms->Lock();
- try
- {
- for (ii = nDownloadCnt; ii < AObj->FormDownload.MaxSchedule; ii++)
- {
- AObj->FormDownload.DownloadCnt++;
- int nFormId = AObj->FormDownload.Info[ii].FormNo;
- int nBitmapId = AObj->FormDownload.Info[ii].BitmapId;
- int nFormIdx = AObj->FormDownload.Info[ii].FormIdx;
- if (g_AppCfg.IsCheckNewForm && AObj->FormDownload.Info[ii].IsDownload == false)
- {
- // 이미 다운로드 했기 때문에 다시 다운로드 하지 않는다.
- LDEBUG("download_lib_form_0x0A: DownloadCnt: %d, FormId: %d, BitmapId: %d, already download...", ii, nFormId, nBitmapId);
- continue;
- }
- TVmsForm *pForm = AObj->pForms->FLists.Find(nFormIdx);
- if (!pForm)
- {
- continue;
- }
- if (!pForm->Success)
- {
- continue;
- }
- if (pForm->fileType == P_FILE_TYPE_VIDEO || pForm->fileType == P_FILE_TYPE_STREAM)
- {
- continue;
- }
- if (!pForm->pStream || pForm->pStream->Size == 0)
- {
- continue;
- }
- if (!pForm->pBitmap || pForm->pBitmap->Width == 0 || pForm->pBitmap->Height == 0)
- {
- continue;
- }
- // pForm->pBitmap->PixelFormat = pf24bit;
- // 픽셀포멧이 24비트여야 ScanLine을 사용할 수 있다. 24비트가 아닌경우에는 다른 방법으로 처리해야 한다.
- isEndDownload = false;
- AObj->DownloadFormId = AObj->FormDownload.Info[ii].VMS_FORM_ID;
- LDEBUG("download_lib_form_0x0A: DownloadCnt: %d, FormId: %d, BitmapId: %d, VMS_FORM_ID: %s", ii, nFormId, nBitmapId, AObj->DownloadFormId.c_str());
- // 다운로드
- msgPtr = (BYTE*)pMsg->Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pFile = (VMS_FULL_GRAPHIC_LIB*)&msgPtr[sizeof(VMS_HEAD)];
- AObj->FTxtOpCode = e_txt_download_full_graphic_lib;
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_txt_download_full_graphic_lib;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = sizeof(VMS_FULL_GRAPHIC_LIB);
- memset((char*)pFile, 0x00, sizeof(VMS_FULL_GRAPHIC_LIB));
- pFile->Phase = 0x00; // 0x00(1phase), 0x01(2phase)
- pFile->DispFunc = 0x07; // 0x07(static)
- pFile->DispDir = 0x00; // 0x00(drop down)
- pFile->MsgNmbr = (WORD)nBitmapId;
- pFile->MsgNmbr = htons(pFile->MsgNmbr);
- try
- {
- int idx = 0;
- int ll, mm;
- int r, g, b;
- int nW = pForm->pBitmap->Width;
- int nH = pForm->pBitmap->Height;
- TPixelFormat PixelFormat = pForm->pBitmap->PixelFormat;
- if (PixelFormat == pf24bit)
- {
- for (ll = 0; ll < nH; ll++)
- {
- TRGBTriple *p = reinterpret_cast<TRGBTriple *>(pForm->pBitmap->ScanLine[ll]);
- for (mm = 0; mm < nW; mm++)
- {
- r = p[mm].rgbtRed;
- g = p[mm].rgbtGreen;
- //b = p[mm].rgbtBlue;
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- }
- }
- }
- else
- if (PixelFormat == pf32bit)
- {
- for (ll = 0; ll < nH; ll++)
- {
- TRGBQuad *p = reinterpret_cast<TRGBQuad *>(pForm->pBitmap->ScanLine[ll]);
- for (mm = 0; mm < nW; mm++)
- {
- r = p[mm].rgbRed;
- g = p[mm].rgbGreen;
- //b = p[mm].rgbBlue;
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- }
- }
- }
- else
- if (PixelFormat == pf16bit)
- {
- //FILE *fp = fopen("C:\\temp.dat", "w+");
- for (ll = 0; ll < nH; ll++)
- {
- WORD *p = reinterpret_cast<WORD *>(pForm->pBitmap->ScanLine[ll]);
- for (mm = 0; mm < nW; mm++)
- {
- r = p[mm] >> 11 & 0x1F; // 5
- g = p[mm] >> 5 & 0x3F; // 6
- //b = p[mm] >> 0 & 0x1F; // 5
- //((blue>>3)<<10) | ((green>>3)<<5) | (red>>3);
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- //if (r > 0 || g > 0) fprintf(fp, "*"); else fprintf(fp, "-");
- }
- //fprintf(fp, "\n");
- }
- //fclose(fp);
- }
- else
- if (PixelFormat == pf8bit)
- {
- PALETTEENTRY PalEntries[257];
- if (pForm->pBitmap->Palette != 0)
- {
- GetPaletteEntries(pForm->pBitmap->Palette, 0, 256, (LPPALETTEENTRY)PalEntries);
- //FILE *fp = fopen("C:\\temp.dat", "w+");
- for (ll = 0; ll < nH; ll++)
- {
- BYTE *p = reinterpret_cast<BYTE *>(pForm->pBitmap->ScanLine[ll]);
- for (mm = 0; mm < nW; mm++)
- {
- r = PalEntries[p[mm]].peRed;
- g = PalEntries[p[mm]].peGreen;
- b = PalEntries[p[mm]].peBlue;
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- //if (r > 0 || g > 0) fprintf(fp, "*"); else fprintf(fp, "-");
- }
- //fprintf(fp, "\n");
- }
- //fclose(fp);
- }
- }
- else
- if (PixelFormat == pf4bit)
- // PixelFormat == pf1bit)
- {
- PALETTEENTRY PalEntries[17];
- if (pForm->pBitmap->Palette != 0)
- {
- int clrIdx;
- GetPaletteEntries(pForm->pBitmap->Palette, 0, 16, (LPPALETTEENTRY)PalEntries);
- //FILE *fp = fopen("C:\\temp.dat", "w+");
- for (ll = 0; ll < nH; ll++)
- {
- BYTE *p = reinterpret_cast<BYTE *>(pForm->pBitmap->ScanLine[ll]);
- for (mm = 0; mm < nW/2; mm++)
- {
- clrIdx = (p[mm] >> 4) & 0xF;
- r = PalEntries[clrIdx].peRed;
- g = PalEntries[clrIdx].peGreen;
- b = PalEntries[clrIdx].peBlue;
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- //if (r > 0 || g > 0) fprintf(fp, "*"); else fprintf(fp, "-");
- clrIdx = p[mm] & 0xF;
- r = PalEntries[clrIdx].peRed;
- g = PalEntries[clrIdx].peGreen;
- b = PalEntries[clrIdx].peBlue;
- if (r > g_AppCfg.PixelValue) CComm_SetBitString(pFile->R_Data1, idx, 1);
- if (g > g_AppCfg.PixelValue) CComm_SetBitString(pFile->G_Data1, idx, 1);
- idx++;
- //if (r > 0 || g > 0) fprintf(fp, "*"); else fprintf(fp, "-");
- }
- //fprintf(fp, "\n");
- }
- //fclose(fp);
- }
- }
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- break;
- }
- catch(Exception &e)
- {
- bResult = false;
- }
- }
- }
- __finally
- {
- AObj->pForms->UnLock();
- }
- if (isEndDownload)
- {
- // 폼이미지 정보가 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
- download_schedule_form_0x0E(); // Display Schedule Form
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_schedule_form_0x0E()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- char Buff[1024];
- BYTE *msgPtr;
- VMS_HEAD *pHead;
- VMS_SCHEDULE_FORM *pSche;
- WORD crc;
- int nPktSize;
- AObj->FTxtOpCode = e_txt_display_schedule_msg;
- msgPtr = Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pSche = (VMS_SCHEDULE_FORM*)&msgPtr[sizeof(VMS_HEAD)];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_txt_display_schedule_msg;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = sizeof(VMS_SCHEDULE_FORM);
- memset((char*)pSche, 0x00, sizeof(VMS_SCHEDULE_FORM));
- for (int ii = 0; ii < AObj->FormDownload.MaxSchedule && ii < MAX_VMS_SCENARIO_FORM; ii++)
- {
- pSche->Form[ii].FormNo = htons(AObj->FormDownload.Info[ii].FormNo);
- pSche->Form[ii].DispSec = AObj->FormDownload.Info[ii].DispSec;
- LINFO("download_lib_form_0x0A: %d, FormId: %d, DispSec: %d", ii, AObj->FormDownload.Info[ii].FormNo, AObj->FormDownload.Info[ii].DispSec);
- }
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::download_blank_0x16()
- {
- TCDSCtlr *AObj = FCDSCtlr;
- if (!AObj) return -1;
- char Buff[1024];
- BYTE *msgPtr;
- VMS_HEAD *pHead;
- WORD crc;
- int nPktSize;
- AObj->FTxtOpCode = e_txt_blank;
- msgPtr = Buff;
- pHead = (VMS_HEAD*)&msgPtr[0];
- pHead->Dle = VMS_DLE;
- pHead->Stx = VMS_STX;
- pHead->Group = AObj->GROUP_NO;
- pHead->Ctlr = AObj->CTLR_LOCAL_NO;
- pHead->OpCode = e_txt_blank;
- pHead->Curr = 1;
- pHead->Total = 1;
- pHead->Length = 0;
- nPktSize = sizeof(VMS_HEAD)+pHead->Length-2; //DLE/STX
- crc = GETCRC16((char*)&pHead->Group, nPktSize);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+0] = VMS_DLE;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+1] = VMS_ETX;
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+2] = HIBYTE(crc);
- msgPtr[sizeof(VMS_HEAD)+pHead->Length+3] = LOBYTE(crc);
- SendPacketDLE((char*)msgPtr, nPktSize+6, AObj->IsDle);
- return 1;
- }
- //---------------------------------------------------------------------------
- int TClientSession::ReqSendPacket(char *ACmd, int ALen)
- {
- VMS_HEAD *pHead = (VMS_HEAD*)ACmd;
- if (ALen <= 0)
- {
- return -1;
- }
- if (!SendRequest(ACmd, ALen))
- {
- SERROR("+CLI ReqSendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), pHead->OpCode);
- MERROR("+CLI ReqSendPacket send request faild: %s, 0x%02X will be closed.", FIpAddress.c_str(), pHead->OpCode);
- Disconnect();
- return -2;
- }
- SendFlushComplete();
- return 1;
- }
- //---------------------------------------------------------------------------
|