void THISCLASS::OnStep() { // Check input image IplImage *inputimage = mCore->mDataStructureInput.mImage; if (! inputimage) { return; } if (inputimage->nChannels != 1) { AddError(wxT("This component requires a grayscale input image.")); } // Prepare the output image PrepareOutputImage(inputimage); // Convert try { switch (mBayerType) { case 0 : cvCvtColor(inputimage, mOutputImage, CV_BayerBG2BGR); break; case 1 : cvCvtColor(inputimage, mOutputImage, CV_BayerGB2BGR); break; case 2 : cvCvtColor(inputimage, mOutputImage, CV_BayerRG2BGR); break; case 3 : cvCvtColor(inputimage, mOutputImage, CV_BayerGR2BGR); break; default : AddError(wxT("Invalid Bayer Pattern Type")); return; } } catch (...) { AddError(wxT("Conversion from Bayer to BGR failed.")); } // Set the output image on the color data structure mCore->mDataStructureImageColor.mImage = mOutputImage; // Let the Display know about our image DisplayEditor de(&mDisplayOutput); if (de.IsActive()) { de.SetMainImage(mCore->mDataStructureImageColor.mImage); } }
int LuaParser::_EventEncounter(std::string package_name, QuestEventID evt, std::string encounter_name, uint32 extra_data, std::vector<void*> *extra_pointers) { const char *sub_name = LuaEvents[evt]; int start = lua_gettop(L); try { lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str()); lua_getfield(L, -1, sub_name); lua_createtable(L, 0, 0); lua_pushstring(L, encounter_name.c_str()); lua_setfield(L, -2, "name"); quest_manager.StartQuest(nullptr, nullptr, nullptr); if(lua_pcall(L, 1, 1, 0)) { std::string error = lua_tostring(L, -1); AddError(error); quest_manager.EndQuest(); return 0; } quest_manager.EndQuest(); if(lua_isnumber(L, -1)) { int ret = static_cast<int>(lua_tointeger(L, -1)); lua_pop(L, 2); return ret; } lua_pop(L, 2); } catch(std::exception &ex) { std::string error = "Lua Exception: "; error += std::string(ex.what()); AddError(error); //Restore our stack to the best of our ability int end = lua_gettop(L); int n = end - start; if(n > 0) { lua_pop(L, n); } } return 0; }
bool TParserBase::Consume(const char* text, const char* error) { if (TryConsume(text)) return true; else { AddError(error); return false; } }
bool TParserBase::Consume(const char* text) { if (TryConsume(text)) return true; else { AddError(Substitute("Expected \"$0\".", text)); return false; } }
void THISCLASS::OnStop() { if (mCamera.StopImageAcquisition() != 0) { AddError(wxT("Could not stop image acquisition.")); return; } if (mOutputImage) { cvReleaseImage(&mOutputImage); } }
//----------------------------------------------------------------------------- // Purpose: // Input : pEntity - // pList - // Output : //----------------------------------------------------------------------------- static BOOL _CheckEmptyEntities(CMapEntity *pEntity, CListBox *pList) { if(!pEntity->IsPlaceholder() && !pEntity->GetChildCount()) { AddError(pList, ErrorEmptyEntity, (DWORD)pEntity->GetClassName(), pEntity); } return(TRUE); }
//----------------------------------------------------------------------------- // Purpose: // Input : pSolid - // pList - // Output : //----------------------------------------------------------------------------- static BOOL FindDuplicatePlanes(CMapSolid *pSolid, CListBox *pList) { if (DoesContainDuplicates(pSolid)) { AddError(pList, ErrorDuplicatePlanes, 0, pSolid); } return(TRUE); }
void FWindowsNativeFeedbackContext::Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category ) { // if we set the color for warnings or errors, then reset at the end of the function // note, we have to set the colors directly without using the standard SET_WARN_COLOR macro if( Verbosity==ELogVerbosity::Error || Verbosity==ELogVerbosity::Warning ) { if( TreatWarningsAsErrors && Verbosity==ELogVerbosity::Warning ) { Verbosity = ELogVerbosity::Error; } FString Prefix; if( Context ) { Prefix = Context->GetContext() + TEXT(" : "); } FString Format = Prefix + FOutputDeviceHelper::FormatLogLine(Verbosity, Category, V); if(Verbosity == ELogVerbosity::Error) { // Only store off the message if running a commandlet. if ( IsRunningCommandlet() ) { AddError(Format); } } else { // Only store off the message if running a commandlet. if ( IsRunningCommandlet() ) { AddWarning(Format); } } } if( GLogConsole && IsRunningCommandlet() ) { GLogConsole->Serialize( V, Verbosity, Category ); } if( !GLog->IsRedirectingTo( this ) ) { GLog->Serialize( V, Verbosity, Category ); } // Buffer up the output during a slow task so that we can dump it all to the log console if the show log button is clicked if(GIsSlowTask) { FScopeLock Lock(&CriticalSection); if(hThread != NULL) { LogOutput += FString(V) + FString("\r\n"); SetEvent(hUpdateEvent); } } }
void CSrScriptErrorView::AddErrors (CSrScriptErrorArray& Errors) { dword Index; for (Index = 0; Index < Errors.GetSize(); ++Index) { AddError(Errors.GetAt(Index)); } }
void CANAbortCMD(void){ if((can_Status==CAN_Send)||(can_Status==CAN_Pending)){ Timer0_Stop(); can_queue[can_queue_tail]->cmd=CMD_ABORT; can_cmd(can_queue[can_queue_tail]); AddError(ERROR_CAN_SEND); can_Status=CAN_Ready; can_queue_tail=(can_queue_tail+1)%CAN_QUEUE_SIZE; } }
void CANSend(void){ can_queue[can_queue_tail]->cmd=CMD_TX_DATA; if(can_cmd(can_queue[can_queue_tail])!=CAN_CMD_ACCEPTED){ can_Status=CAN_Ready; AddError(ERROR_CAN_ACCEPTED); }else{ CANGIE|=(1<<ENERR); Timer0_Start(); } }
void SampleErrorListing::CreateListing() { StdTitle("Sampler Setup Errors"); SC_SetupErr sampErr; SampVarArray currSamp; if (currSamp.Size() < 1) { sampErr.SetConstantError("at least 1 variable must be sampled"); AddError(sampErr); } for (int i = 0; i < currSamp.Size(); i++) if (!currSamp[i]->SampleSetupOK(sampErr)) AddError(sampErr); //for FOSM or PEM - check to make sure all vars belong to same corr group if (!IsMonteCarlo()) { int uncertCorrGroup = currSamp[0]->GetCorrGroup(); if (!forceCorrelationsToZero) { //case where no correlations are set if ((currSamp[0]->GetnCorrGroup(uncertCorrGroup) > 1) && (currSamp[0]->correlations.Size() == 0)) AddError("correlations not set or forced to zero"); } for (int i = 1; i < currSamp.Size(); i++) { int currCorrGroup = currSamp[i]->GetCorrGroup(); if (currCorrGroup != uncertCorrGroup) AddError("FOSM/PEM: all uncertain vars must belong to same correlation group"); if (!forceCorrelationsToZero) { //case where individual correlations are not set for (int j = 0; j < currSamp[i]->correlations.Size(); j++) { if (RealIsNull(currSamp[i]->correlations[j].correlationValue)) AddError("correlations not set or forced to zero"); } } } } }
void SecondPass::outNode(StmtIfThenElse* n, bool last){ auto exprType = GetResultTypeOf(n->GetExpr()); if (exprType == nullptr) return; if (exprType->name != "bool"){ AddError(n->GetToken(), "Result type of if-else-condition must be 'bool' but is '%s'.", exprType->name.c_str()); } }
void DataCaptureErrorListing::CreateListing() { StdTitle("Simulation Results Setup Errors"); SC_SetupErr dcErr; if (dataCaptureData.IsEmpty()) AddError("no output data specified"); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsNotValid(i)) { AddError("Null capture spec found"); } else { if (!dataCaptureData.GetRef(i).SetupOK(dcErr)) { AddError(dcErr); } } if (productionRestartTimes.Size() > 0) { double prev = productionRestartTimes[0]; for (int i = 1; i < productionRestartTimes.Size(); i++) { double next = productionRestartTimes[i]; if (RealIsNull(prev) || RealIsNull(next)) { AddError("Null production restart time found"); break; } if (prev >= next) { AddError("Production restart times must be ascending"); break; } } } }
bool LWOFile::LoadUVMap(unsigned int iChunkSize) { Layer *pLayer=GetLastLayer(); const char *pChunkEndPos=m_pData+iChunkSize-4; unsigned short iDimension=0; if(!ReadU2(iDimension)) { return false; } // not 2 floats per vertex if(iDimension!=2) { // just skip m_pData+=iChunkSize-4-2; AddError("Warning: UVMap has "+ConvertToString(iDimension)+" floats per vertex (2 expected)"); return true; } unsigned int iStrBytes=0; std::string strName; if(!ReadS0(strName,iStrBytes)) { return false; } // VMAP { type[ID4], dimension[U2], name[S0], // ( vert[VX], value[F4] # dimension )* } UVMap *pUVMap=new UVMap(); pUVMap->m_strName=strName; pUVMap->m_Values.resize(2*pLayer->m_iPoints); pLayer->m_UVMaps.push_back(pUVMap); float *pValues=&(pUVMap->m_Values[0]); memset(pValues,0,sizeof(float)*2*pLayer->m_iPoints); while(m_pData<pChunkEndPos) { unsigned int iVertexID=0; if(!ReadVX(iVertexID)) return false; if(iVertexID>=pLayer->m_iPoints) return false; if(!ReadF4(pValues[iVertexID*2+0])) return false; if(!ReadF4(pValues[iVertexID*2+1])) return false; // flip v coordinate pValues[iVertexID*2+1]=1-pValues[iVertexID*2+1]; } return true; }
bool FBlueprintReparentTest::RunTest(const FString& BlueprintAssetPath) { bool bTestFailed = false; UBlueprint * const BlueprintTemplate = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath)); if (BlueprintTemplate != NULL) { // want to explicitly test switching from actors->objects, and vise versa (objects->actors), // also could cover the case of changing non-native parents to native ones TArray<UClass*> TestParentClasses; if (!BlueprintTemplate->ParentClass->IsChildOf(AActor::StaticClass())) { TestParentClasses.Add(AActor::StaticClass()); } else { // not many engine level Blueprintable classes that aren't Actors TestParentClasses.Add(USaveGame::StaticClass()); } TArray<FAssetData> Assets; FBlueprintAutomationTestUtilities::GetAssetListingFromConfig(TEXT("ReparentTest.ParentsPackagePaths"), Assets, UBlueprint::StaticClass()); // additionally gather up any blueprints that we explicitly specify though the config for (FAssetData const& AssetData : Assets) { UClass* AssetClass = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetClass.ToString()); TestParentClasses.Add(AssetClass); } for (UClass* Class : TestParentClasses) { UBlueprint* BlueprintObj = FBlueprintAutomationTestUtilities::DuplicateBlueprint(BlueprintTemplate); check(BlueprintObj != NULL); BlueprintObj->ParentClass = Class; if (!FBlueprintAutomationTestUtilities::TestSaveBlueprint(BlueprintObj)) { AddError(FString::Printf(TEXT("Failed to save blueprint after reparenting with %s: '%s'"), *Class->GetName(), *BlueprintAssetPath)); bTestFailed = true; } FBlueprintAutomationTestUtilities::UnloadBlueprint(BlueprintObj); } #if WITH_EDITOR // clear undo history to ensure that the transaction buffer isn't // holding onto any references to the blueprints we want unloaded GEditor->Trans->Reset(NSLOCTEXT("BpAutomation", "ReparentTest", "Reparent Blueprint Test")); #endif // #if WITH_EDITOR // make sure the unloaded blueprints are properly flushed (for future tests) CollectGarbage(RF_Native); } return !bTestFailed; }
Stack<Error>* Corrector::CheckExpression(Lexema *input) { int i = 0; int count_bracket = 0; while (input[i].GetType() != Type_Lexems::terminal) { if (IsDigit(input[i])) { if(IsDigitRight(input[i]) == false){ AddError(input[i].GetPosition(), "Ошибка в числе. Позиция ошибки: "); } } if (IsBinaryOperaion(input[i])) { if (input[i+1].GetType() == Type_Lexems::terminal) { AddError(input[i].GetPosition(), "Ошибка в бинарной операции. Позиция ошибки: "); } if (input[i + 1].GetType() != Type_Lexems::terminal && IsBinaryOperaion(input[i+1])) { AddError(input[i].GetPosition(), "Ошибка в повторе бинарной операций. Позиция ошибки: "); } if (input[i + 1].GetType() != Type_Lexems::terminal && input[i + 1].GetType() == Type_Lexems::close_bracket) { AddError(input[i].GetPosition(), "Ошибка в бинарной операции, пропущен аргумент. Позиция ошибки: "); } } if (IsOperationUnary(input[i])) { if (input[i + 1].GetType() == Type_Lexems::terminal) { AddError(input[i].GetPosition(), "Ошибка в унарной операции. Позиция ошибки: "); } if (input[i + 1].GetType() != Type_Lexems::terminal && input[i + 1].GetType() == Type_Lexems::close_bracket) { AddError(input[i].GetPosition(), "Ошибка в унарной операции, пропущен аргумент. Позиция ошибки: "); } } if (IsOpenBracket(input[i])) { count_bracket++; } if (IsCloseBracket(input[i])) { count_bracket--; if (count_bracket<0) { AddError(input[i].GetPosition(), "Ошибка в закрывающей скобке. Позиция ошибки: "); } } i++; } if (count_bracket != 0) { AddError("Ошибка в скобках."); } return &errors; }
void THISCLASS::OnReloadConfiguration() { mMinArea = GetConfigurationInt(wxT("MinArea"), 1); mMaxArea = GetConfigurationInt(wxT("MaxArea"), 1000); mMaxNumber = GetConfigurationInt(wxT("MaxNumber"), 10); mAreaSelection = GetConfigurationBool(wxT("AreaBool"), false); mMinCompactness = GetConfigurationDouble(wxT("MinCompactness"), 1); mMaxCompactness = GetConfigurationDouble(wxT("MaxCompactness"), 1000); mCompactnessSelection = GetConfigurationBool(wxT("CompactnessBool"), false); mMinOrientation = GetConfigurationDouble(wxT("MinOrientation"), -90); mMaxOrientation = GetConfigurationDouble(wxT("MaxOrientation"), 90); mOrientationSelection = GetConfigurationBool(wxT("OrientationBool"), false); // Check for stupid configurations if (mMaxNumber < 1) { AddError(wxT("Max number of particles must be greater or equal to 1")); } if (mMinArea > mMaxArea) { AddError(wxT("The min area must be smaller than the max area.")); } }
/////////////////////////////////////////////////// // GetValue /////////////////////////////////////////////////// float CAnalogIO::GetValue(bool updateFirst ) { float retVal = ANALOG_ERRVAL; if (!updateFirst) { return m_LastVal; } if (m_IsInput) { if (m_ReadCurrent) { int currentRegister; //Read current currentRegister = ((CDS2438*)(m_InDevice))->ReadCurrentRegister(); //Con i ritaratori serie CLIMA vado fuori scala if (currentRegister > 1023) { currentRegister = 1023; } retVal = (float)(currentRegister/(4096.0*m_ResistorValue)); } else { //The maximum range of the NTH-AFO-AI is 0-5V so we have to scale the value retVal = ((CDS2438*)(m_InDevice))->ReadVoltage( false )*2.0; } } else { retVal = (float)( ((CDS2890*)(m_InDevice))->ReadPosition() ); //Transform the position in volts retVal = (255.0 - retVal)/25.5; } if (retVal >= 0) { //Scalo il valore retVal = retVal*m_ScaleFactor+m_OffsetValue; m_LastVal = retVal; ClearError(); } else { AddError(); } return retVal; }
void CANAddSendData(st_cmd_t* Tx){ if((can_queue_head+1)%CAN_QUEUE_SIZE!=can_queue_tail){ can_queue[can_queue_head]=Tx; can_queue_head=(can_queue_head+1)%CAN_QUEUE_SIZE; }else{ AddError(ERROR_CANQUEUE_FULL); } if(can_Status==CAN_Ready){ CANSendData(); } }
void THISCLASS::OnStart() { wxString filename_string = GetConfigurationString(wxT("BackgroundImage"), wxT("")); wxFileName filename = mCore->GetProjectFileName(filename_string); if (filename.IsOk()) { mBackgroundImage = cvLoadImage(filename.GetFullPath().mb_str(wxConvFile), CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR); } if (! mBackgroundImage) { AddError(wxT("Cannot open background image.")); return; } if (mBackgroundImage->nChannels != 3) { AddError(wxT("Background Image has not 3 channels")); return; } // load other parameters: OnReloadConfiguration(); }
bool TParserBase::ConsumeString(Stroka* output, const char* error) { if (LookingAtType(Tokenizer::TYPE_STRING)) { Tokenizer::ParseString(CurrentToken().text, output); NextToken(); return true; } else { AddError(error); return false; } }
bool TParserBase::TryConsumeBOM() { // EF BB BF if (TryConsume('\xEF')) { if (TryConsume('\xBB')) if (TryConsume('\xBF')) return true; AddError("Found incomplete Byte Order Mark."); } return false; }
//----------------------------------------------------------------------------- // Purpose: // Input : pList - // pWorld - //----------------------------------------------------------------------------- static void CheckRequirements(CListBox *pList, CMapWorld *pWorld) { // ensure there's a player start .. if(pWorld->EnumChildren(ENUMMAPCHILDRENPROC(FindPlayer), 0, MAPCLASS_TYPE(CMapEntity))) { // if rvl is !0, it was not stopped prematurely.. which means there is // NO player start. AddError(pList, ErrorNoPlayerStart, 0); } }
bool TParserBase::ConsumeNumber(double* output, const char* error) { if (LookingAtType(Tokenizer::TYPE_FLOAT)) { *output = Tokenizer::ParseFloat(CurrentToken().text); NextToken(); return true; } else if (LookingAtType(Tokenizer::TYPE_INTEGER)) { // Also accept integers. ui64 value = 0; if (!Tokenizer::ParseInteger(CurrentToken().text, NProtoBuf::kuint64max, &value)) { AddError("Integer out of range."); // We still return true because we did, in fact, parse a number. } *output = (double)value; NextToken(); return true; } else { AddError(error); return false; } }
bool TParserBase::ConsumeDoubleSymbol(const char* symbols, const char* error) { YASSERT(strlen(symbols) == 2); // symbols should follow one another without whitespace between, // so we are checking positions. if (!TryConsume(symbols[0]) || !AdjacentToPrevious() || !TryConsume(symbols[1])) { AddError(error); return false; } return true; }
bool LWOFile::LoadFromFile(const char *strFile) { // try to open file HANDLE hFile=CreateFileA(strFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile==INVALID_HANDLE_VALUE) { AddError("Could not open file: " + std::string(strFile)); return false; } // get file size LARGE_INTEGER LI_Size; if(!GetFileSizeEx(hFile,&LI_Size)) { AddError("Could not get file size!"); return false; } unsigned int iFileSize=(unsigned int)LI_Size.QuadPart; // allocate memory to hold the file char *pData=new char[iFileSize]; // read file to memory DWORD iBytesRead=0; if(!ReadFile(hFile,pData,iFileSize,&iBytesRead,NULL) || iBytesRead!=iFileSize) { AddError("Reading file failed!"); delete[] pData; CloseHandle(hFile); return false; } // load if(!LoadFromMemory(pData, iFileSize)) return false; delete[] pData; CloseHandle(hFile); return true; }
void THISCLASS::OnStep() { // Get the input image IplImage* inputimage = mCore->mDataStructureImageGray.mImage; if (! inputimage) { AddError(wxT("No image on selected input.")); return; } // Calculate non-zero elements if (mCalculateNonZero) { int non_zero= cvCountNonZero(inputimage); CommunicationMessage m(wxT("STATS_NONZERO")); m.AddInt(non_zero); mCore->mCommunicationInterface->Send(&m); } // Calculate sum if (mCalculateSum) { CvScalar sum= cvSum(inputimage); CommunicationMessage m(wxT("STATS_SUM")); m.AddDouble(sum.val[0]); mCore->mCommunicationInterface->Send(&m); } // Calculate mean and standard deviation if (mCalculateMeanStdDev) { CvScalar mean; CvScalar std_dev; cvAvgSdv(inputimage, &mean, &std_dev, NULL); CommunicationMessage m(wxT("STATS_MEANSTDDEV")); m.AddDouble(mean.val[0]); m.AddDouble(std_dev.val[0]); mCore->mCommunicationInterface->Send(&m); } // Calculate min and max if (mCalculateMinMax) { double min_val; double max_val; cvMinMaxLoc(inputimage, &min_val, &max_val, NULL, NULL, NULL); CommunicationMessage m(wxT("STATS_MINMAX")); m.AddDouble(min_val); m.AddDouble(max_val); mCore->mCommunicationInterface->Send(&m); } // Set the display DisplayEditor de(&mDisplayOutput); if (de.IsActive()) { de.SetMainImage(inputimage); } }
bool TGztParser::ParseChainedFieldValues(TFieldValueDescriptorProto* value) { DO(ParseSingleFieldValue(value)); // try read several more values, interleaved with "+" or "|" if (!LookingAtListDelimiter()) return true; // What was previously read into @value was actually a first item of chained list, // not a single value. So transform @value to a list and place its current content // as first sub-value of this list. // Re-use previuosly allocated items THolder<TFieldValueDescriptorProto> sub_value; if (value->mutable_list()->mutable_value()->ClearedCount() > 0) { sub_value.Reset(value->mutable_list()->mutable_value()->ReleaseCleared()); sub_value->CopyFrom(*value); //sub_value->Swap(value); -- Swap is unsafe here because it creates cycles for some reason! } else sub_value.Reset(new TFieldValueDescriptorProto(*value)); value->Clear(); value->set_type(TFieldValueDescriptorProto::TYPE_LIST); value->mutable_list()->mutable_value()->AddAllocated(sub_value.Release()); // only single kind of separating token is allowed at single chained list. // so next we only accept a delimiters of same level which are equal to the first one. Stroka delimiter = CurrentToken().text; if (delimiter == "|") value->mutable_list()->set_type(TValuesListDescriptorProto::PIPE_DELIMITED); else if (delimiter == "+") value->mutable_list()->set_type(TValuesListDescriptorProto::PLUS_DELIMITED); else YASSERT(false); const char* delim_text = delimiter.c_str(); while (TryConsume(delim_text)) DO(ParseSingleFieldValue(value->mutable_list()->add_value())); // it is an error to meet any list delimiter here (as it will be mixed with previuos delimiters). if (!LookingAtListDelimiter()) return true; else { AddError(Substitute("Distinct kinds of delimiters (\"$0\" and \"$1\") " "should not be mixed in a single chained list at same level.", delimiter, CurrentToken().text)); return false; } }
void THISCLASS::OnStart() { // Load the background image wxString filename_string = GetConfigurationString(wxT("BackgroundImage"), wxT("")); wxFileName filename = mCore->GetProjectFileName(filename_string); if (filename.IsOk()) { mBackgroundImage = cvLoadImage(filename.GetFullPath().mb_str(wxConvFile), CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR); } if (! mBackgroundImage) { AddError(wxT("Cannot open background image.")); return; } // Check the background image // We explicitely do not convert image to grayscale automatically, as this is likely to be a configuration error of the user (e.g. wrong background selected). In addition, the user can easily convert a file to grayscale. if (mBackgroundImage->nChannels != 1) { AddError(wxT("Background image is not grayscale.")); return; } // Read the reloadable parameters OnReloadConfiguration(); }