wxString wxsCoder::GetFullCode(const wxString& FileName,wxFontEncoding& Encoding,bool &UseBOM) { wxMutexLocker Lock(DataMutex); wxString FixedFileName = NormalizeFileName(FileName); FlushFile(FixedFileName); // Checking if editor is opened EditorManager* EM = Manager::Get()->GetEditorManager(); assert ( EM != 0 ); cbEditor* Editor = EM->GetBuiltinEditor(FixedFileName); if ( Editor ) { Encoding = Editor->GetEncoding(); UseBOM = Editor->GetUseBom(); cbStyledTextCtrl* Ctrl = Editor->GetControl(); return Ctrl->GetText(); } else { EncodingDetector Detector(FixedFileName); Encoding = Detector.GetFontEncoding(); UseBOM = Detector.GetBOMSizeInBytes() > 0; return Detector.IsOK() ? Detector.GetWxStr() : _T(""); } }
// Preset Load bool SweepSettings::Load(QSettings &s) { mode = (OperationalMode)(s.value("Mode", (int)Mode()).toInt()); start = s.value("Sweep/Start", Start().Val()).toDouble(); stop = s.value("Sweep/Stop", Stop().Val()).toDouble(); center = s.value("Sweep/Center", Center().Val()).toDouble(); span = s.value("Sweep/Span", Span().Val()).toDouble(); step = s.value("Sweep/Step", Step().Val()).toDouble(); rbw = s.value("Sweep/RBW", RBW().Val()).toDouble(); vbw = s.value("Sweep/VBW", VBW().Val()).toDouble(); auto_rbw = s.value("Sweep/AutoRBW", AutoRBW()).toBool(); auto_vbw = s.value("Sweep/AutoVBW", AutoVBW()).toBool(); native_rbw = s.value("Sweep/NativeRBW", NativeRBW()).toBool(); refLevel.Load(s, "Sweep/RefLevel"); div = s.value("Sweep/Division", Div()).toDouble(); attenuation = s.value("Sweep/Attenuation", Atten()).toInt(); gain = s.value("Sweep/Gain", Gain()).toInt(); preamp = s.value("Sweep/Preamp", Preamp()).toInt(); sweepTime = s.value("Sweep/SweepTime", SweepTime().Val()).toDouble(); processingUnits = s.value("Sweep/ProcessingUnits", ProcessingUnits()).toInt(); detector = s.value("Sweep/Detector", Detector()).toInt(); rejection = s.value("Sweep/Rejection", Rejection()).toBool(); tgSweepSize = s.value("Sweep/TgSweepSize", tgSweepSize).toInt(); tgHighRangeSweep = s.value("Sweep/TgHighRangeSweep", tgHighRangeSweep).toBool(); tgPassiveDevice = s.value("Sweep/TgPassiveDevice", tgPassiveDevice).toBool(); UpdateProgram(); return true; }
/** deserialize the data from the Serializer * * reads the frame the the key and then the detctor from the serializer * * @return true when de serialization was successfull * @param in the serializer object to read the data from */ bool deserialize(SerializerBackend &in) { checkVersion(in); /** read the number of detectors */ size_t nbrDetectors(in.retrieve<size_t>()); /** read the key of the detector and then deserialze the detector */ for(uint32_t i(0); i < nbrDetectors; ++nbrDetectors) { detectors_t::key_type key(in.retrieve<detectors_t::key_type>()); _detectors[key] = Detector(in); } return true; }
bool SweepSettings::IsAveragePower() const { return (Detector() == BB_AVERAGE && ProcessingUnits() == BB_POWER); }
void begin(void) { #ifdef AVOID_PRINTF volatile float result; #endif struct BeamFirData coarse_fir_data[NUM_CHANNELS]; struct BeamFirData fine_fir_data[NUM_CHANNELS]; struct BeamFirData mf_fir_data[NUM_BEAMS]; float inputs[2*NUM_SAMPLES*NUM_CHANNELS]; float predec[2*NUM_POST_DEC_1*NUM_CHANNELS]; float postdec[NUM_CHANNELS][2*NUM_POST_DEC_2*NUM_CHANNELS]; float beam_weights[NUM_BEAMS][2*NUM_CHANNELS]; float beam_input[2*NUM_CHANNELS*NUM_POST_DEC_2]; float beam_output[2*NUM_POST_DEC_2]; float beam_fir_output[2*NUM_POST_DEC_2]; float beam_fir_mag[NUM_POST_DEC_2]; float detector_out[NUM_BEAMS][NUM_POST_DEC_2]; int i, j; for (i = 0; i < NUM_CHANNELS; i++) { BeamFirSetup(&coarse_fir_data[i], NUM_COARSE_TAPS); BeamFirSetup(&fine_fir_data[i], NUM_FINE_TAPS); } for (i = 0; i < NUM_BEAMS; i++) { BeamFirSetup(&mf_fir_data[i], MF_SIZE); BeamFormWeights(i, beam_weights[i]); } while (numiters == -1 || numiters-- > 0) { for (i = 0; i < NUM_CHANNELS; i++) { for (j = 0; j < NUM_CHANNELS; j++) InputGenerate(i, inputs + j*NUM_SAMPLES*2, NUM_SAMPLES); for (j = 0; j < NUM_POST_DEC_1; j++) BeamFirFilter(&coarse_fir_data[i], NUM_SAMPLES, COARSE_DECIMATION_RATIO, inputs + j * COARSE_DECIMATION_RATIO*2, predec + j * 2); for (j = 0; j < NUM_POST_DEC_2; j++) BeamFirFilter(&fine_fir_data[i], NUM_POST_DEC_1, FINE_DECIMATION_RATIO, predec + j * FINE_DECIMATION_RATIO * 2, postdec[i] + j * 2); } /* Assemble beam-forming input: */ for (i = 0; i < NUM_CHANNELS; i++) for (j = 0; j < NUM_POST_DEC_2; j++) { beam_input[j*NUM_CHANNELS*2+2*i] = postdec[i][2*j]; beam_input[j*NUM_CHANNELS*2+2*i+1] = postdec[i][2*j+1]; } for (i = 0; i < NUM_BEAMS; i++) { /* Have now rearranged NUM_CHANNELS*NUM_POST_DEC_2 items. * BeamForm takes NUM_CHANNELS inputs, 2 outputs. */ for (j = 0; j < NUM_POST_DEC_2; j++) BeamForm(i, beam_weights[i], beam_input + j*NUM_CHANNELS*2, beam_output + j*2); for (j = 0; j < NUM_POST_DEC_2; j++) BeamFirFilter(&mf_fir_data[i], NUM_POST_DEC_2, 1, beam_output+j*2, beam_fir_output+j*2); Magnitude(beam_fir_output, beam_fir_mag, NUM_POST_DEC_2); Detector(i, beam_fir_mag, detector_out[i]); } for (j = 0; j < NUM_POST_DEC_2; j++) for (i = 0; i < NUM_BEAMS; i++) #ifdef AVOID_PRINTF result = detector_out[i][j]; #else #ifdef raw print_float(detector_out[i][j]); #else printf("%f\n", detector_out[i][j]); #endif #endif } }
void QRcodeReader::decode() { Binarizer binarizer(img); img = binarizer.getBlackMatrix(); if (more) { imshow("original", rgbImg); imshow("test",img); waitKey(0); printf("**************************************************************\n"); printf("Begin detection to find the three finder pattern centers:\n"); } Finder finder = Finder(img); FinderResult fr = finder.find(); if (more) { printf("\n"); printf("Three finder pattern centers:\n"); FinderPoint bL = fr.getBottomLeft(); FinderPoint tL = fr.getTopLeft(); FinderPoint tR = fr.getTopRight(); printf("bottomLeft: (%f, %f)\n", bL.getX(), bL.getY()); printf("topLeft: (%f, %f)\n", tL.getX(), tL.getY()); printf("topRight: (%f, %f)\n", tR.getX(), tR.getY()); Point2f p1 = Point2f(bL.getX(), bL.getY()); circle(rgbImg, p1, 3, Scalar(0,255,0)); Point2f p2 = Point2f(tL.getX(), tL.getY()); circle(rgbImg, p2, 3, Scalar(0,255,0)); Point2f p3 = Point2f(tR.getX(), tR.getY()); circle(rgbImg, p3, 3, Scalar(0,255,0)); imshow("original", rgbImg); waitKey(0); } Detector detector = Detector(img); DetectorResult detectorResult = detector.processFinderPatternInfo(fr); if (more) { vector<FinderPoint> patternPoints = detectorResult.getResultPoints(); BitMatrix bits = detectorResult.getBits(); printf("\n"); printf("Module Size: %f\n", detectorResult.getModuleSize()); printf("Dimension: %d\n", detectorResult.getDimension()); printf("Alignment Pattern : (%f, %f)\n", patternPoints[3].getX(), patternPoints[3].getY()); Point2f p4 = Point2f(patternPoints[3].getX(), patternPoints[3].getY()); circle(rgbImg, p4, 3, Scalar(0,255,0)); imshow("original", rgbImg); waitKey(0); printf("\n"); printf("The bit matrix:\n"); bits.display(); printf("\nDetection Done!\n"); printf("**************************************************************\n"); waitKey(0); } Decoder decoder = Decoder(detectorResult); DecoderResult decoderResult = decoder.decode(); if (more) { printf("Decode:\n"); printf("version : %d\n", decoderResult.getVersion()); printf("Error correct level : %d\n", decoderResult.getEcLevel()); vector<char> resultBytes = decoderResult.getResultBytes(); printf("Data bytes: "); for (int i = 0; i < resultBytes.size(); ++i) { printf("%d ",resultBytes[i]); } printf("\n"); string result = decoderResult.getResultText(); printf("%s\n", result.c_str()); waitKey(0); } else { string result = decoderResult.getResultText(); printf("%s\n", result.c_str()); } }
void wxsCoder::FlushFile(const wxString& FileName) { int Index = CodeChangesFiles.Index(FileName); if ( Index == wxNOT_FOUND ) return; CodeChange* Changes = CodeChanges[Index]; if ( !Changes ) return; // Searching for file in opened file list EditorManager* EM = Manager::Get()->GetEditorManager(); assert ( EM != 0 ); cbEditor* Editor = EM->GetBuiltinEditor(FileName); if ( Editor ) { wxString EOL; while ( Changes ) { CodeChange* Next = Changes->Next; ApplyChangesEditor(Editor,Changes->Header,Changes->End,Changes->Code,Changes->CodeHasHeader,Changes->CodeHasEnd,EOL); delete Changes; Changes = Next; } } else { // Reading file content wxString EOL; bool HasChanged = false; //wxStopWatch SW; EncodingDetector Detector(FileName); if ( !Detector.IsOK() ) { #if wxCHECK_VERSION(2, 9, 0) Manager::Get()->GetLogManager()->Log(F(_("wxSmith: Couldn't open and properly read file '%s'"),FileName.wx_str())); #else Manager::Get()->GetLogManager()->Log(F(_("wxSmith: Couldn't open and properly read file '%s'"),FileName.c_str())); #endif return; } //Manager::Get()->GetLogManager()->DebugLog(F(_T("File read time: %d ms"),SW.Time())); wxString Content = Detector.GetWxStr(); while ( Changes ) { CodeChange* Next = Changes->Next; ApplyChangesString(Content,Changes->Header,Changes->End,Changes->Code,Changes->CodeHasHeader,Changes->CodeHasEnd,HasChanged,EOL); delete Changes; Changes = Next; } if ( HasChanged ) { // Storing the result //wxStopWatch SW; if ( !cbSaveToFile(FileName,Content,Detector.GetFontEncoding(),Detector.GetBOMSizeInBytes()>0) ) { #if wxCHECK_VERSION(2, 9, 0) Manager::Get()->GetLogManager()->Log(F(_("wxSmith: Couldn't write data to file '%s'"),FileName.wx_str())); #else Manager::Get()->GetLogManager()->Log(F(_("wxSmith: Couldn't write data to file '%s'"),FileName.c_str())); #endif } else { CodeBlocksEvent event(cbEVT_PROJECT_FILE_CHANGED); event.SetString(FileName); Manager::Get()->GetPluginManager()->NotifyPlugins(event); } //Manager::Get()->GetLogManager()->DebugLog(F(_T("File write time: %d ms"),SW.Time())); } } CodeChanges[Index] = 0; }
wxString wxsCoder::GetCode(const wxString& FileName,const wxString& Header,const wxString& End,bool IncludeHeader,bool IncludeEnd) { wxMutexLocker Lock(DataMutex); wxString FixedFileName = NormalizeFileName(FileName); FlushFile(FixedFileName); int TabSize = Manager::Get()->GetConfigManager(_T("editor"))->ReadInt(_T("/tab_size"), 4); // Checking if editor is opened EditorManager* EM = Manager::Get()->GetEditorManager(); assert ( EM != 0 ); cbEditor* Editor = EM->GetBuiltinEditor(FixedFileName); if ( Editor ) { cbStyledTextCtrl* Ctrl = Editor->GetControl(); Ctrl->SetSearchFlags(wxSCI_FIND_MATCHCASE); Ctrl->SetTargetStart(0); Ctrl->SetTargetEnd(Ctrl->GetLength()); int Position = Ctrl->SearchInTarget(Header); if ( Position == -1 ) return _T(""); // Counting number of indentation spaces which will be removed at // the beginning of each line int SpacesCut = 0; int SpacesPos = Position; while ( --SpacesPos >= 0 ) { wxChar ch = Ctrl->GetCharAt(SpacesPos); if ( ch == _T('\t') ) SpacesCut += TabSize; else if ( (ch==_T('\n')) || (ch==_T('\r')) ) break; else SpacesCut++; } Ctrl->SetTargetStart(Position); Ctrl->SetTargetEnd(Ctrl->GetLength()); int EndPosition = Ctrl->SearchInTarget(End); if ( EndPosition == -1 ) return _T(""); // Fixing up positions to include / exclude header and/or ending sequence if ( !IncludeHeader ) Position += Header.Length(); if ( IncludeEnd ) EndPosition += End.Length(); return CutSpaces(Ctrl->GetTextRange(Position,EndPosition),SpacesCut); } else { EncodingDetector Detector(FixedFileName); if ( !Detector.IsOK() ) return _T(""); wxString Content = Detector.GetWxStr(); int Position = Content.First(Header); if ( Position == -1 ) return _T(""); int SpacesCut = 0; int SpacesPos = Position; while ( --SpacesPos >= 0 ) { wxChar ch = Content.GetChar(SpacesPos); if ( ch == _T('\t') ) SpacesCut += TabSize; else if ( (ch==_T('\n')) || (ch==_T('\r')) ) break; else SpacesCut++; } if ( !IncludeHeader ) Position += Header.Length(); Content.Remove(0,Position); int EndPosition = Content.First(End); if ( EndPosition == -1 ) return _T(""); if ( IncludeEnd ) EndPosition += End.Length(); Content.Remove(EndPosition); return CutSpaces(Content,SpacesCut); } }