int GetLastFileName(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString Inpath (ctx->GetLastCmoLoaded()); CKParameterOut *pout = beh->GetOutputParameter(0); pout->SetStringValue(Inpath.Str()); PathRemoveFileSpec(Inpath.Str()); CKParameterOut *pout2 = beh->GetOutputParameter(1); pout2->SetStringValue(Inpath.Str()); beh->ActivateOutput(0); return 0; }
//************************************ // Method: vt_SetOutVal // FullName: vt_SetOutVal // Access: public static // Returns: PyObject * // Qualifier: // Parameter: PyObject * self // Parameter: PyObject * args //************************************ static PyObject *vt_SetOutVal( PyObject * self, PyObject * args ) { int size = PyTuple_Size(args); PyObject *val; int bid, index; PyArg_ParseTuple(args, "iiO", &bid, &index,&val); CK_ID cid = bid; CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid)); if (size!=3) { pym->m_Context->OutputToConsole("PyError : This function only accepts 3 arguments : \n\t bid,index,value "); Py_RETURN_NONE; } using namespace vtTools; if (beh && val && index < beh->GetOutputParameterCount() ) { if (PyInt_Check(val)) { long ret = PyInt_AsLong(val); int retx = static_cast<int>(ret); beh->SetOutputParameterValue(index,&retx); Py_RETURN_NONE; } if (PyFloat_Check(val)) { double ret = PyFloat_AsDouble(val); float retx = static_cast<float>(ret); beh->SetOutputParameterValue(index,&retx); Py_RETURN_NONE; } if (PyString_Check(val)) { std::string ret; CKParameterOut * pout = beh->GetOutputParameter(index); XString retx(ret.c_str()); pout->SetStringValue(retx.Str()); Py_RETURN_NONE; } if (PyTuple_Check(val)) { std::string outList = to_string(val); CKParameterOut * pout = beh->GetOutputParameter(index); XString retx(outList.c_str()); pout->SetStringValue(retx.Str()); Py_RETURN_NONE; } } Py_RETURN_NONE; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLBuildCommand::BehaviourFunction(const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; if( behavior->IsInputActive(EGBLBuildCommandBehInputs::BuildCommand) ) { DeactivateInputs(behaviorContext); DeactivateOutputs(behaviorContext); return DoBuildCommand (behaviorContext); } if( behavior->IsInputActive(EGBLBuildCommandBehInputs::CancelOperation)) { DeactivateInputs(behaviorContext); DeactivateOutputs(behaviorContext); ClearParameterOutputs (behaviorContext); int stateValue = EGBLBuildCommandState::Initial; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue); int initialParameterPosition = 0; behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition); char *emptyString = ""; behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Cancelled); } if( behavior->IsInputActive(EGBLBuildCommandBehInputs::ReadNextParameterValue)) { DeactivateInputs(behaviorContext); DeactivateOutputs(behaviorContext); int stateValue = 0; behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue); if (! ( (stateValue == EGBLBuildCommandState::AwaitingParametersForUntargeted) || (stateValue == EGBLBuildCommandState::AwaitingParametersForNetwork) || (stateValue == EGBLBuildCommandState::GetTargets) ) ) { int stateValue = EGBLBuildCommandState::Initial; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue); int initialParameterPosition = 0; behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition); char *emptyString = ""; behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1); CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); } return DoReadNextParameterValue (behaviorContext); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAESetLoadState::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; CGBLLAEManager *laeManager = (CGBLLAEManager *)ctx->GetManagerByGuid(GBLLAEManagerGUID); if (laeManager) { int state = 0; beh->GetInputParameterValue(0, &state); laeManager->SetLoadState(state); beh->ActivateInput(0, FALSE); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(0); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CANTSETLAEIDENTITY,GBLLAE_ERROR_CANTSETLAEIDENTITY_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int RetrieveCICB( const CKBehaviorContext& behaviorContext ) * * Description : The Behavior Callback function is called by Virtools when various events happen * in the life of a BuildingBlock. Exactly which events trigger a call to the * Behavior Callback function is defined in the Behavior Prototype, along with the * declaration of the function pointer * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values. * ******************************************************************* */ CKERROR RetrieveCICB(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior *beh = behcontext.Behavior; CKContext* ctx = beh->GetCKContext(); CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); /************************************************************************/ /* process virtools callbacks : */ /* */ switch(behcontext.CallbackMessage) { case CKM_BEHAVIOREDITED: case CKM_BEHAVIORSETTINGSEDITED: { assert(beh && ctx); BOOL getAsString,outputAttriubtes = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); ////////////////////////////////////////////////////////////////////////// // get ci by string if(getAsString) { CKParameterOut* ciValue = beh->GetOutputParameter(0); ciValue->SetType(pm->ParameterGuidToType(CKPGUID_STRING)); } if(outputAttriubtes) { beh->CreateOutputParameter("Default Value",CKPGUID_STRING); beh->CreateOutputParameter("Unique name",CKPGUID_STRING); beh->CreateOutputParameter("Description",CKPGUID_STRING); beh->CreateOutputParameter("Runtime flags",CIPRTFLAGSGUID); beh->CreateOutputParameter("Type",CKPGUID_PARAMETERTYPE); } int p_count = beh->GetOutputParameterCount(); while( (outputAttriubtes ? BEH_OUT_MAX_COUNT : BEH_OUT_MIN_COUNT ) < p_count ) { CKDestroyObject( beh->RemoveOutputParameter( --p_count) ); } } } return CKBR_OK; }
/* ******************************************************************* * Function: int GetCIS( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GetCIS(const CKBehaviorContext& behcontext) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // Retrieving min data : CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID)); IGBLCIAccessInterface *accessInterface = cman->GetCISAccessInterface(); CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_OUT_INDEX_ERROR); int idCIS = GBLCommon::BehaviorTools::GetInputParameterValue<int>(beh,BEH_IN_INDEX_CIS); CGBLCOError returnValue = accessInterface->GetCIS(idCIS); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }
int DirToArray(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1)); int rec; beh->GetInputParameterValue(2,&rec); if( beh->IsInputActive(0) ){ beh->ActivateInput(0,FALSE); flist.erase(flist.begin(),flist.end()); CKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec); char* str = NULL; while(str = MyParser.GetNextFile()) flist.push_back(XString(str)); counter = 0; beh->ActivateInput(1,TRUE); } if( beh->IsInputActive(1) ){ beh->ActivateInput(1,FALSE); if ( counter < flist.size() ){ XString entry = flist.at(counter); CKParameterOut * pout = beh->GetOutputParameter(0); pout->SetStringValue(entry.Str() ); counter++; beh->SetOutputParameterValue(1,&counter); beh->ActivateOutput(1); }else{ beh->SetOutputParameterValue(1,&counter); counter = 0 ; beh->ActivateOutput(0); } } return 0; }
int GBLCOSetID::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; behaviour->ActivateInput(ECGBLCOSetLAIDBehInputs::InSetIdentity, FALSE); CKAttributeManager*attributeManager = context->GetAttributeManager(); if (attributeManager != NULL) { CKLevel *level = context->GetCurrentLevel(); if ( level != NULL ) { int attributeType = attributeManager->GetAttributeTypeByName("GBLCOLAID"); if (attributeType == -1) attributeType = attributeManager->RegisterNewAttributeType("GBLCOLAID", GUID_TGBLLAID, CKCID_BEOBJECT); else if ( level->HasAttribute(attributeType) ) level->RemoveAttribute(attributeType); attributeManager->SetAttributeCategory(attributeType,"GBL"); level->SetAttribute(attributeType); CKParameter*attribute = level->GetAttributeParameter(attributeType); if ( attribute != NULL ) { CKParameterIn*pin = behaviour->GetInputParameter(ECGBLCOSetLAIDBehInputs::InSetIdentity); CKParameter*laid = pin->GetDirectSource(); if ( laid != NULL ) { CKERROR err = attribute->CopyValue(laid); if ( err == CK_OK ) { behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, TRUE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, FALSE); return CKBR_OK; } } } } } CKParameterOut *parameterOutError = behaviour->GetOutputParameter(ECGBLCOSetLAIDParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLCO_ERROR_SETID_ATTRIBUTE,GBLCO_ERROR_SETID_ATTRIBUTE_DESC); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, FALSE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, TRUE); return CKBR_GENERICERROR; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAEGetLA::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAAccess *laInterface = storageManager->GetLAInterface(); char *arrayName = "laList"; CKDataArray* array; array = (CKDataArray *)ctx->GetObjectByNameAndClass(arrayName,CKCID_DATAARRAY,NULL); if ( !array ) { array = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,arrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( array ); array->InsertColumn( -1, CKARRAYTYPE_INT, "LAID" ); } else { array->Clear(); } CGBLCOError res = laInterface->RetrieveLAList(array); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { beh->ActivateInput(0, FALSE); beh->SetOutputParameterObject(0, array); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(1); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_GETLISTOFLAIDS,GBLLAE_ERROR_GETLISTOFLAIDS_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAESetLAEData::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface(); int cisid; CGBLLAID laid; XString xlaid; XString laeName; int laeState = 0; CKDataArray *userIDList = NULL; CGBLLAEID laeid = 0; int dlaeid; beh->GetInputParameterValue(1, &dlaeid); laeid = dlaeid; GBLLAEDataType::GetGBLLAEData(beh->GetInputParameter(0)->GetRealSource(), cisid, laeName, laeState, xlaid, &userIDList ); laid.FromString(xlaid); CGBLCOError res = laeInterface->StoreLAE (laeState, cisid, laid, laeName, &laeid); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { beh->ActivateInput(0, FALSE); beh->ActivateOutput(0); } else { CKParameterOut *parameterOutError = beh->GetOutputParameter(0); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) * * Description : This function sets corresponding outputs with requested argument's * name, type and if the type of arguments is TGBLFCStringFromList, it also * provides designer specified list array with GetDesignerSpecifiedList output. * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * nextArgument r Required argument to have parameters provided by the command * * targetBB r Target GBLWaitForCommand building block * * Returns : int, The return value is 0 if no error occured or -1 on error * ******************************************************************* */ int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; XString typeName = context->GetParameterManager()->ParameterTypeToName(nextArgument->GetType()); XString argumentName = nextArgument->GetName(); if (typeName == "TGBLFCStringFromList") { int inputs = targetBB->GetInputParameterCount(); for (int i=0; i<inputs; i++) { CKParameterIn *parameterInput = targetBB->GetInputParameter(i); if ( argumentName == parameterInput->GetName() ) { CKParameterOut *parameterOutput = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetDesignerSpecifiedList); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterOutput->GetType()), FALSE); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterInput->GetType()), FALSE); parameterOutput->CopyValue (parameterInput->GetDirectSource()); break; } } } behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentType, typeName.Str(), strlen (typeName.Str()) + 1 ); behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentName, argumentName.Str(), strlen (argumentName.Str()) + 1 ); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::GetNextParameterValue); return 0; }
/* ******************************************************************* * Function: int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext) * * Description : Read next provided argument from SetParameterString p-in and add it to command string * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * ******************************************************************* */ int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; int gblBuildCommandState; behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState); switch (gblBuildCommandState) { case EGBLBuildCommandState::Initial: { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } break; case EGBLBuildCommandState::GetTargets: { //check if the array of recipients is provided void* recipients = NULL; recipients = behavior->GetInputParameter (EGBLBuildCommandParamInputs::SetDests)->GetDirectSource()->GetValueObject(); if (recipients == NULL) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } int targetID = 0; behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID); XString commandString; commandString << targetID << CGBLCommandUtil::commandSeparator; behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 ); //check if there are more arguments return DoHandleNextNetworkArgument (behaviorContext); } break; case EGBLBuildCommandState::AwaitingParametersForNetwork: case EGBLBuildCommandState::AwaitingParametersForUntargeted: { CKSTRING commandString = (CKSTRING) behavior->GetLocalParameter(commandStringLocalPos)->GetReadDataPtr(); CKSTRING argumentString = (CKSTRING) behavior->GetInputParameter(EGBLBuildCommandParamInputs::SetParameterString)->GetReadDataPtr(); //char commandString[512]; //char argumentString[512]; //behavior->GetLocalParameterValue(commandStringLocalPos,&commandString); //behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetParameterString, &argumentString); if (strlen (argumentString) == 0) { behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue); return CKBR_OK; } CKSTRING argumentType = (CKSTRING) behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetArgumentType)->GetReadDataPtr(); if ( (strcmp (argumentType, "Integer") == 0) || (strcmp (argumentType, "Float") == 0)) { bool isArgumentNumeric = CGBLCommandUtil::IsNumeric(argumentString); if (!isArgumentNumeric) { behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue); return CKBR_OK; } } XString updatedCommandString; updatedCommandString << commandString << argumentString << CGBLCommandUtil::commandSeparator; behavior->SetLocalParameterValue(commandStringLocalPos, updatedCommandString.Str(), strlen(updatedCommandString.Str()) + 1 ); if (gblBuildCommandState == EGBLBuildCommandState::AwaitingParametersForUntargeted) { return DoHandleNextLocalArgument (behaviorContext); } return DoHandleNextNetworkArgument (behaviorContext); } break; default: break; } return CKBR_OK; }
/* ******************************************************************* * Function: int CGBLBuildCommand::DoHandleNextNetworkArgument (const CKBehaviorContext& behaviorContext) * * Description : Checks if there are more arguments to be specified for network command * and takes corresponded actions * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * ******************************************************************* */ int CGBLBuildCommand::DoHandleNextNetworkArgument (const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; int gblBuildCommandState; CKBehavior* targetBB = NULL; CK_ID targetID; behavior->GetLocalParameterValue (targetBBLocalPos, &targetID); targetBB = (CKBehavior*)behaviorContext.Context->GetObject(targetID); if (targetBB == NULL) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } int currentParameterPosition = 0; behavior->GetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition); CKParameter* nextArgument = CGBLCommandUtil::GetCommandArgument(*targetBB, currentParameterPosition); currentParameterPosition++; behavior->SetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition); if (nextArgument == NULL) { //no arguments required, build finished CKParameter *outputCommandString, *localCommandString; CKParameter *outputDests; CKParameterIn *inputDests; ClearParameterOutputs(behaviorContext); outputCommandString = (CKParameter*) behavior->GetOutputParameter (EGBLBuildCommandParamOutputs::GetCommandString); localCommandString = (CKParameter*) behavior->GetLocalParameter (commandStringLocalPos); outputCommandString->CopyValue(localCommandString); // Copy list of recipients from input to output outputDests = (CKParameter*) (behavior->GetOutputParameter (EGBLBuildCommandParamOutputs::GetDests)); inputDests = behavior->GetInputParameter (EGBLBuildCommandParamInputs::SetDests); outputDests->CopyValue(inputDests->GetDirectSource()); gblBuildCommandState = EGBLBuildCommandState::Completed; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::HandleTargetedCommand); return CKBR_OK; } else { //get next argument gblBuildCommandState = EGBLBuildCommandState::AwaitingParametersForNetwork; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState); GetNextArgument (nextArgument, targetBB, behaviorContext); return CKBR_OK; } }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int RetrieveCI(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); IGBLCIManageInterface *cisFac = cman->GetCISFactoryInterface(); IGBLCIAccessInterface * accessInterface = cman->GetCISAccessInterface(); BOOL getAsString,outputAttriubtes = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); using namespace GBLCommon::BehaviorTools; using namespace GBLCommon::ParameterTools; using namespace Customisation::typedefs; int idCI = GetInputParameterValue<int>(beh,BEH_PAR_INDEX_CI); CGBLCI *currentCI = NULL; CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); currentCI = new CGBLCI("temp",CKPGUID_INT); CGBLCOError returnValue = accessInterface->GetCI(currentCI,idCI); //get error parameter CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_PIN_OUT_INDEX_ERROR); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { ////////////////////////////////////////////////////////////////////////// // output values : CKParameterOut *pout = beh->GetOutputParameter(1); if(getAsString) { //output the value VxScratch sbuffer(currentCI->realValue->GetDataSize()); CKSTRING buffer = (CKSTRING)sbuffer.Mem(); currentCI->realValue->GetStringValue(buffer); pout->SetStringValue(buffer); }else { CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); if ( beh->GetOutputParameter(0)->GetType() == currentCI->realValue->GetType() ) { pout->CopyValue(currentCI->realValue); }else { pout->SetType(currentCI->realValue->GetType()); return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// // output custom attributes : if(outputAttriubtes) { //output unique name : CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME); poutName->SetStringValue(currentCI->name.Str()); //output description : CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION); poutDescription->SetStringValue(currentCI->description.Str()); //output default value : CKParameterOut *poutDefaultValue = beh->GetOutputParameter(BEH_OUT_INDEX_DEFAULTVALUE); TypeCheckedParameterCopy(poutDefaultValue,currentCI->defaultValue); if(getAsString) { XString outDefValue = GBLCommon::ParameterTools::GetParameterAsString(currentCI->defaultValue); poutDefaultValue->SetStringValue( outDefValue.Str() ); }else{ poutDefaultValue->CopyValue(currentCI->defaultValue,TRUE); } //output flags : int flags = 0 ; beh->SetOutputParameterValue(BEH_OUT_INDEX_FLAGS,¤tCI->flags); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type); } TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLCHPopulateAvailableRecipients::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { enum { GETACTIVEPLAYERSARRAY_COLUMN_VIRTOOLSUSERID, GETACTIVEPLAYERSARRAY_COLUMN_USERNAME, GETACTIVEPLAYERSARRAY_COLUMN_GBLTEAMID }; enum { AVAILABLERECIPIENTSARRAY_COLUMN_USERNAME, AVAILABLERECIPIENTSARRAY_COLUMN_VIRTOOLSUSERID, AVAILABLERECIPIENTSARRAY_COLUMN_GBLTEAMID }; CKBehavior *beh = behaviorContext.Behavior; CGBLCOError localError(CGBLCOError::EGBLCOErrorType::GBLCO_OK); if (!beh) { assert(NULL); return CKBR_BEHAVIORERROR; } // Get profile controller CGBLProfileManager* profileManager = static_cast<CGBLProfileManager*>(beh->GetCKContext()->GetManagerByGuid(GBLProfileManagerGUID)); if (!profileManager) { assert(NULL); return CKBR_BEHAVIORERROR; } // Get GBL Loader manager GBLLDManager* loaderManager = static_cast<GBLLDManager*>(beh->GetCKContext()->GetManagerByGuid(GBLLDManagerGUID)); if (!profileManager) { assert(NULL); return CKBR_BEHAVIORERROR; } // Check we have been passed an array CKDataArray* availableRecipientsArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputAvailableRecipientsArray)); if (!availableRecipientsArray) { return CKBR_BEHAVIORERROR; } // Clear array and set up structure availableRecipientsArray->Clear(); while (availableRecipientsArray->GetColumnCount()) availableRecipientsArray->RemoveColumn(0); availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_STRING, "Name"); availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_INT, "VirtoolsUserID"); availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_PARAMETER, "GBLTeamID", GUID_TEAM_ID); // Create a temporary array of active players to be filled in by the Profile Controller CKDataArray* tmpActivePlayersArray = (CKDataArray*)beh->GetCKContext()->CreateObject(CKCID_DATAARRAY, "CGBLCHPopulateAvailableRecipients temp array", CK_OBJECTCREATION_DYNAMIC); if (!tmpActivePlayersArray) { assert(NULL); return CKBR_BEHAVIORERROR; } // Create temporary array for team names to be filled in by the Profile Controller CKDataArray* tmpTeamNameArray = (CKDataArray*)beh->GetCKContext()->CreateObject(CKCID_DATAARRAY, "CGBLCHPopulateAvailableRecipients temp array 2", CK_OBJECTCREATION_DYNAMIC); if (!tmpTeamNameArray) { assert(NULL); return CKBR_BEHAVIORERROR; } // Get active players localError = profileManager->GetActivePlayers(tmpActivePlayersArray); if (localError != CGBLCOError::EGBLCOErrorType::GBLCO_OK) { localError.SetCode(GBLCH_ERRORCODE_UNABLETOGETPROFILEINFORMATION); localError.SetDescription((XString)"An error occurred while attempting to retrieve profile information: " + (const char*)localError); } else { // Collate Team IDs into local array CGBLTeamID teamID; XArray<CGBLTeamID> arrayOfTeamIDs; XArray<XString> arrayOfTeamNames; char* stringBuffer = NULL; for (int row = 0;row < tmpActivePlayersArray->GetRowCount();row++) { // Get Team ID teamID = 0; if (tmpActivePlayersArray->GetElementValue(row, GETACTIVEPLAYERSARRAY_COLUMN_GBLTEAMID, &teamID)) { if ((int)teamID) { // Have we already got this team ID in the array? if (arrayOfTeamIDs.End() == arrayOfTeamIDs.Find(teamID)) { // No, add it to the array arrayOfTeamIDs.PushBack(teamID); } } } } // Copy team IDs and names into AvailableRecipients array for (int team = 0;team < arrayOfTeamIDs.Size();team++) { availableRecipientsArray->AddRow(); int row = availableRecipientsArray->GetRowCount() - 1; assert(row == team); // Get team name teamID = arrayOfTeamIDs[team]; localError = profileManager->GetProfileField((const)teamID, "Name", tmpTeamNameArray); if (localError != CGBLCOError::EGBLCOErrorType::GBLCO_OK) { localError.SetCode(GBLCH_ERRORCODE_UNABLETOGETPROFILEINFORMATION); localError.SetDescription((XString)"An error occurred while attempting to retrieve profile information: " + (const char*)localError); break; } // Place team name into destination array stringBuffer = new char[tmpTeamNameArray->GetElementStringValue(0, 0, NULL) + 1]; tmpTeamNameArray->GetElementStringValue(0, 0, stringBuffer); availableRecipientsArray->SetElementStringValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_USERNAME, stringBuffer); delete stringBuffer; stringBuffer = NULL; // Set user ID as 0 int virtoolsUserID = 0; availableRecipientsArray->SetElementValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_VIRTOOLSUSERID, &virtoolsUserID); // Set team ID availableRecipientsArray->SetElementValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_GBLTEAMID, &arrayOfTeamIDs[team]); } } if (localError == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { CGBLTeamID teamID; char* stringBuffer = NULL; int virtoolsUserID; // Now copy players (which includes facilitators) into the destination array for (int row = 0;row < tmpActivePlayersArray->GetRowCount();row++) { // Get User ID virtoolsUserID = 0; if (tmpActivePlayersArray->GetElementValue(row, GETACTIVEPLAYERSARRAY_COLUMN_VIRTOOLSUSERID, &virtoolsUserID)) { // Check this user ID valid if (virtoolsUserID) { // Add new row to destination array availableRecipientsArray->AddRow(); int row = availableRecipientsArray->GetRowCount() - 1; // Set Virtools user ID availableRecipientsArray->SetElementValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_VIRTOOLSUSERID, &virtoolsUserID); // Get name and put into dest array stringBuffer = new char[tmpActivePlayersArray->GetElementStringValue(row, GETACTIVEPLAYERSARRAY_COLUMN_USERNAME, NULL) + 1]; tmpActivePlayersArray->GetElementStringValue(row, GETACTIVEPLAYERSARRAY_COLUMN_USERNAME, stringBuffer); availableRecipientsArray->SetElementStringValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_USERNAME, stringBuffer); delete stringBuffer; stringBuffer = NULL; // Set team ID to 0 teamID = 0; availableRecipientsArray->SetElementValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_GBLTEAMID, &teamID); } } } } if (localError == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { // Remove the current user from the array // Get current Virtools User ID from GBL Loader int currentVirtoolsUserID = loaderManager->GetVirtoolsUserID(); for (int row = availableRecipientsArray->GetRowCount() - 1;row >= 0;row--) { int virtoolsUserId = 0; availableRecipientsArray->GetElementValue(row, AVAILABLERECIPIENTSARRAY_COLUMN_VIRTOOLSUSERID, &virtoolsUserId); if (virtoolsUserId == currentVirtoolsUserID) { // This row is the current user. Remove it availableRecipientsArray->RemoveRow(row); } } } // Free temporary arrays beh->GetCKContext()->DestroyObject(tmpActivePlayersArray); beh->GetCKContext()->DestroyObject(tmpTeamNameArray); // Did an error occur? if (localError == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { // Output success beh->ActivateOutput(eBehOutputDone); } else { // Output the error TGBLError::SetTGBLError(beh->GetOutputParameter(eParamOutputError), localError, localError, (CKSTRING)(const char*)localError); beh->ActivateOutput(eBehOutputError); } // All done return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction() * * Description : * * Paramters : * CKBehaviorContext& r The virtools behaviour context * * Returns : One of the many virtools return values * ******************************************************************* */ int CGBLLOStringBuilder::BehaviourFunction(const CKBehaviorContext& behContext) { CKBehavior* beh = behContext.Behavior; CKBeObject* beObject = beh->GetTarget(); CKBOOL error = FALSE; XString outString = NULL; // error check to ensure virtools is working ok if (!beObject) { error = TRUE; CKParameterOut *parameterOutError = beh->GetOutputParameter(EGBLStringBuilderParamOutputs::eParamGetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_FATAL,LOI_ERROR_NO_BEHAVIOUR_STATE,LOI_ERROR_NO_BEHAVIOUR_DESC); beh->SetOutputParameterValue(eParamGetError, parameterOutError); beh->ActivateOutput(eBehOutputError, TRUE); } int lengthOfSource = 0; int lengthOfInsert = 0; int insertPosition = 0; if (!error) { // Reset On input, if active if (beh->IsInputActive(eBehInputOn)) { beh->ActivateInput(eBehInputOn, FALSE); } // get the BB params into variables to work with XString sourceString = NULL; sourceString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetSourceString)); XString insertString = NULL; insertString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetInsertString)); beh->GetInputParameterValue(eParamSetInsertPosition,&insertPosition); lengthOfSource = strlen(sourceString.Str()); lengthOfInsert = strlen(insertString.Str()); // Simple bounds checking and error recovery if (insertPosition<0) { insertPosition=0; } if (insertPosition>lengthOfSource) { outString = sourceString; outString += insertString; } else { // a little more error checking and simple recovery // deal with the special cases first if (lengthOfSource<=0) { // an empty source outString = insertString; } else if (insertPosition == 0) { outString = insertString; outString += sourceString; } else { // build up the new string XString start = NULL; XString end = NULL; start = sourceString.Substring(0,insertPosition); end = sourceString.Substring(insertPosition,lengthOfSource); outString = start ; outString += insertString; outString += end; } } } if (!error) { int newCartPos = insertPosition+lengthOfInsert; beh->SetOutputParameterValue(eParamGetCarretPosition,&newCartPos); beh->SetOutputParameterValue(eParamGetNewText, outString.CStr(), outString.Length() + 1); beh->ActivateOutput(eBehOutputDone, TRUE); } return CKBR_OK; }
int GBLCOBGWrapper::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; int iPin, nbPin; CKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT); if (script == NULL) return CKBR_GENERICERROR; // Activate the right inputs nbPin = behaviour->GetInputCount(); for (iPin = 0; iPin < nbPin; iPin++) { if (behaviour->IsInputActive(iPin)) { script->ActivateInput(iPin, TRUE); behaviour->ActivateInput(iPin, FALSE); } } // Deactivate all the outputs nbPin = script->GetOutputCount(); for (iPin = 0; iPin < nbPin; iPin++) { behaviour->ActivateOutput(iPin, FALSE); } // Parameter In: Set Source int nbPinBB = behaviour->GetInputParameterCount(); int nbPinBG = script->GetInputParameterCount(); if (nbPinBB != nbPinBG) return CKBR_GENERICERROR; for (iPin = 0; iPin < nbPinBB; iPin++) { CKParameterIn *pBin = behaviour->GetInputParameter(iPin); CKParameter* pSource = pBin->GetDirectSource(); CKParameterIn *pSin = script->GetInputParameter(iPin); pSin->SetDirectSource(pSource); } // Execute the contained script CKERROR result = script->Execute(behContext.DeltaTime); // The script loop on itself too much times if (result == CKBR_INFINITELOOP) { context->OutputToConsoleExBeep("Execute Script : Script %s Executed too much times",script->GetName()); script->Activate(FALSE,FALSE); return CKBR_OK; } // Activate the right outputs nbPin = script->GetOutputCount(); for (iPin = 0; iPin < nbPin; iPin++) { if (script->IsOutputActive(iPin)) { behaviour->ActivateOutput(iPin); script->ActivateOutput(iPin, FALSE); } } // Update Parameters Out nbPin = behaviour->GetOutputParameterCount(); for (iPin = 0; iPin < nbPin; iPin++) { CKParameterOut *pBout = behaviour->GetOutputParameter(iPin); CKParameterOut *pSout = script->GetOutputParameter(iPin); pBout->CopyValue(pSout, TRUE); } // Test if there are any active sub-behaviors, restart the next frame if any BOOL bActivateNextFrame = FALSE; ActivateNextFrameSubBB(script,bActivateNextFrame); if (bActivateNextFrame) return CKBR_ACTIVATENEXTFRAME; // return the execute value return result; }
/* ******************************************************************* * Function: int BehaviourFunction() * * Description : Returns the number of plugins in this DLL * * Paramters : * CKBehaviorContext& r The virtools behaviour context * * Returns : One of the many virtools return values * ******************************************************************* */ int CGBLLOGetMOStatus::BehaviourFunction(const CKBehaviorContext& behContext) { CKBehavior* beh = behContext.Behavior; CKBOOL localError = false; CGBLCOError retVal(CGBLCOError::EGBLCOErrorType::GBLCO_OK); MeasuredObjectiveControllerMgr* MOMngr = static_cast<MeasuredObjectiveControllerMgr*>(behContext.Context->GetManagerByGuid(MeasuredObjectiveControllerMgrGUID)); // Check to see if we got the manager ok if (!MOMngr) { assert(NULL); return CKBR_OK; } if (beh->IsInputActive(eBehInputStart)) { // Get the details of the MO P-In CKParameterIn *pIn = beh->GetInputParameter(eParamInputMO); CKParameter *moParam = pIn->GetRealSource(); // Ensure we read the P-In ok if (!moParam) { // Report the error CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLLO_ERROR_NO_PARAM_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC); beh->ActivateOutput(eBehOutputError, TRUE); localError = true; } if (!localError) { // Get the data from the P-In CGBLMOData *moData = static_cast<CGBLMOData*>(moParam->GetAppData()); if (moData) { // Get the name from the MO and use this to get the // runtime MO from the controller XString moName = moData->GetName(); CGBLLOMeasuredObjective *mo=NULL; retVal=MOMngr->GetRunTimeMO(moName,mo); // See if the controller gave us the MO if((retVal==CGBLCOError::EGBLCOErrorType::GBLCO_OK)&&(mo)) { // Get the status of the MO bool moStatus=mo->GetMOStatus(); // return the status of the MO back to Virtools Dev beh->SetOutputParameterValue(eParamOutputGetStatus, &moStatus); } } else { // Report the fact that we couldnt create a runtime MO from the param CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLLO_ERROR_NO_DATA_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC); beh->ActivateOutput(eBehOutputError, TRUE); localError = true; } } } if (localError) { // error allready dealt with } else if (retVal!=CGBLCOError::EGBLCOErrorType::GBLCO_OK) { // Report the error back to Virtools dev CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); const char* errorString = retVal; TGBLError::SetTGBLError(pOut, retVal,retVal,(CKSTRING)errorString); beh->ActivateOutput(eBehOutputError, TRUE); } else { // We are ok beh->ActivateOutput(eBehOutputDone, TRUE); } return CKBR_OK; }
/* ******************************************************************* * Function: int CGBLBuildCommand::DoHandleNextLocalArgument (const CKBehaviorContext& behaviorContext) * * Description : Checks if there are more arguments to be specified for global command * and takes corresponded actions * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * ******************************************************************* */ int CGBLBuildCommand::DoHandleNextLocalArgument (const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; int gblBuildCommandState; CKBehavior* targetBB = NULL; CK_ID targetID; behavior->GetLocalParameterValue (targetBBLocalPos, &targetID); targetBB = (CKBehavior*)behaviorContext.Context->GetObject(targetID); if (targetBB == NULL) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } int currentParameterPosition = 0; behavior->GetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition); CKParameter* nextArgument = CGBLCommandUtil::GetCommandArgument(*targetBB, currentParameterPosition); currentParameterPosition++; behavior->SetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition); if (nextArgument == NULL) { //no arguments required, build finished //char commandString[512]; //behavior->GetLocalParameterValue(commandStringLocalPos,&commandString); CKSTRING commandString = (CKSTRING) behavior->GetLocalParameter(commandStringLocalPos)->GetReadDataPtr(); int res = CGBLCommandUtil::InvokeCommand (commandString, behaviorContext); ClearParameterOutputs(behaviorContext); if (res != CK_OK) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVOKING_FAILED, GBLFC_ERROR_BUILDCOMMAND_INVOKING_FAILED_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } behavior->ActivateOutput (EGBLBuildCommandBehOutputs::HandleUntargetedCommand); return CKBR_OK; } else { //get next argument gblBuildCommandState = EGBLBuildCommandState::AwaitingParametersForUntargeted; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState); GetNextArgument (nextArgument, targetBB, behaviorContext); return CKBR_OK; } }
int PMaterialIterator(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; PhysicManager *pm = GetPMan(); pFactory *pf = pFactory::Instance(); if (beh->IsInputActive(0)) { beh->ActivateInput(0,FALSE); ////////////////////////////////////////////////////////////////////////// //we reset our session counter int sessionIndex=-1; beh->SetOutputParameterValue(0,&sessionIndex); LMaterials*sResults = NULL; beh->GetLocalParameterValue(0,&sResults); if (!sResults) { sResults = new LMaterials(); }else sResults->clear(); NxScene * scene = GetPMan()->getDefaultWorld()->getScene(); for(int i = 0 ; i < GetPMan()->getDefaultWorld()->getScene()->getNbMaterials() ; i ++) { NxMaterial *currentMaterial = scene->getMaterialFromIndex(i); sResults->push_back(currentMaterial); } beh->SetLocalParameterValue(0,&sResults); if (sResults->size()) { beh->ActivateInput(1); }else { beh->ActivateOutput(0); return 0; } } if( beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); int currentIndex=0; CKParameterOut *pout = beh->GetOutputParameter(0); pout->GetValue(¤tIndex); currentIndex++; LMaterials *sResults = NULL; beh->GetLocalParameterValue(0,&sResults); if (!sResults) { beh->ActivateOutput(0); return 0; } if (currentIndex>=sResults->size()) { sResults->clear(); beh->ActivateOutput(0); return 0; } NxMaterial * material = sResults->at(currentIndex); if (material!=NULL) { int sIndex = currentIndex+1; beh->SetOutputParameterValue(0,&sIndex); //SetOutputParameterValue<int>(beh,O_XML,material->xmlLinkID); SetOutputParameterValue<float>(beh,O_DFRICTION,material->getDynamicFriction()); SetOutputParameterValue<float>(beh,O_SFRICTION,material->getStaticFriction()); SetOutputParameterValue<float>(beh,O_RES,material->getRestitution()); SetOutputParameterValue<float>(beh,O_DFRICTIONV,material->getDynamicFrictionV()); SetOutputParameterValue<float>(beh,O_SFRICTIONV,material->getStaticFrictionV()); SetOutputParameterValue<VxVector>(beh,O_ANIS,getFrom(material->getDirOfAnisotropy())); SetOutputParameterValue<int>(beh,O_FCMODE,material->getFrictionCombineMode()); SetOutputParameterValue<int>(beh,O_RCMODE,material->getFrictionCombineMode()); SetOutputParameterValue<int>(beh,O_FLAGS,material->getFlags()); } if(material->userData ) { pMaterial *bMaterial = static_cast<pMaterial*>(material->userData); if (bMaterial && bMaterial->xmlLinkID ) { int xid = bMaterial->xmlLinkID; XString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,xid); CKParameterOut *nameStr = beh->GetOutputParameter(O_NAME); nameStr->SetStringValue(nodeName.Str()); } } //pFactory::Instance()->copyTo(beh->GetOutputParameter(O_MATERIAL),material); beh->ActivateOutput(0); } return 0; }
int LogEntry(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKMessageManager* mm = behcontext.MessageManager; CKContext* ctx = behcontext.Context; CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager()); XString File((CKSTRING) beh->GetInputParameterReadDataPtr(0)); if (GetPMan()->GetLastLogEntry().Length()) { CKParameterOut *pout = beh->GetOutputParameter(0); pout->SetStringValue(GetPMan()->GetLastLogEntry().Str()); GetPMan()->SetLastLogEntry(""); vtTools::BehaviorTools::SetOutputParameterValue<int>(beh,1,xLogger::GetInstance()->lastTyp); int descriptionS = xLogger::GetInstance()->getItemDescriptions().size(); int compo = xLogger::GetInstance()->lastComponent; XString compoStr; /*if(compo<= xLogger::GetInstance()->getItemDescriptions().size() ) compoStr.Format("%s",xLogger::GetInstance()->getItemDescriptions().at(compo));*/ beh->ActivateOutput(0,TRUE); switch (xLogger::GetInstance()->lastTyp) { case ELOGERROR: beh->ActivateOutput(1,TRUE); case ELOGWARNING: beh->ActivateOutput(2,TRUE); case ELOGINFO: beh->ActivateOutput(3,TRUE); case ELOGTRACE: beh->ActivateOutput(4,TRUE); case ELOGDEBUG: beh->ActivateOutput(5,TRUE); default: beh->ActivateOutput(0,TRUE); } } // Steering if( beh->IsInputActive(1) ) { beh->ActivateOutput(0,FALSE); return 1; } return CKBR_ACTIVATENEXTFRAME; }
int DOUserValueModified(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKMessageManager* mm = behcontext.MessageManager; CKContext* ctx = behcontext.Context; ////////////////////////////////////////////////////////////////////////// //connection id : int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0); if (beh->IsInputActive(1)) { beh->ActivateInput(1,FALSE); beh->ActivateOutput(1); return 0; } ////////////////////////////////////////////////////////////////////////// //the object : CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1); if (!obj) { beh->ActivateOutput(3); return CKBR_ACTIVATENEXTFRAME; } ////////////////////////////////////////////////////////////////////////// //network ok ? xNetInterface *cin = GetNM()->GetClientNetInterface(); if (!cin) { CKParameterOut *pout = beh->GetOutputParameter(2); XString errorMesg("distributed object creation failed,no network connection !"); pout->SetStringValue(errorMesg.Str()); beh->ActivateOutput(3); return CKBR_ACTIVATENEXTFRAME; } //use objects name, if not specified : CKSTRING name= obj->GetName(); IDistributedObjects*doInterface = cin->getDistObjectInterface(); IDistributedClasses*cInterface = cin->getDistributedClassInterface(); XString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0)); XString parameterName((CKSTRING) beh->GetLocalParameterReadDataPtr(1)); xDistributedClass *_class = cInterface->get(className.CStr()); ////////////////////////////////////////////////////////////////////////// //dist class ok ? if (_class==NULL) { beh->ActivateOutput(3); ctx->OutputToConsoleEx("Distributed Class doesn't exists : %s",className.CStr()); return CKBR_ACTIVATENEXTFRAME; } const char * cNAme = _class->getClassName().getString(); int classType = _class->getEnitityType(); int bcount = beh->GetInputParameterCount(); ////////////////////////////////////////////////////////////////////////// //we come in by input 0 : xDistributedObject *dobjDummy = NULL; xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID()); if (!dobj) { beh->ActivateOutput(3); return CKBR_ACTIVATENEXTFRAME; } if (dobj) { xDistributedProperty * prop = dobj->getUserProperty(parameterName.CStr()); if (prop) { if ( dobj->getGhostUpdateBits().testStrict(1 << prop->getBlockIndex())) { CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager()); CKParameterOut *ciIn = beh->GetOutputParameter(1); CKParameterType pType = ciIn->GetType(); int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType)); int userType = xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType); if ( userType ==sType ) { beh->ActivateOutput(2); dobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false); switch(xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType)) { case vtFLOAT: { xDistributedPoint1F *propValue = static_cast<xDistributedPoint1F*>(prop); if (propValue) { float ovalue = propValue->mLastServerValue; beh->SetOutputParameterValue(1,&ovalue); break; } } case vtVECTOR2D: { xDistributedPoint2F *propValue = static_cast<xDistributedPoint2F*>(prop); if (propValue) { Point2F ovalue = propValue->mLastServerValue; Vx2DVector ovaluex(ovalue.x,ovalue.y); beh->SetOutputParameterValue(1,&ovaluex); break; } } case vtVECTOR: { xDistributedPoint3F *propValue = static_cast<xDistributedPoint3F*>(prop); if (propValue) { Point3F ovalue = propValue->mLastServerValue; VxVector ovaluex(ovalue.x,ovalue.y,ovalue.z); beh->SetOutputParameterValue(1,&ovaluex); break; } } case vtQUATERNION: { xDistributedQuatF*propValue = static_cast<xDistributedQuatF*>(prop); if (propValue) { QuatF ovalue = propValue->mLastServerValue; VxQuaternion ovaluex(ovalue.x,ovalue.y,ovalue.z,ovalue.w); beh->SetOutputParameterValue(1,&ovaluex); break; } } case vtSTRING: { xDistributedString*propValue = static_cast<xDistributedString*>(prop); if (propValue) { TNL::StringPtr ovalue = propValue->mCurrentValue; CKParameterOut *pout = beh->GetOutputParameter(1); XString errorMesg(ovalue.getString()); pout->SetStringValue(errorMesg.Str()); break; } } case vtINTEGER: { xDistributedInteger*propValue = static_cast<xDistributedInteger*>(prop); if (propValue) { int ovalue = propValue->mLastServerValue; beh->SetOutputParameterValue(1,&ovalue); break; } } } } } } } return CKBR_ACTIVATENEXTFRAME; if (beh->IsInputActive(0)) { beh->ActivateOutput(0); } /* ////////////////////////////////////////////////////////////////////////// //we come in by input 0 : if (beh->IsInputActive(0)) { beh->ActivateOutput(0); for (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ ) { beh->ActivateInput(0,FALSE); xDistributedObject *dobj = doInterface->get(name); if (!dobj) { beh->ActivateOutput(0); return 0; } CKParameterIn *ciIn = beh->GetInputParameter(i); CKParameterType pType = ciIn->GetType(); int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType)); xDistributedPropertyArrayType &props = *dobj->getDistributedPorperties(); int propID = _class->getInternalUserFieldIndex(i - BEH_IN_INDEX_MIN_COUNT); if (propID==-1 || propID > props.size() ) { beh->ActivateOutput(1); return 0; } xDistributedProperty *prop = props[propID]; if (prop) { xDistributedPropertyInfo*propInfo = prop->getPropertyInfo(); if (propInfo) { if (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType ) { TNL::U32 currentTime = TNL::Platform::getRealMilliseconds(); switch(propInfo->mValueType) { case E_DC_PTYPE_3DVECTOR: { xDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop; if (dpoint3F) { VxVector vvalue; beh->GetInputParameterValue(i,&vvalue); bool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime); } break; } case E_DC_PTYPE_FLOAT: { xDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop; if (dpoint3F) { float vvalue; beh->GetInputParameterValue(i,&vvalue); bool update = dpoint3F->updateValue(vvalue,currentTime); } break; } } } } } } beh->ActivateOutput(0); } */ ////////////////////////////////////////////////////////////////////////// //we come in by loop : return 0; }
/* ******************************************************************* * Function: int BehaviourFunction() * * Description : Returns the number of plugins in this DLL * * Paramters : * CKBehaviorContext& r The virtools behaviour context * * Returns : One of the many virtools return values * ******************************************************************* */ int CGBLLOStopTimer::BehaviourFunction(const CKBehaviorContext& behContext) { CKBehavior* beh = behContext.Behavior; CKBOOL localError = false; CGBLCOError retVal(CGBLCOError::EGBLCOErrorType::GBLCO_OK); MeasuredObjectiveControllerMgr* MOMngr = static_cast<MeasuredObjectiveControllerMgr*>(behContext.Context->GetManagerByGuid(MeasuredObjectiveControllerMgrGUID)); // Check to see if we got the manager ok if (!MOMngr) { assert(NULL); return CKBR_OK; } if (beh->IsInputActive(eBehInputStart)) { // Get the details of the MO P-In CKParameterIn *pInMO = beh->GetInputParameter(eParamInputMO); CKParameter *moParam = pInMO->GetRealSource(); // Get the details of the Measurement P-In CKParameterIn *pInMeas= beh->GetInputParameter(eParamInputMeasurement); CKParameter *measParam = pInMeas->GetRealSource(); // Ensure we read the P-In ok if (!moParam) { // Report the error CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLLO_ERROR_NO_PARAM_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC); beh->ActivateOutput(eBehOutputError, TRUE); localError = true; } if (!localError) { // Get the data from the P-In CGBLMOData *moData = static_cast<CGBLMOData*>(moParam->GetAppData()); if (moData) { // Get the name from the MO and use this to get the // runtime MO from the controller XString moName = moData->GetName(); CGBLLOMeasuredObjective *mo=NULL; retVal=MOMngr->GetRunTimeMO(moName,mo); // See if the controller gave us the MO if((retVal==CGBLCOError::EGBLCOErrorType::GBLCO_OK)&&(mo)) { // Get the data from the P-In CGBLMeasurementData *measData = static_cast<CGBLMeasurementData*>(measParam->GetAppData()); if (measData) { // Get the measurement XString measName = measData->GetName(); EGBLLOMeasurementType measType=measData->GetType(); CGBLMeasurement *meas=NULL; retVal=mo->GetMeasurement(measName,meas); // See if the MO gave us the measurement if((retVal==CGBLCOError::EGBLCOErrorType::GBLCO_OK)&&(meas)) { // Based on the measurement type, get the value from the P-Im // and pass the value to the measurement. switch (measType) { case eTimer: { CGBLLOMeasurementTimer *timeMeas=NULL; timeMeas=static_cast<CGBLLOMeasurementTimer*>(meas); retVal=timeMeas->StopTimer(); } break; default: { CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLLO_ERROR_TRIED_START_TIMER_NOT,GBLLO_ERROR_TRIED_START_TIMER_NOT_DESC); beh->ActivateOutput(eBehOutputError, TRUE); localError = true; } break; } } } } } else { // Report the fact that we couldnt create a runtime MO from the param CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLLO_ERROR_NO_DATA_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC); beh->ActivateOutput(eBehOutputError, TRUE); localError = true; } } } if (localError) { // error allready dealt with } else if (retVal!=CGBLCOError::EGBLCOErrorType::GBLCO_OK) { // Report the error back to Virtools dev CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError); const char* errorString = retVal; TGBLError::SetTGBLError(pOut, retVal,retVal,(CKSTRING)errorString); beh->ActivateOutput(eBehOutputError, TRUE); } else { // We are ok beh->ActivateOutput(eBehOutputDone, TRUE); } return CKBR_OK; }
int GBLCOCreateError::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; if ( behaviour == NULL || context == NULL ) return CKBR_GENERICERROR; behaviour->ActivateInput(ECGBLCOCreateErrorBehInputs::In, FALSE); CGBLCOErrorManager *errorManager = (CGBLCOErrorManager *)context->GetManagerByGuid(CGBLCOErrorManagerGUID); if ( errorManager == NULL ) return CKBR_GENERICERROR; // Get Parameters Inputs Source. CKParameterOut *poutError = behaviour->GetOutputParameter(ECGBLCOCreateErrorParamOutputs::GetError); if ( poutError == NULL ) return CKBR_GENERICERROR; CKParameterIn*pinCode = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorCode); CKParameterIn*pinDesc = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorDescription); CKParameterIn*pinType = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorType); if ( pinCode == NULL || pinDesc == NULL || pinType == NULL ) return CKBR_GENERICERROR; CKParameter*paraCode = pinCode->GetRealSource(); CKParameter*paraDesc = pinDesc->GetRealSource(); CKParameter*paraType = pinType->GetRealSource(); if ( paraCode == NULL || paraDesc == NULL || paraType == NULL ) return CKBR_GENERICERROR; // Get Parameters Inputs Values (code,desc,type). int code = 0; paraCode->GetValue(&code); XString desc; int paramsize = paraDesc->GetStringValue(NULL); if (paramsize) { XAP<char> paramstring(new char[paramsize]); paraDesc->GetStringValue(paramstring,TRUE); desc << (char*)paramstring; } CGBLCOError::EGBLCOErrorType type; paraType->GetValue(&type); // Create the TGBLError parameter output. TGBLError::SetTGBLError(poutError,type,code,(CKSTRING)desc.CStr()); CK_CLASSID cid = poutError->GetClassID(); // if ( type != CGBLCOError::EGBLCOErrorType::GBLCO_FATAL ) { behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, FALSE); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, TRUE); return CKBR_OK; } errorManager->NotifyError(type,code,(CKSTRING)desc.CStr()); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, TRUE); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, FALSE); return CKBR_OK; }
/* ******************************************************************* * Function: int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext) * * Description : Starts building the command. Find required GBLWaitForCommand BB, * determine its target (GBLTarget) and take corresponded actions. * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * ******************************************************************* */ int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; //set to initial state int stateValue = EGBLBuildCommandState::Initial; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue); int initialParameterPosition = 0; behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition); char *emptyString = ""; behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1); ClearParameterOutputs(behaviorContext); int targetID = 0; behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID); CKBehavior* targetBB = CGBLCommandUtil::GetTargetCommand (targetID, behaviorContext); if (targetBB == NULL) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); return CKBR_OK; } CK_ID targetBBID = targetBB->GetID(); behavior->SetLocalParameterValue (targetBBLocalPos, &targetBBID); int gblTatgetType = -1; targetBB->GetLocalParameterValue (CGBLWaitForCommand::EGBLWaitForCommandLocalVariables::EGBLFCTarget, &gblTatgetType); switch (gblTatgetType) { case CGBLWaitForCommand::EGBLFCTarget::Untargeted: { XString commandString; commandString << targetID << CGBLCommandUtil::commandSeparator; behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 ); return DoHandleNextLocalArgument (behaviorContext); } break; case CGBLWaitForCommand::EGBLFCTarget::Player: case CGBLWaitForCommand::EGBLFCTarget::Team: { //set state to GetTargets int stateValue = EGBLBuildCommandState::GetTargets; behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos,&stateValue); //get list of recipients behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetTarget, &gblTatgetType); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::ListRecipients); return CKBR_OK; } break; default: CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT_DESC); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error); break; } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAEGetLAE::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAAccess *laInterface = storageManager->GetLAInterface(); IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface(); char *laListArrayName = "laList"; CKDataArray* laListArray; laListArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laListArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laListArray ); laListArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAID" ); char *laeArrayName = "laeidList"; CKDataArray* laeArray; laeArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laeArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laeArray ); laeArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAEID" ); char *laelaArrayName = "laelaIDList"; CKDataArray* laelaArray; laelaArray = (CKDataArray *)ctx->GetObjectByNameAndClass(laelaArrayName,CKCID_DATAARRAY,NULL); if ( !laelaArray ) { laelaArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laelaArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laelaArray ); laelaArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAEID" ); laelaArray->InsertColumn( -1, CKARRAYTYPE_STRING, "LAID" ); } else { laelaArray->Clear(); } CGBLCOError res = laInterface->RetrieveLAList(laListArray); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { int count = laListArray->GetRowCount(); for (int i=0; i < count; i++) { //get list of laes for given la and add it to results list XString xLAID; CKSTRING valueField = NULL; int labelLength = laListArray->GetElementStringValue(i, 0, NULL); valueField = new CKCHAR[labelLength]; labelLength = laListArray->GetElementStringValue(i, 0, valueField); xLAID = valueField; delete valueField; CGBLLAID laid; laid.FromString(xLAID); CGBLCOError res = laeInterface->RetrieveLAEList(laeArray,laid); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { int count = laeArray->GetRowCount(); for (int j=0; j < count; j++) { CKSTRING valueField = NULL; int labelLength = laeArray->GetElementStringValue(j, 0, NULL); valueField = new CKCHAR[labelLength]; labelLength = laeArray->GetElementStringValue(j, 0, valueField); laelaArray->AddRow(); laelaArray->SetElementStringValue(laelaArray->GetRowCount()-1, 0, valueField); laelaArray->SetElementStringValue(laelaArray->GetRowCount()-1, 1, xLAID.Str()); delete valueField; } } } beh->ActivateInput(0, FALSE); beh->SetOutputParameterObject(0, laelaArray); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(1); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_GETLISTOFLAIDS,GBLLAE_ERROR_GETLISTOFLAIDS_DESC); beh->ActivateOutput(1); } behaviorContext.CurrentLevel->RemoveObject(laListArray); ctx->DestroyObject(laListArray); behaviorContext.CurrentLevel->RemoveObject(laeArray); ctx->DestroyObject(laeArray); return CKBR_OK; }
int DOOwnerChanged(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKMessageManager* mm = behcontext.MessageManager; CKContext* ctx = behcontext.Context; ////////////////////////////////////////////////////////////////////////// //connection id : int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0); ////////////////////////////////////////////////////////////////////////// //we come in by input 0 : if (beh->IsInputActive(0)) { beh->ActivateOutput(0); beh->ActivateInput(0,FALSE); } if (beh->IsInputActive(1)) { beh->ActivateOutput(1); beh->ActivateInput(1,FALSE); return 0; } ////////////////////////////////////////////////////////////////////////// //the object : CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1); if (!obj) { beh->ActivateOutput(4); return CKBR_ACTIVATENEXTFRAME; } ////////////////////////////////////////////////////////////////////////// //network ok ? xNetInterface *cin = GetNM()->GetClientNetInterface(); if (!cin) { CKParameterOut *pout = beh->GetOutputParameter(1); XString errorMesg("distributed object creation failed,no network connection !"); pout->SetStringValue(errorMesg.Str()); beh->ActivateOutput(4); return CKBR_ACTIVATENEXTFRAME; } IDistributedObjects*doInterface = cin->getDistObjectInterface(); ////////////////////////////////////////////////////////////////////////// //we come in by input 0 : xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID()); if (!dobj) { CKParameterOut *pout = beh->GetOutputParameter(1); XString errorMesg("There is no such an object"); pout->SetStringValue(errorMesg.Str()); beh->ActivateOutput(4); } else { if (dobj->getOwnershipState().test(1 << E_DO_OS_RELEASED) && dobj->getOwnershipState().test( 1 << E_DO_OS_OWNERCHANGED) ) { beh->ActivateOutput(3); } if (dobj->getOwnershipState().testStrict(1 << E_DO_OS_OWNERCHANGED)) { dobj->getOwnershipState().set( 1<<E_DO_OS_OWNERCHANGED ,false ); int newCLientID = dobj->getUserID(); beh->SetOutputParameterValue(0,&newCLientID); beh->ActivateOutput(2); } } return CKBR_ACTIVATENEXTFRAME; }
/* ******************************************************************* * Function: int GetCIValue( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GetCIValue(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); BOOL getByName,getAsString,outputAttriubtes,outputOnChange = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_BY_NAME,&getByName); beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); beh->GetLocalParameterValue(BEH_SETTINGS_OUTPUT_ON_CHANGE,&outputOnChange); // Beh Input 1 activated : switch of on event mode ///////////////////////////////////////////////// if( outputOnChange && beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); return CKBR_OK; } using namespace GBLCommon::BehaviorTools; using namespace Customisation::typedefs; Customisation::typedefs::CIS* currentCIS = cman->GetCIS(); if( !currentCIS) { return CKBR_PARAMETERERROR; } CGBLCI *currentCI = NULL; //get by uniquie name mode ? if( getByName ) { CISIterator it = currentCIS->Find( new CGBLCIID (GetInputParameterValue<CKSTRING>(beh,0) , 0 ) ); if (it == currentCIS->End() ) { return CKBR_PARAMETERERROR; }else { currentCI = *it; } //////// then get the custom parameter : }else { CKParameter *ciPar = beh->GetInputParameter(0)->GetRealSource(); currentCI = static_cast<CGBLCI *>(ciPar->GetAppData()); if (!currentCI) { return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// // output values : CKParameterOut *pout = beh->GetOutputParameter(0); if(getAsString) { //output the value VxScratch sbuffer(currentCI->realValue->GetDataSize()); CKSTRING buffer = (CKSTRING)sbuffer.Mem(); currentCI->realValue->GetStringValue(buffer); pout->SetStringValue(buffer); }else { CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); if ( beh->GetOutputParameter(0)->GetType() == currentCI->realValue->GetType() ) { pout->CopyValue(currentCI->realValue); }else { pout->SetType(currentCI->realValue->GetType()); return CKBR_PARAMETERERROR; } } using namespace GBLCommon::ParameterTools; ////////////////////////////////////////////////////////////////////////// // output custom attributes : if(outputAttriubtes) { //output unique name : CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME); poutName->SetStringValue(currentCI->name.Str()); //output description : CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION); poutDescription->SetStringValue(currentCI->description.Str()); //output default value : CKParameterOut *poutDefaultValue = beh->GetOutputParameter(BEH_OUT_INDEX_DEFAULTVALUE); TypeCheckedParameterCopy(poutDefaultValue,currentCI->defaultValue); if(getAsString) { XString outDefValue = GBLCommon::ParameterTools::GetParameterAsString(currentCI->defaultValue); poutDefaultValue->SetStringValue( outDefValue.Str() ); }else{ poutDefaultValue->CopyValue(currentCI->defaultValue,TRUE); } //output flags : int flags = 0 ; beh->SetOutputParameterValue(BEH_OUT_INDEX_FLAGS,¤tCI->flags); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type); } if (outputOnChange && (currentCI->ciState & CGBLCI::GBL_CI_STATE::GBL_CI_CHANGED) ) { //reset state : currentCI->ciState = 0L; beh->ActivateOutput(0); } if (!outputOnChange) { beh->ActivateOutput(0); } return outputOnChange ? CKBR_ACTIVATENEXTFRAME : CKBR_OK; }
/* ******************************************************************* * Function: int DecodeAndSendCommand (XString commandString, char separator, const CKBehaviorContext& behaviorContext) * * Description : Decodes the string message passed in into the separate parameters for the command and * sets the output parameter valuess of the corresponding GBLWaitForCommand BB. * * Paramters : * * commandString r command string * separator r parameter separator * behaviorContext r behavior context * * Returns : * 0 on success, otherwise error * ******************************************************************* */ int CGBLCommandController::InvokeCommand (XString commandString, const CKBehaviorContext& behaviorContext) { int returnValue = 0; // 0 indicates success int separatorPos = 0; //position for string separator char separator = CGBLCommandController::commandSeparator; if (strlen (commandString.Str()) <=0) { returnValue = -1; } else { separatorPos = commandString.Find(separator, separatorPos); int commandID = atoi ( (commandString.Substring (0, separatorPos)).Str() ); CKBehavior* targetBB = CGBLCommandController::GetTargetCommand (commandID, behaviorContext); if (targetBB == NULL ) { returnValue = -1; } else if (! (targetBB->IsInputActive(0)) ) { returnValue = -1; } else { int argumentCount = targetBB->GetOutputParameterCount(); int separatorCount = 0; for (unsigned int k=0; k < strlen (commandString.Str()); k++) { if (commandString.Str()[k] == separator) { separatorCount++; } } if ( separatorCount != (argumentCount + 1 ) ) { returnValue = -1; } else { int prevPos = separatorPos+1; for(int i = 0; i < argumentCount ; i++) { separatorPos = commandString.Find(separator, prevPos); if (separatorPos == prevPos) { CKParameterOut* targetParam = targetBB->GetOutputParameter(i); targetParam->SetStringValue (""); } else { XString insert = (commandString.Substring (prevPos, separatorPos-prevPos)).Str(); CKParameterOut* targetParam = targetBB->GetOutputParameter(i); targetParam->SetStringValue (insert.Str()); } prevPos = separatorPos+1; } targetBB->ActivateOutput(0); } } } return returnValue; }
/* ******************************************************************* * Function: int CISIteratorBB( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CISIteratorBB(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); /*get the last index */ int index = 0; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX, &index); BOOL getFromDB = false; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB); using namespace GBLCommon::BehaviorTools; using namespace GBLCommon::ParameterTools; using namespace Customisation::typedefs; /************************************************************************/ /* behavior trigger event processing : */ /* */ /* */ /* Reset/On : sets the index to zero and save it */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); if (getFromDB) { CKDataArray * resultArray = NULL; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray); if (resultArray) { resultArray->Clear(); while ( resultArray->GetColumnCount() ) resultArray->RemoveColumn(0); } else { resultArray = static_cast<CKDataArray*>(ctx->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::CIS_IDLIST", CK_OBJECTCREATION_DYNAMIC )); } ctx->GetCurrentLevel()->AddObject( resultArray ); ////////////////////////////////////////////////////////////////////////// retrieve list of CI ID's : CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); int idCIS = GetInputParameterValue<int>(beh,BEH_IN_PAR_CIS_ID); smCIS->RetrieveCIList(resultArray,CGBLCISID(idCIS)); beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray,sizeof(CKDataArray*)); int cis_size = resultArray->GetRowCount(); beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cis_size); }else { Customisation::typedefs::CIS* currentCIS = cman->GetCIS(); if(!currentCIS) Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CIS"); } //reset counter : index = 0 ; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateInput(1,TRUE); } //get LA_ID : int cisSize; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cisSize); /* bounding check for the index: if out of range, set to zero and save it.*/ if(index > cisSize -1 ) { index = 0; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateOutput(0); return CKBR_OK; } /* Loop In : */ if( beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); CGBLCI *currentCI = NULL; //ctx->OutputToConsole("asfasdf"); if (getFromDB) { CKDataArray * resultArray = NULL; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray); if (resultArray) { CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID)); IGBLCIAccessInterface * accessInterface = cman->GetCISAccessInterface(); currentCI = new CGBLCI("temp",CKPGUID_INT); int idCI; resultArray->GetElementValue(index,0,&idCI); accessInterface->GetCI(currentCI,idCI); beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_DB_INDEX,&idCI); }else { ctx->OutputToConsole("wrong array"); } }else { Customisation::typedefs::CISIterator it = cman->GetCIS()->GetIteratorByIndex(index); currentCI = (CGBLCI *)*it; } if (currentCI) { //output name : CKParameterOut *outName = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_UNAME); outName->SetStringValue(currentCI->name.Str()); //output description: CKParameterOut *outDescr = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DESCRIPTION); outDescr->SetStringValue(currentCI->description.Str()); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_TYPE,&type); //output value: CKParameterOut *outStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_VALUE); outStrValue->SetStringValue(GetParameterAsString(currentCI->realValue)); //output default value: CKParameterOut *outDefaultStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DEFAULTVALUE); outDefaultStrValue->SetStringValue(GetParameterAsString(currentCI->defaultValue)); //output flags : beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_FLAGS,¤tCI->flags); }else { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CI Parameter"); } //increase counter : index++; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateOutput(1); } return CKBR_OK; }