VOID CVariableSystem::Initial(VOID*) { //----------------------------------------------------------- //加载 m_mapCurrent.clear(); LoadVariable(SYSTEM_CFG, m_mapCurrent); if(GetAs_Int("GameServer_ConnectDirect")==0) LoadVariable(USER_CFG, m_mapCurrent); m_mapNeedSave.clear(); //创建帐号配置文件目录 ::CreateDirectory("..\\Accounts", 0); //----------------------------------------------------------- //导出函数 m_pMetaTable = new LuaPlus::LuaObject; *m_pMetaTable = CScriptSystem::GetMe()->GetLuaState()->GetGlobals().CreateTable("Variable"); m_pMetaTable->SetObject("__index", *m_pMetaTable); m_pMetaTable->RegisterObjectFunctor("GetVariable", &CVariableSystem::Lua_GetGlobalVariable); m_pMetaTable->RegisterObjectFunctor("SetVariable", &CVariableSystem::Lua_SetGlobalVariable); LuaPlus::LuaObject obj_Variable = CScriptSystem::GetMe()->GetLuaState()->BoxPointer(this); obj_Variable.SetMetaTable(*m_pMetaTable); CScriptSystem::GetMe()->GetLuaState()->GetGlobals().SetObject("Variable", obj_Variable); SetAs_Int("DebugMode", g_bDebugMode); }
void CVariableSystem::LoadPrivateConfig() { STRING szAccount,szUser; GetVariable("Game_Account",szAccount); GetVariable("Character_Name",szUser); ConvertOldSaving_pfc( szAccount, szUser );//转换旧目录 ::WritePrivateProfileString("Variable", "Login_Area", GetAs_String("Login_Area").c_str(), USER_CFG ); ::WritePrivateProfileString("Variable", "Login_Server", GetAs_String("Login_Server").c_str(), USER_CFG); ::WritePrivateProfileString("Variable", "Login_Provider", GetAs_String("Login_Provider").c_str(), USER_CFG); std::string srcAcc = szAccount; std::string srcUser = szUser; std::string dstAcc = ""; std::string dstUser = ""; StringEncrypt( srcAcc, dstAcc ); StringEncrypt( srcUser, dstUser ); CHAR szTemp[120]; //_snprintf(szTemp, 120, "..\\Accounts\\%s\\%s.pfc", szAccount.c_str(), szUser.c_str()); _snprintf(szTemp, 120, "..\\Accounts\\%s\\%s.pfc", dstAcc.c_str(), dstUser.c_str()); LoadVariable(szTemp, m_mapCurrent); KLU_Log("Load private profile:%s,%s", szAccount.c_str(), szUser.c_str()); }
/* -------------------------------------------------------------------- */ void ToggleWaveLengthScale(Widget w, XtPointer client, XtPointer call) { if (((XmToggleButtonCallbackStruct *)call)->set) { if (!plotWaveNumber()) { if (tas.data) { delete [] tas.data; tas.data = NULL; } if (LoadVariable(&tas, tasVarName) == ERR) { XmToggleButtonSetState(pmOptButt[5], false, false); sprintf(buffer, "Can't locate True Airspeed variable %s.", tasVarName.c_str()); ShowError(buffer); return; } } } else { if (!plotWaveNumber()) { delete [] tas.data; tas.data = NULL; } } } /* END TOGGLEWAVELENGTHSCALE */
bool CRegArchive::LoadVariable(LPCTSTR lpName, unsigned short& Var) { unsigned long tvar; if (LoadVariable(lpName, tvar)) { Var = (unsigned short)tvar; return true; } else return false; }
bool CRegArchive::LoadVariable(LPCTSTR lpName, int& Var) { long tvar; if (LoadVariable(lpName, tvar)) { Var = (int)tvar; return true; } else return false; }
bool CRegArchive::LoadVariable(LPCTSTR lpName, bool& Var) { ATLASSERT(m_hKey); long tempvar; if (!LoadVariable(lpName, tempvar)) return false; else { Var = tempvar?true:false; return true; } }
ret_ CXMLLoaderActions::LoadDualityCalculate(CProgram &Program, const DOMElement *pElement, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); #endif // auto_xerces_str wsOperator ("operator"); auto_xerces_str sOperator (pElement->getAttribute(wsOperator)); EDualityCalculate Calculate; if (SUCCESS != GetDualityOperator(sOperator, Calculate)) return XML_LOADER_ERROR; // DOMElement *pSub = (DOMElement *)pElement->getFirstChild(); if (!pSub) return XML_LOADER_ERROR; CAutoPtr<CVariable> OV[3]; size_ n = 0; while (pSub) { ret_ Ret = LoadVariable(Program.Data(), pSub, OV[n].Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) if (3 <= ++n) break; pSub = (DOMElement *)pSub->getNextSibling(); } COptDualityCalculate *pODC = new COptDualityCalculate( OV[0].Ptr(), Calculate, OV[1].Ptr(), OV[2].Ptr()); if (false_v == Program.AddOperator(pODC)) return XML_LOADER_ERROR; return SUCCESS; }
ret_ CXMLLoaderActions::LoadAddItem(CProgram &Program, const DOMElement *pElement, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); #endif auto_xerces_str wsName("name"); auto_xerces_str sName(pElement->getAttribute(wsName)); // Check if there is the container if (!m_pTmpContainer) return XML_LOADER_ERROR; // Check if there is the table identified by the attribute CWindow *pWindow = m_pTmpContainer->GetChild(sName); if (!pWindow || WINDOW_TABLE != pWindow->Type()) return XML_LOADER_ERROR; COptAddItem *pOpt = new COptAddItem(sName); DOMElement *pSub = (DOMElement *)pElement->getFirstChild(); if (!pSub) return XML_LOADER_ERROR; while (pSub) { CVariable *pV = null_v; ret_ Ret = LoadVariable(Program.Data(), pSub, pV, pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) pOpt->AddVariable(pV); pSub = (DOMElement *)pSub->getNextSibling(); } if (false_v == Program.AddOperator(pOpt)) return XML_LOADER_ERROR; return SUCCESS; }
ret_ CXMLLoaderActions::LoadReadFile(CProgram &Program, const DOMElement *pElement, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); #endif DOMElement *pSub = (DOMElement *)pElement->getFirstChild(); if (!pSub) return XML_LOADER_ERROR; CAutoPtr<CVariable> OV[3]; size_ n = 0; while (pSub) { ret_ Ret = LoadVariable(Program.Data(), pSub, OV[n].Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) if (3 <= ++n) break; pSub = (DOMElement *)pSub->getNextSibling(); } if (n != 3) return XML_LOADER_ERROR; COptReadFile *pOperator = new COptReadFile(OV[0].Ptr(), OV[1].Ptr(), OV[2].Ptr()); if (false_v == Program.AddOperator(pOperator)) return XML_LOADER_ERROR; return SUCCESS; }
/* -------------------------------------------------------------------- */ void ToggleWaveNumberScale(Widget w, XtPointer client, XtPointer call) { static float min, max; if (((XmToggleButtonCallbackStruct *)call)->set) { min = specPlot.Xaxis.min; max = specPlot.Xaxis.max; if (!plotWaveLength()) { if (tas.data) { delete [] tas.data; tas.data = NULL; } if (LoadVariable(&tas, tasVarName) == ERR) { sprintf(buffer, "Can't locate True Airspeed variable %s.", tasVarName.c_str()); ShowError(buffer); } } specPlot.Xaxis.min = (min * 2.0*M_PI / tas.stats.mean); specPlot.Xaxis.max = (max * 2.0*M_PI / tas.stats.mean)+1; specPlot.Xaxis.label = "Wave Number (rad/m)"; } else { specPlot.Xaxis.min = min; specPlot.Xaxis.max = max; specPlot.Xaxis.label = "Frequency (Hz)"; if (!plotWaveLength()) { delete [] tas.data; tas.data = NULL; } } specPlot.Xaxis.nMajorTics = (int)(specPlot.Xaxis.max - specPlot.Xaxis.min); SetSpecDefaults(); } /* END TOGGLEWAVENUMBERSCALE */
ret_ CXMLLoaderActions::LoadEmpty(CProgram &Program, const DOMElement *pElement, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); #endif // DOMElement *pSub = (DOMElement *)pElement->getFirstChild(); if (!pSub) return XML_LOADER_ERROR; CAutoPtr<CVariable> OV; while (pSub) { ret_ Ret = LoadVariable(Program.Data(), pSub, OV.Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) break; pSub = (DOMElement *)pSub->getNextSibling(); } COptEmpty *pOperator = new COptEmpty(OV.Ptr()); if (false_v == Program.AddOperator(pOperator)) return XML_LOADER_ERROR; return SUCCESS; }
bool CRegArchive::LoadText(LPCTSTR lpName, CString& Var) { return LoadVariable(lpName, Var); }
bool CRegArchive::LoadDefText(CString& Var) { return LoadVariable(NULL, Var); }
BOOL CAgentService::OnStartService() { UINT startTick, curTick, resetTick; int nState, nError; // Create Directory InitializeDirectories(); /*-- Database Helper Initiliaze --*/ theDBRepository.Initialize(); // Initialize Variable LoadVariable(); DisplayPatchInfo(); #if defined(__INCLUDE_GPIO__) // Initialize GPIO (POWER/LED) //sy GPIOAPI_Initialize(TRUE,MOBILE_MODULE_TYPE_GE910, TRUE); #endif /*-- Transaction Manager Initialize --*/ theTransactionManager.Initialize(); // Command Control Service Initialize IF4API_Initialize(m_nLocalPort, m_CommandHandler); IF4API_SetID(m_nSystemID); // Watchdog initialize theWatchdog.Initialize(); //software watch dog theStatusMonitor.Initialize(); //hardware watchdog theRealTimeClock.Initialize(); //external RTC circuit theUserManager.LoadUser(); //user management -> CLI theTempManager.Initialize(); //external Temperature Sensor theEventManager.Initialize(); // 사용하지 않는 AlarmManager 삭제 //theAlarmManager.Initialize(); theMeterFileWriter.Initialize(); theLpWriter.Initialize(); theMalfMonitor.Initialize(); theMeterUploader.Initialize(); //upload metering data file to server(through GSM interface) theTimeoutHash.Initialize(); theAutoReset.Initialize(); theEndDeviceList.Initialize(); theMeterDeviceList.Initialize(); theSystemMonitor.Initialize(); thePowerOutage.Initialize(); theInventoryScanner.Initialize(); theDistributor.Initialize(); // Protocol Library 초기화 PROTOCOL_DLMS_INIT; // DLMS Protocol libary support PROTOCOL_MBUS_INIT; // MBUS Protocol libary support PROTOCOL_KMP_INIT; // KMP Protocol libary support // CODIAPI 초기화 nError = codiInit(); if(nError != CODIERR_NOERROR) { XDEBUG("nError = %d -------%d\r\n", nError,__LINE__); //ReportError(NULL, nError); return FALSE; } theInventoryHash.Initialize(); // 새로운 Coordinator 장치를 등록한다 nError = codiRegister(&m_codiHandle, &codiDevice); if(nError != CODIERR_NOERROR) { XDEBUG("nError = %d -------%d\r\n", nError,__LINE__); //ReportError(NULL, nError); codiUnregister(m_codiHandle); codiExit(); return FALSE; } // Coordinator 서비스를 시작합니다. nError = codiStartup(m_codiHandle); if (nError != CODIERR_NOERROR) { XDEBUG("nError = %d -------%d\r\n", nError,__LINE__); //ReportError(NULL, nError); codiUnregister(m_codiHandle); codiExit(); return FALSE; } { /** Issue #2567: Patch 상태에 따라 Coodinator Link 절차 사용 여부를 설정한다 */ #if defined(__PATCH_9_2567__) Patch_9_2567_Handler(8, 9, 2567, (*m_pbPatch_9_2567) , const_cast<char *>("Remove Link Procedure")); #endif } // 코디네이터가 초기화되었는지 확인한다. startTick = resetTick = GetSysUpTime(); XDEBUG("COORDINATOR AUTO RESET ######################### \r\n"); CoordinatorPowerControl(TRUE); usleep(1000000); resetTick = GetSysUpTime(); for(;;) { usleep(200000); nState = codiGetState(m_codiHandle); // XDEBUG("-------- COORDINATOR STATE = %d -------\r\n", nState); if ((nState != CODISTATE_NOT_CONNECTED) && (nState != CODISTATE_NO_RESPONSE)) break; curTick = GetSysUpTime(); if ((curTick-startTick) > 12) break; if ((curTick-resetTick) > 4) { XDEBUG("COORDINATOR AUTO RESET ######################### \r\n"); CoordinatorPowerControl(TRUE); resetTick = GetSysUpTime(); } } m_pZigbeeServer->Initialize(); theMetering.Initialize(); theMeterReader.Initialize(); theRecovery.Initialize(); thePolling.Initialize(); theTimesync.Initialize(); // SENSOR-TIMESYNC: Many to one network (LOW RAM) theBatchJob.Initialize(); theBypassQueue.Initialize(); m_pMalfMonitor->CheckExceptCleaning(); // MCU Startup Event mcuStartupEvent(); return TRUE; }
VOID CVariableSystem::Initial(VOID*) { LoadVariable(".\\WXSystem.cfg", m_mapCurrent); m_mapNeedSave.clear(); }
ret_ CXMLLoaderActions::LoadSend(CProgram &Program, const DOMElement *pElement, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); #endif // CProtocolInfo *pProtocol = CProtocolManager::Instance()->GetProtocol(); // auto_xerces_str wsPDU ("pdu"); auto_xerces_str sPDU (pElement->getAttribute(wsPDU)); CPDUInfo *pPDUInfo = null_v; if (SUCCESS != (pProtocol->GetPDU(sPDU, pPDUInfo))) return XML_LOADER_ERROR; COptSend *pOperator = new COptSend(pPDUInfo); // For send operation, sub elements are not necessary. DOMElement *pSub = (DOMElement *)pElement->getFirstChild(); if (pSub) { auto_xerces_str wsFieldVariable("field_variable"); auto_xerces_str wsFieldName("field_name"); while (pSub) { if (0 == XMLString::compareString(pSub->getNodeName(), wsFieldVariable)) { // DOMElement *pVariable = (DOMElement *)pSub->getFirstChild(); CAutoPtr<CVariable> OV_; if (!pVariable) return XML_LOADER_ERROR; while (pVariable) { ret_ Ret = LoadVariable(Program.Data(), pVariable, OV_.Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) break; pVariable = (DOMElement *)pVariable->getNextSibling(); } // auto_xerces_str sFieldName(pSub->getAttribute(wsFieldName)); CField *pField = null_v; if (SUCCESS != pPDUInfo->GetField(sFieldName, pField)) return XML_LOADER_ERROR; // if (false_v == pOperator->AddEvaluate(sFieldName, OV_.Ptr())) return XML_LOADER_ERROR; } pSub = (DOMElement *)pSub->getNextSibling(); } } if (false_v == Program.AddOperator(pOperator)) return XML_LOADER_ERROR; return SUCCESS; }
void VM::Execute() { while (m_running) { ByteCode code = m_functions[m_frames.back().FunctionID()].GetByteCode(m_frames.back().NextInstruction()); switch (code.GetInstruction()) { case Instruction::NOP: break; case Instruction::STOP: m_running = false; break; case Instruction::ADD: Add(m_frames.back()); break; case Instruction::SUB: Sub(m_frames.back()); break; case Instruction::MUL: Mul(m_frames.back()); break; case Instruction::DIV: Div(m_frames.back()); break; case Instruction::PRINT: Print(m_frames.back()); break; case Instruction::PRINTLINE: PrintLine(m_frames.back()); break; case Instruction::COMPARE: Compare(m_frames.back()); break; case Instruction::COMPARE_NULL: CompareNull(m_frames.back()); break; case Instruction::JUMP_IF_TRUE: JumpIfTrue(m_frames.back(), code.GetObject()); break; case Instruction::JUMP_IF_FALSE: JumpIfFalse(m_frames.back(), code.GetObject()); break; case Instruction::JUMP: Jump(m_frames.back(), code.GetObject()); break; case Instruction::CALLFUNCTION: CallFunction(this, m_frames.back()); break; case Instruction::RETURN: Return(this, m_frames.back()); break; case Instruction::PUSH: Push(m_frames.back(), code.GetObject()); break; case Instruction::POP: Pop(m_frames.back()); break; case Instruction::LOAD_VARIABLE: LoadVariable(m_frames.back(), code.GetObject()); break; case Instruction::STORE_VARIABLE: StoreVariable(m_frames.back(), code.GetObject()); break; case Instruction::ALLOCATE_PTR: AllocatePtr(m_frames.back(), m_memory_manager); break; case Instruction::WRITE_PTR: WritePtr(m_frames.back(), m_memory_manager); break; case Instruction::READ_PTR: ReadPtr(m_frames.back(), m_memory_manager); break; case Instruction::SWAP: Swap(m_frames.back()); break; default: throw UndefinedInstructionError(std::string("Instruction ") + std::to_string(static_cast<int>(code.GetInstruction())) + " was not recognized by the virtual machine"); } } }
bool CRegArchive::LoadVariable(LPCTSTR lpName, unsigned long& Var) { return LoadVariable(lpName, (long&)Var); }
ret_ CXMLLoaderActions::LoadExpression(const CData &Data, const DOMElement *pElement, CExpression *&pExpression, const CPDUInfo *pPDU) { #ifdef _DEBUG_ if (!pElement) return (PARAMETER_NULL | PARAMETER_2); if (pExpression) return (PARAMETER_NOT_NULL | PARAMETER_3); #endif auto_xerces_str wsExpressionUnitary ("expression_unitary"); auto_xerces_str wsExpressionDuality ("expression_duality"); auto_xerces_str wsConditionUnitary ("condition_unitary"); auto_xerces_str wsConditionDuality ("condition_duality"); auto_xerces_str wsCalculate ("calculate"); auto_xerces_str wsRelation ("relation"); if (0 == XMLString::compareString(pElement->getNodeName(), wsExpressionUnitary)) { DOMElement *pChild = (DOMElement *)pElement->getFirstChild(); if (!pChild) return XML_LOADER_ERROR; CExpression *pExp = null_v; while (pChild) { if (0 == XMLString::compareString(pChild->getNodeName(), wsExpressionUnitary) || 0 == XMLString::compareString(pChild->getNodeName(), wsExpressionDuality) || 0 == XMLString::compareString(pChild->getNodeName(), wsConditionUnitary) || 0 == XMLString::compareString(pChild->getNodeName(), wsConditionDuality)) { if (SUCCESS != LoadExpression(Data, pChild, pExp, pPDU)) return XML_LOADER_ERROR; break; } pChild = (DOMElement *)pChild->getNextSibling(); } if (!pExp) return XML_LOADER_ERROR; pExpression = (CExpression *)new CExpNot(pExp); } else if (0 == XMLString::compareString(pElement->getNodeName(), wsExpressionDuality)) { DOMElement *pChild = (DOMElement *)pElement->getFirstChild(); if (!pChild) return XML_LOADER_ERROR; size_ n = 0; CExpression *pExp[2] = {null_v, null_v}; while (pChild) { if (2 <= n) break; if (0 == XMLString::compareString(pChild->getNodeName(), wsExpressionUnitary) || 0 == XMLString::compareString(pChild->getNodeName(), wsExpressionDuality) || 0 == XMLString::compareString(pChild->getNodeName(), wsConditionUnitary) || 0 == XMLString::compareString(pChild->getNodeName(), wsConditionDuality)) { if (SUCCESS != LoadExpression(Data, pChild, pExp[n++], pPDU)) return XML_LOADER_ERROR; } pChild = (DOMElement *)pChild->getNextSibling(); } if (2 != n) return XML_LOADER_ERROR; auto_xerces_str sRelation(pElement->getAttribute(wsRelation)); if (0 == strcmp((const ch_1 *)sRelation, "and")) pExpression = (CExpression *)new CExpAnd(pExp[0], pExp[1]); else if (0 == strcmp((const ch_1 *)sRelation, "or")) pExpression = (CExpression *)new CExpOr(pExp[0], pExp[1]); else return XML_LOADER_ERROR; } else if (0 == XMLString::compareString(pElement->getNodeName(), wsConditionUnitary)) { DOMElement *pChild = (DOMElement *)pElement->getFirstChild(); if (!pChild) return XML_LOADER_ERROR; CAutoPtr<CVariable> v; while (pChild) { ret_ Ret = LoadVariable(Data, pChild, v.Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) break; pChild = (DOMElement *)pChild->getNextSibling(); } pExpression = new CExpVarUnitary(v.Ptr()); } else if (0 == XMLString::compareString(pElement->getNodeName(), wsConditionDuality)) { DOMElement *pChild = (DOMElement *)pElement->getFirstChild(); if (!pChild) return XML_LOADER_ERROR; CAutoPtr<CVariable> v[2]; size_ n = 0; while (pChild) { ret_ Ret = LoadVariable(Data, pChild, v[n].Ptr(), pPDU); if (SUCCESS != Ret && XML_INVALID_ELEMENT != Ret) return Ret; if (SUCCESS == Ret) if (2 <= ++n) break; pChild = (DOMElement *)pChild->getNextSibling(); } auto_xerces_str sOperator(pElement->getAttribute(wsCalculate)); ECompareCalculate Calculate; if (SUCCESS != GetCompareOperator((const ch_1 *)sOperator, Calculate)) return XML_LOADER_ERROR; pExpression = new CExpVarDuality(v[0].Ptr(), Calculate, v[1].Ptr()); } return SUCCESS; }