void SimpleHome(int axis,float speed,int dir,int bit,int polarity, float offset) { int SaveLimits; //place to save limit switch settings DisableAxis(axis); // disable the limits (first save how they were set) SaveLimits = chan[axis]->LimitSwitchOptions; chan[axis]->LimitSwitchOptions = 0; EnableAxis(axis); // enable axis and begin servoing where we are // Home - jog until it sees the limit Jog(axis,speed*dir); // jog slowly while (!ReadBit(bit)) ; // loop until IO bit goes high Jog(axis,0); // stop while (!CheckDone(axis)) // loop until motion completes if (!chan[axis].Enable) return; // abort/exit if diasabled DisableAxis(axis); // disable the axis Zero(axis); // Zero the position EnableAxis(axis); // re-enable Move(axis,-dir * offset); // move some amount inside the limits while (!CheckDone(axis)) ; // loop until motion completes chan[axis]->LimitSwitchOptions = SaveLimits; // restore limit settings }
void Tap(void) { // #10 1010 18 19 TPI // #11 1011 20 21 Feed Rate in/min // #12 1012 22 23 Retract Rate in/min // #13 1013 24 25 Z depth Total inches // #14 1014 26 27 Z depth Forward per Motion // #15 1015 28 29 Z depth Retract per Motion double TPI = *(double *)&persist.UserData[18]; double FeedRate = *(double *)&persist.UserData[20]/60.0; double RetractRate = *(double *)&persist.UserData[22]/60.0; double ZDist = *(double *)&persist.UserData[24]; double ZForward = *(double *)&persist.UserData[26]; double ZReverse = *(double *)&persist.UserData[28]; printf("TPI = %f\n",TPI); printf("FeedRate = %f\n",FeedRate); printf("RetractRate = %f\n",RetractRate); printf("ZDist = %f\n",ZDist); printf("ZForward= %f\n",ZForward); printf("ZReverse = %f\n",ZReverse); // Slave the Z Axis to the Spindle SlaveGain = Z_CNTS_PER_INCH/(CNTS_PER_REV * TPI); Z0 = chan[ZAXIS].Dest; S0 = chan[SPINDLE_AXIS].Dest; // in case there is significant spindle position error move there first Move(ZAXIS,(chan[SPINDLE_AXIS].Position-S0)*SlaveGain+Z0); while (!CheckDone(ZAXIS)) ; TotalCut=0.0; while (TotalCut < ZDist) { if (TotalCut + ZForward > ZDist) // last feed { // yes, do any remaining DoTap(ZDist-TotalCut, FeedRate, TPI); // retract fully DoTap(-ZDist, RetractRate, TPI); TotalCut=ZDist; } else { // no, just cut a bit DoTap(ZForward, FeedRate, TPI); DoTap(-ZReverse, RetractRate, TPI); TotalCut+=ZForward-ZReverse; } } Delay_sec(1.0); Move(ZAXIS,Z0); // move back to where we started while (!CheckDone(ZAXIS)) ; }
void stop() { if (mChannel>=0) Mix_HaltChannel(mChannel); CheckDone(); }
main() { float speed = *(float *)&persist.UserData[97]; // value stored is actually a float float LastSpeed = *(float *)&persist.UserData[99]; // get last speed setting float LastState = persist.UserData[98]; // get last state if (LastState==1) { // if spindle was CW now we want CCW // spin down ClearBit(154); ClearBit(155); LastSpeed = 0.0; Jog(SPINDLEAXIS,0); while (!CheckDone(SPINDLEAXIS)) ; } // turn spindle on CCW and ramp to new speed SetBit(155); // spindle is already on, so ramp to new speed if (LastSpeed != speed) { LastSpeed = speed; Jog(SPINDLEAXIS,LastSpeed * FACTOR); } *(float *)&persist.UserData[99] = LastSpeed; // save the last speed persist.UserData[98] = -1; // remember we are CCW }
main() { float speed = *(float *)&persist.UserData[SPEEDVAR]; // value stored is actually a float float LastState = persist.UserData[STATEVAR]; // get last state if (LastState==1) { // if spindle was CW now we want CCW // spin down ClearBit(SPINDLECW_BIT); ClearBit(SPINDLECCW_BIT); Jog(SPINDLEAXIS,0); while (!CheckDone(SPINDLEAXIS)) ; } // turn spindle on CCW and ramp to new speed SetBit(SPINDLECCW_BIT); // spindle is already on, so ramp to new speed Jog(SPINDLEAXIS,-speed * FACTOR); printf("Jogging Spindle %f counts/sec\n",speed * FACTOR); persist.UserData[STATEVAR] = -1; // remember we are CCW }
void MainWindow::CheckCode(const QString& code, const QString& filename) { // Initialize dummy ThreadResult as ErrorLogger ThreadResult result; result.SetFiles(QStringList(filename)); connect(&result, SIGNAL(Progress(int, const QString&)), mUI.mResults, SLOT(Progress(int, const QString&))); connect(&result, SIGNAL(Error(const ErrorItem &)), mUI.mResults, SLOT(Error(const ErrorItem &))); connect(&result, SIGNAL(Log(const QString &)), this, SLOT(Log(const QString &))); connect(&result, SIGNAL(DebugError(const ErrorItem &)), this, SLOT(DebugError(const ErrorItem &))); // Create CppCheck instance CppCheck cppcheck(result, true); cppcheck.settings() = GetCppcheckSettings(); // Check CheckLockDownUI(); ClearResults(); mUI.mResults->CheckingStarted(1); cppcheck.check(filename.toStdString(), code.toStdString()); CheckDone(); }
void DoTap(double Dist, double Rate, double TPI) { // Tap down MoveRelAtVel(SPINDLE_AXIS, Dist*TPI*CNTS_PER_REV, Rate*TPI*CNTS_PER_REV); while(!CheckDone(SPINDLE_AXIS)) DoSlave(); }
main() { ch0->LimitSwitchOptions=0x00000000; // disable limits Jog(0,-100); // start moving while (!Readbit(8)) ; // wait for switch (input #8) to change Jog(0,0); // stop while (!CheckDone(0)) ; // wait till we are stopped Zero(0); // Set current position to 0 Move(0,1000); // move off limit while (!CheckDone(0)) ; // wait till we are stopped // re-enable limits, bit 8 both ends, active low, disable all axis ch0->LimitSwitchOptions=0x808000f; }
void EHSConnection::AddResponse ( HttpResponse * ipoHttpResponse ) { MUTEX_LOCK ( m_oConnectionMutex ); // push the object on to the list m_oHttpResponseMap [ ipoHttpResponse->m_nResponseId ] = ipoHttpResponse; // go through the list until we can't find the next response to send int nFoundNextResponse = 0; do { nFoundNextResponse = 0; if ( m_oHttpResponseMap.find ( m_nResponses + 1 ) != m_oHttpResponseMap.end ( ) ) { nFoundNextResponse = 1; HttpResponseMap::iterator i = m_oHttpResponseMap.find ( m_nResponses + 1 ); SendHttpResponse ( i->second ); delete i->second; m_oHttpResponseMap.erase ( i ); m_nResponses++; // set last activity to the current time for idle purposes UpdateLastActivity ( ); // if we're done with this connection, get rid of it if ( CheckDone ( ) ) { EHS_TRACE( "add response found something to delete\n" ); // careful with mutexes around here.. Don't want to hold both MUTEX_UNLOCK ( m_oConnectionMutex ); MUTEX_LOCK ( m_poEHSServer->m_oMutex ); m_poEHSServer->RemoveEHSConnection ( this ); MUTEX_UNLOCK ( m_poEHSServer->m_oMutex ); return; } EHS_TRACE ( "Sending response %d to %x\n", m_nResponses, this ); } } while ( nFoundNextResponse == 1 ); MUTEX_UNLOCK ( m_oConnectionMutex ); }
main() { // spin down ClearBit(SPINDLECW_BIT); ClearBit(SPINDLECCW_BIT); Jog(SPINDLEAXIS,0); printf("Jogging Spindle Stop\n"); persist.UserData[STATEVAR] = 0; // remember we are Off while (!CheckDone(SPINDLEAXIS)) ; }
main() { for(;;) { Move(4,8000); while (!CheckDone(4)); Delay_sec(0.2); Move(4,16000); while (!CheckDone(4)); Delay_sec(0.2); Move(4,24000); while (!CheckDone(4)); Delay_sec(0.2); Move(4,32000); while (!CheckDone(4)); Delay_sec(0.2); Move(4,40000); while (!CheckDone(4)); Delay_sec(0.2); Move(4,00000); while (!CheckDone(4)); } }
// for persistent connections (keepAlive = true), reuse the open connection to make another request bool Download::Reuse(std::string newuri) { if (!keepAlive || !CheckDone() || CheckCanceled()) { return false; } uri = std::string(newuri); DownloadManager::Ref().Lock(); downloadFinished = false; DownloadManager::Ref().Unlock(); Start(); DownloadManager::Ref().EnsureRunning(); return true; }
// start the download thread void Download::Start() { if (CheckStarted() || CheckDone()) return; http = http_async_req_start(http, uri.c_str(), postData.c_str(), postData.length(), keepAlive ? 1 : 0); // add the necessary headers if (userID.length() || userSession.length()) http_auth_headers(http, userID.c_str(), NULL, userSession.c_str()); if (postDataBoundary.length()) http_add_multipart_header(http, postDataBoundary); DownloadManager::Ref().Lock(); downloadStarted = true; DownloadManager::Ref().Unlock(); }
void ServerMessagesSyncer::HandleFinished (QNetworkReply *reply, IMessage::Direction dir) { const auto& json = Util::ParseJson (reply, Q_FUNC_INFO); reply->deleteLater (); const auto itemsVar = json.toMap () ["response"].toMap () ["items"]; if (itemsVar.type () != QVariant::List) { ReportError ("Unable to parse reply."); return; } const auto& itemsList = itemsVar.toList (); const auto& accId = Acc_->GetAccountID (); for (const auto& mapVar : itemsList) { const auto& map = mapVar.toMap (); const HistoryItem item { QDateTime::fromTime_t (map ["date"].toULongLong ()), dir, map ["body"].toString (), {}, IMessage::Type::ChatMessage, {}, IMessage::EscapePolicy::Escape }; const auto& id = accId + QString::number (map ["user_id"].toLongLong ()); Messages_ [id].VisibleName_ = id; Messages_ [id].Messages_ << item; } if (itemsList.size () == RequestSize) { Offset_ += RequestSize; Request (dir); } else { Dones_.insert (dir); CheckDone (); } }
// finish the download (if called before the download is done, this will block) char* Download::Finish(int *length, int *status) { if (CheckCanceled()) return NULL; // shouldn't happen but just in case while (!CheckDone()); // block DownloadManager::Ref().Lock(); downloadStarted = false; if (length) *length = downloadSize; if (status) *status = downloadStatus; char *ret = downloadData; downloadData = NULL; if (!keepAlive) downloadCanceled = true; DownloadManager::Ref().Unlock(); return ret; }
int MIDIStreamer::FillBuffer(int buffer_num, int max_events, DWORD max_time) { if (!Restarting && CheckDone()) { return SONG_DONE; } int i; DWORD *events = Events[buffer_num], *max_event_p; DWORD tot_time = 0; DWORD time = 0; // The final event is for a NOP to hold the delay from the last event. max_event_p = events + (max_events - 1) * 3; if (InitialPlayback) { InitialPlayback = false; // Send the full master volume SysEx message. events[0] = 0; // dwDeltaTime events[1] = 0; // dwStreamID events[2] = (MEVT_LONGMSG << 24) | 8; // dwEvent events[3] = MAKE_ID(0xf0,0x7f,0x7f,0x04); // dwParms[0] events[4] = MAKE_ID(0x01,0x7f,0x7f,0xf7); // dwParms[1] events += 5; DoInitialSetup(); } // If the volume has changed, stick those events at the start of this buffer. if (VolumeChanged && (m_Status != STATE_Paused || NewVolume == 0)) { VolumeChanged = false; for (i = 0; i < 16; ++i) { BYTE courseVol = (BYTE)(((ChannelVolumes[i]+1) * NewVolume) >> 16); events[0] = 0; // dwDeltaTime events[1] = 0; // dwStreamID events[2] = MIDI_CTRLCHANGE | i | (7<<8) | (courseVol<<16); events += 3; } }
bool CMove::CheckFailed() { bool inList = false; Point ptDestination = (m_nSrcMapID == m_nTargetMapID ? m_DonePos : m_Destination); for (size_t i = 0; i < path.size(); i++) { if (path[i].x == ptDestination.x && path[i].y == ptDestination.y) { inList = true; break; } } if (!inList) return true; if (!gHero->IsMoving() && !CheckDone()) { return true; } return false; }
// Services Tool Change Sequence void ServiceToolChange(void) { switch (*ChangerState) { case T_IDLE: { break; } case T_START: { if (*LastTool==0) { printf("Error Last Tool Never defined\n"); *ChangerState = T_IDLE; // go idle } else if (*LastTool > 5 || *LastTool < 1) { printf("Invalid LastTool Number %d\n",*Tool); *ChangerState = T_IDLE; // go idle } else if (*Tool > 5 || *Tool < 1) { printf("Invalid Tool Number %d\n",*Tool); *ChangerState = T_IDLE; // go idle } else { printf("Tool Change Z Up\n"); Move(Z,10000); *ChangerState = T_WAIT_Z_UP; } break; } case T_WAIT_Z_UP: { if (CheckDone(Z)) { printf("Tool Change Move XY to Unload\n"); Move(X,ToolPositionX[*LastTool]); Move(Y,ToolPositionY[*LastTool]); *ChangerState = T_WAIT_MOVE_XY_UNLOAD; } break; } case T_WAIT_MOVE_XY_UNLOAD: { if (CheckDone(X) && CheckDone(Y)) { printf("Tool Change Z Down\n"); Move(Z,10000); // start Z moving down fast *ChangerState = T_WAIT_MOVE_Z_DOWN_FAST; } break; } case T_WAIT_MOVE_Z_DOWN_FAST: { if (chan[Z].Dest < 1000.0) { MoveAtVel(Z,10000,100.0); // slow down Z *ChangerState = T_WAIT_MOVE_Z_DOWN_SLOW; } break; } case T_WAIT_MOVE_Z_DOWN_SLOW: { if (chan[Z].Dest < 500.0) { MoveAtVel(Z,10000,50.0); // slow down Z more *ChangerState = T_WAIT_MOVE_Z_DOWN_VERYSLOW; } break; } case T_WAIT_MOVE_Z_DOWN_VERYSLOW: { if (CheckDone(Z)) { printf("Tool Change Unclamp\n"); SetBit(TOOL_CLAMP_BIT); *ChangerState = T_WAIT_OPENCLAMP; } break; } case T_WAIT_OPENCLAMP: { if (ReadBit(TOOL_CLAMP_STATUS_BIT)) { printf("Tool Change Z Up #2\n"); Move(Z,10000); *ChangerState = T_WAIT_Z_UP2; } break; } case T_WAIT_Z_UP2: { if (CheckDone(Z)) { printf("Tool Change Move XY to Load\n"); Move(X,ToolPositionX[*Tool]); Move(Y,ToolPositionY[*Tool]); *ChangerState = T_WAIT_MOVE_XY_LOAD; } break; } case T_WAIT_MOVE_XY_LOAD: { if (CheckDone(X) && CheckDone(Y)) { printf("Tool Change Z Down\n"); Move(Z,10000); // start Z moving down fast *ChangerState = T_WAIT_MOVE_Z_DOWN_FAST2; } break; } case T_WAIT_MOVE_Z_DOWN_FAST2: { if (chan[Z].Dest < 1000.0) { MoveAtVel(Z,10000,100.0); // slow down Z *ChangerState = T_WAIT_MOVE_Z_DOWN_SLOW2; } break; } case T_WAIT_MOVE_Z_DOWN_SLOW2: { if (chan[Z].Dest < 500.0) { MoveAtVel(Z,10000,50.0); // slow down Z more *ChangerState = T_WAIT_MOVE_Z_DOWN_VERYSLOW2; } break; } case T_WAIT_MOVE_Z_DOWN_VERYSLOW2: { if (CheckDone(Z)) { SetBit(TOOL_CLAMP_BIT); *ChangerState = T_WAIT_CLOSECLAMP; } break; } case T_WAIT_CLOSECLAMP: { if (!ReadBit(TOOL_CLAMP_STATUS_BIT)) { printf("Tool Change Z Up #2\n"); Move(Z,10000); *ChangerState = T_WAIT_Z_UP3; } break; } case T_WAIT_Z_UP3: { if (CheckDone(Z)) { printf("Tool Change Move XY to Probe\n"); Move(X,ProbeX); Move(Y,ProbeY); *ChangerState = T_WAIT_MOVE_XY_PROBE; } break; } case T_WAIT_MOVE_XY_PROBE: { if (CheckDone(X) && CheckDone(Y)) { printf("Tool Change Complete\n"); *LastTool = *Tool; // remember where we are *ChangerState = T_IDLE; } break; } } }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); }
TArray<uint16_t> MIDISource::PrecacheData() { uint32_t Events[2][MAX_MIDI_EVENTS*3]; uint8_t found_instruments[256] = { 0, }; uint8_t found_banks[256] = { 0, }; bool multiple_banks = false; LoopLimit = 1; DoRestart(); found_banks[0] = true; // Bank 0 is always used. found_banks[128] = true; // Simulate playback to pick out used instruments. while (!CheckDone()) { uint32_t *event_end = MakeEvents(Events[0], &Events[0][MAX_MIDI_EVENTS*3], 1000000*600); for (uint32_t *event = Events[0]; event < event_end; ) { if (MEVENT_EVENTTYPE(event[2]) == 0) { int command = (event[2] & 0x70); int channel = (event[2] & 0x0f); int data1 = (event[2] >> 8) & 0x7f; int data2 = (event[2] >> 16) & 0x7f; if (channel != 9 && command == (MIDI_PRGMCHANGE & 0x70)) { found_instruments[data1] = true; } else if (channel == 9 && command == (MIDI_PRGMCHANGE & 0x70) && data1 != 0) { // On a percussion channel, program change also serves as bank select. multiple_banks = true; found_banks[data1 | 128] = true; } else if (channel == 9 && command == (MIDI_NOTEON & 0x70) && data2 != 0) { found_instruments[data1 | 128] = true; } else if (command == (MIDI_CTRLCHANGE & 0x70) && data1 == 0 && data2 != 0) { multiple_banks = true; if (channel == 9) { found_banks[data2 | 128] = true; } else { found_banks[data2] = true; } } } // Advance to next event if (event[2] < 0x80000000) { // short message event += 3; } else { // long message event += 3 + ((MEVENT_EVENTPARM(event[2]) + 3) >> 2); } } }
void MakeWhite (typePOS* POSITION, uint32 move) { int fr, to, pi, fl, cp, z; uint64 mask; TRACE (TRACE_MAKE_UNMAKE, printf ("Mw %d %s\n", HEIGHT (POSITION), Notate(move, STRING1[POSITION->cpu]))); POSITION->nodes++; if (!TITANIC_MODE) /* new */ { NODE_CHECK++; if ((NODE_CHECK & 4095) == 0) CheckDone (POSITION, 0); } memcpy (POSITION->DYN + 1, POSITION->DYN, 32); fr = FROM (move); to = TO (move); #ifdef CHESS_960 if (UCI_OPTION_CHESS_960 && MoveIsOO (move)) { Castle960White (POSITION, move, to, fr); return; } #endif pi = POSITION->sq[fr]; POSITION->DYN++; REV_HASH (POSITION); POSITION->DYN->reversible++; POSITION->DYN->move = move; fl = CastleTable[fr] & CastleTable[to] & POSITION->DYN->oo; POSITION->DYN->HASH ^= ZobristCastling[POSITION->DYN->oo ^ fl]; POSITION->DYN->PAWN_HASH ^= ZobristCastling[POSITION->DYN->oo ^ fl]; POSITION->DYN->oo = fl; if (POSITION->DYN->ep) { POSITION->DYN->HASH ^= ZobristEP[POSITION->DYN->ep & 7]; POSITION->DYN->ep = 0; } POSITION->sq[fr] = 0; mask = SqClear[fr]; wBitboardOcc &= mask; POSITION->bitboard[pi] &= mask; ClearOccupied (mask, fr); POSITION->DYN->STATIC += PST (pi, to) - PST (pi, fr); mask = Zobrist (pi, fr) ^ Zobrist (pi, to); cp = POSITION->sq[to]; POSITION->DYN->cp = cp; POSITION->DYN->HASH ^= mask; if (pi == wEnumP) POSITION->DYN->PAWN_HASH ^= mask; POSITION->wtm ^= 1; POSITION->height++; POSITION->DYN->HASH ^= ZobristWTM; if (pi == wEnumK) { POSITION->DYN->PAWN_HASH ^= mask; POSITION->wKsq = to; } if (cp) { mask = SqClear[to]; bBitboardOcc &= mask; POSITION->bitboard[cp] &= mask; POSITION->DYN->material -= MATERIAL_VALUE[cp]; POSITION->DYN->STATIC -= PST (cp, to); if (cp == bEnumP) POSITION->DYN->PAWN_HASH ^= Zobrist (cp, to); POSITION->DYN->HASH ^= Zobrist (cp, to); POSITION->DYN->reversible = 0; } else { mask = SqSet[to]; SetOccupied (mask, to); if (MoveIsOO (move)) { REV_CASTLE (POSITION); MakeWhiteOO (POSITION, to); } } POSITION->sq[to] = pi; wBitboardOcc |= SqSet[to]; POSITION->bitboard[pi] |= SqSet[to]; if (pi == wEnumP) { POSITION->DYN->reversible = 0; if (MoveIsEP (move)) { z = to ^ 8; mask = SqClear[z]; bBitboardOcc &= mask; bBitboardP &= mask; ClearOccupied (mask, z); POSITION->DYN->material -= MATERIAL_VALUE[bEnumP]; POSITION->DYN->STATIC -= PST (bEnumP, z); POSITION->DYN->HASH ^= Zobrist (bEnumP, z); POSITION->DYN->PAWN_HASH ^= Zobrist (bEnumP, z); POSITION->sq[z] = 0; } else if (MoveIsProm (move)) { pi = PromW[(move & FLAG_MASK) >> 12]; if (pi == wEnumBL && SqSet[to] & DARK) pi = wEnumBD; POSITION->sq[to] = pi; if (POSITION->bitboard[pi]) POSITION->DYN->material |= 0x80000000; wBitboardP &= SqClear[to]; POSITION->bitboard[pi] |= SqSet[to]; POSITION->DYN->material += MATERIAL_VALUE[pi] - MATERIAL_VALUE[wEnumP]; POSITION->DYN->STATIC += PST (pi, to) - PST (wEnumP, to); POSITION->DYN->HASH ^= Zobrist (pi, to) ^ Zobrist (wEnumP, to); POSITION->DYN->PAWN_HASH ^= Zobrist (wEnumP, to); } else if ((to ^ fr) == 16)
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLanguages(new QActionGroup(this)), mLogView(NULL), mHelpWindow(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView(mSettings); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); CreateLanguageMenuItems(); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { DoCheckFiles(args); } }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLanguages(new QActionGroup(this)) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionShowAll, SIGNAL(toggled(bool)), this, SLOT(ShowAll(bool))); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowAllStyle, SIGNAL(toggled(bool)), this, SLOT(ShowAllStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); connect(mUI.mActionToolbar, SIGNAL(toggled(bool)), this, SLOT(ToggleToolbar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); CreateLanguageMenuItems(); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { DoCheckFiles(args); } }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mPlatformActions(new QActionGroup(this)), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); // Must setup MRU menu before CLI param handling as it can load a // project file and update MRU menu. for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mRecentProjectActs[MaxRecentProjects] = NULL; // The separator mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < mPlatforms.getCount(); i++) { Platform plat = mPlatforms.mPlatforms[i]; QAction *act = new QAction(this); plat.mActMainWindow = act; mPlatforms.mPlatforms[i] = plat; act->setText(plat.mTitle); act->setData(plat.mType); act->setCheckable(true); act->setActionGroup(mPlatformActions); mUI.mMenuCheck->insertAction(mUI.mActionPlatforms, act); connect(act, SIGNAL(triggered()), this, SLOT(SelectPlatform())); } // For Windows platforms default to Win32 checked platform. // For other platforms default to unspecified/default which means the // platform Cppcheck GUI was compiled on. #if defined(_WIN32) Platform &plat = mPlatforms.get(Settings::Win32A); #else Platform &plat = mPlatforms.get(Settings::Unspecified); #endif plat.mActMainWindow->setChecked(true); mSettings->setValue(SETTINGS_CHECKED_PLATFORM, plat.mType); }
bool isComplete() { CheckDone(); return !mPlaying; }
bool isComplete() { CheckDone(); return mChannel < 0; }