void HWindow::DispatchMessage(BMessage* message, BHandler* handler) { if (message->what == B_PULSE) Pulse(); BWindow::DispatchMessage(message, handler); }
void outbit(bit i_bit) //one bit output { if(i_bit) { Pulse(24); //send '1' out=0; Delay(40); } else { Pulse(12); //send '0' out=0; Delay(80); } }
void mousePressed(int x, int y, int b) { if(!selected) { selected = true; selectedIndex = people.size(); people.push_back(Person(x - ofGetWidth() / 2, y - ofGetHeight() / 2, people.size())); if(people.size() > 1) { pulses.push_back(Pulse(people.back().getAngle(), selectedIndex)); } } }
void MemoryBarMenu::Draw(BRect updateRect) { if (fFirstShow) { Pulse(); fFirstShow = false; } BMenu::Draw(updateRect); }
void ModalProgressDialog::setText(const std::string& text) { // If the aborted flag is set, throw an exception here if (WasCancelled()) { throw OperationAbortedException(_("Operation cancelled by user")); } Pulse(text); }
// Producer void * NotifyPotentialWork(void * arg) { hasWork = 1; //fence; MFENCE(); if(isIdling) { obtain_lock(__unbuffered_condVariable); Pulse(__unbuffered_condVariable); release_lock(__unbuffered_condVariable); } __unbuffered_prod_done=1; }
void SSLReceiver::readPendingDatagrams() { while (_udpsocket.hasPendingDatagrams()) { QByteArray datagram; datagram.resize(_udpsocket.pendingDatagramSize()); QHostAddress sender; quint16 senderPort; _udpsocket.readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); newReceivedPacket(datagram,sender.toString(),senderPort); Pulse(); } }
void PiggybackTaskLoop::PulseMe() { if (!fPulseMe) return; bigtime_t time = system_time(); if (fNextHeartBeatTime < time) { AutoLock<BLocker> autoLock(&fLock); if (Pulse()) fPulseMe = false; fNextHeartBeatTime = time + fHeartBeat; } }
bool SpectraCoroutineExecution::DoWork(void) { bool result = coroutine->DoWork(); int pd = coroutine->PercentDone(); if(pd >= 0 && pd <= 100) { if(!Update(pd)) return true; } else { if(!Pulse()) return true; } return result; }
void send(uchar in_data) //send a data with 8 bits { uchar i; bit DI; Pulse(40);//start out=0; Delay(120); //433mHz transmitter is activated for(i=0;i<8;i++)//send data { DI=(bit)(in_data&0x80); outbit(DI); in_data<<=1; } }
void setup() { ofSetFrameRate(60); ofSetVerticalSync(false); ledRing.setup(); fbo.allocate(512, 512); fbo.begin(); ofClear(0); fbo.end(); ofSetCircleResolution(64); ofSetLineWidth(2); ofLog() << "MIDI Ports: " << ofToString(midi.getPortList()); midi.openPort(); Pulse::midiWrapper = &midiWrapper; pulses.push_back(Pulse(0, 0)); }
U32 CPPMSimulationDataGenerator::GenerateSimulationData(U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor **simulation_channel) { U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample(largest_sample_requested, sample_rate, mSimulationSampleRateHz); while (mCPPMSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested) { Pulse(); } *simulation_channel = &mCPPMSimulationData; return 1; }
void TTimeView::MouseDown(BPoint point) { uint32 buttons; Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); if (buttons == B_SECONDARY_MOUSE_BUTTON) { ShowTimeOptions(ConvertToScreen(point)); return; } else if (buttons == B_PRIMARY_MOUSE_BUTTON) ShowCalendar(point); // invalidate last time/date strings and call the pulse // method directly to change the display instantly fLastDateStr[0] = '\0'; fLastTimeStr[0] = '\0'; Pulse(); }
void NIDAQWrapper::PulseSwitch(int Sector, bool Cross) { if(Sector < 0 || Sector > 8) return; if(Sector == 7 || Sector == 8) { // Cludgey workaround for their labelling Sector = (Sector == 7) ? 8 : 7; } int port = Sector > 4; int channel = ((Sector-1)%4)*2 + Cross; Pulse(writeHandles[port], port, channel, winLog); if(Sector == 7 || Sector == 8) { //Cludgey workaround for their labelling Sector = (Sector == 7) ? 8 : 7; } switches[Sector-1] = Cross; }
void StandAloneTaskLoop::Run() { for(;;) { AutoLock<BLocker> autoLock(&fLock); if (!autoLock) return; if (fNeedToQuit) { // task loop being deleted, let go of the thread allowing the // to go through deletion fScanThread = -1; return; } if (Pulse()) { fScanThread = -1; return; } // figure out when to run next by checking out when the different // tasks wan't to be woken up, snooze until a little bit before that // time bigtime_t now = system_time(); bigtime_t latestRunTime = LatestRunTime() - 1000; bigtime_t afterHeartBeatTime = now + fHeartBeat; bigtime_t snoozeTill = latestRunTime < afterHeartBeatTime ? latestRunTime : afterHeartBeatTime; autoLock.Unlock(); if (snoozeTill > now) snooze_until(snoozeTill, B_SYSTEM_TIMEBASE); else snooze(1000); } }
int main(void) { char *currenttime; /* current time/date string */ int old_sec = 0; // int cur_hour = 0; /* current hour */ // int cur_day = 0; /* current current day */ int result = 0; int key = 0; Initialise(); // turn outputs on and off for 1 second InitDisplay(); int keepgoing = 1; /* tells program to keep running until ESC pressed */ while ( keepgoing == 1 ) { currenttime = thetime(); /* get the current time */ cur_sec = extract_num(currenttime, 18, 2); /* extract minute */ cur_min = extract_num(currenttime, 15, 2); /* extract minute */ cur_hour = extract_num(currenttime, 12,2); /* extract hour */ //cur_day = extract_num(currenttime, 9, 2); /* extract day */ if(old_sec != cur_sec) { /* only update screen once per second */ ReadAnalogInputs(3); DisplayAnalogValues(3); ReadDigitalInputs(3); DisplayDigitalInputs(3); locate( 25, 56); color(CF_SETTINGS,CB_SETTINGS); cprintf(currenttime); /* update current time on screen */ //locate(20,1);cprintf("cur_min=%d",cur_min); old_sec = cur_sec; // EVENTS (new function) //OutputBit(0,valueInput[0]); //OutputBit(1,valueInput[1]); //OutputBit(2,valueInput[2]); //OutputBit(3,valueInput[3]); if (valueInput[1] == 1) { WritePort(1); DisplayPort(1,XOUTPUT,YOUTPUT); } if (valueAnalog[0] < 50) { WritePort(16); DisplayPort(16,XOUTPUT,YOUTPUT); } Log("e:\\user\\c\\a_pcio\\logfile.log", currenttime); } if( kbhit() ) { result = getkeypressed(); /* get a single keypress */ switch (result) { /* perform task user pressed */ case 27: { /* ESC */ Message( "Do you really want to quit? (Y/n) " , 0); key = getch(); if( ( key == 'Y') || (key =='y') || (key == 13) ) keepgoing = 0; /* stop program execution */ Message("", 0); } break; case 59: { /* F1 */ Message("Initialising",0); Message("Fast Pulse", 0); Pulse(255, gPulse_fast); } break; case 60: { /* F2 */ Message("Storage CRO - enter settings", 0); //getch(); gotoHiResMode(); DrawOscilliscopeScreen(50,0,550,255,50,51); StorageOscilliscope("waiting for trigger", 1, 0, 220, 40, 0, 499); InitDisplay(); } break; case 61: { /* F3 */ gotoHiResMode(); DrawOscilliscopeScreen(100,100,355,355,20,32); Oscilliscope(); InitDisplay(); Message("Oscilliscope", 0); Pulse(255, gPulse_slow); } break; case 62: { /* F4 */ Message("BinaryCount", 0); BinaryCount(gCounter); } break; case 63: { /* F5 */ Message("Chase Multiple", 0); ChaseMultiple(gIterations, gSpeed); } break; case 64: { /* F6 */ Message("Chase Up", 0); Chase(gSpeed, 0, 7); } break; case 65: { /* F7 */ Message("Chase Down", 0); Chase(gSpeed, 7,0); } break; case 66: { /* F8 */ Message("Reading Analog inputs", 0); ReadAnalogInputs(3); DisplayAnalogValues(3); ReadDigitalInputs(3); DisplayDigitalInputs(3); } break; case 67: { /* F9 */ Message("Logging - PRESS A KEY TO STOP", 0); FastAcquisition("e:\\user\\c\\a_pcio\\fastlog.log", currenttime); Message("Done Logging to e:\user\c\a_pcio\fastlog.log", 0); } break; case 68: { /* F10 */ Message("Setup", 0); //locate(12,65); scanf("%d", &gPORT); // port change locate(11, 62); color(CF_SETTINGS,CB_SETTINGS); // color(YELLOW,BLACK); cprintf("Enter new settings"); locate(13,75); scanf("%d", &gCounter); // port change if(gCounter<0||gCounter>999) gCounter=10; else fflush(stdin); locate(14,75); scanf("%d", &gSpeed); // port change if(gSpeed<0||gSpeed>999) gSpeed=10; else fflush(stdin); locate(15,75); scanf("%d", &gPulse_fast); // port change if(gPulse_fast<0||gPulse_fast>999) gPulse_fast=10; else fflush(stdin); locate(16,75); scanf("%d", &gPulse_slow); // port change if(gPulse_slow<0||gPulse_slow>999) gPulse_slow=10; else fflush(stdin); locate(17,75); scanf("%d", &gIterations); // port change if(gIterations<0||gIterations>999) gIterations=10; else fflush(stdin); DisplaySettings(XSETTINGS,YSETTINGS); } break; case 48: { OutputBit(0,2); DisplayPort(1,XOUTPUT,YOUTPUT); } break; case 49: { OutputBit(1,2); DisplayPort(2,XOUTPUT,YOUTPUT); } break; case 50: { OutputBit(2,2); DisplayPort(4,XOUTPUT,YOUTPUT); } break; case 51: { OutputBit(3,2); DisplayPort(16,XOUTPUT,YOUTPUT); } break; case 52: { OutputBit(4,2); DisplayPort(32,XOUTPUT,YOUTPUT); } break; case 53: { OutputBit(5,2); DisplayPort(64,XOUTPUT,YOUTPUT); } break; case 54: { OutputBit(6,2); DisplayPort(128,XOUTPUT,YOUTPUT); } break; case 55: { OutputBit(7,2); DisplayPort(255,XOUTPUT,YOUTPUT); } break; case 43: { WritePort(++valueOutput[0]); } break; case 45: { WritePort(--valueOutput[0]); } break; } } } return 0; }
void Heartbeat() { if (gbUnload) return; static ULONGLONG LastGetTick = 0; static bool bFirstHeartBeat = true; static ULONGLONG TickDiff = 0; static fMQPulse pEQPlayNicePulse = NULL; static DWORD BeatCount = 0; ULONGLONG Tick = MQGetTickCount64(); BeatCount++; if (bFirstHeartBeat) { LastGetTick = Tick; bFirstHeartBeat = false; } // This accounts for rollover TickDiff += (Tick - LastGetTick); LastGetTick = Tick; #ifndef ISXEQ while (TickDiff >= 100) { TickDiff -= 100; if (gDelay>0) gDelay--; DropTimers(); } #endif if (!gStringTableFixed && pStringTable) // Please dont remove the second condition { FixStringTable(); gStringTableFixed = TRUE; } DebugTry(int GameState = GetGameState()); if (GameState != -1) { if ((DWORD)GameState != gGameState) { DebugSpew("GetGameState()=%d vs %d", GameState, gGameState); gGameState = GameState; DebugTry(Benchmark(bmPluginsSetGameState, PluginsSetGameState(GameState))); } } else return; DebugTry(UpdateMQ2SpawnSort()); #ifndef ISXEQ_LEGACY #ifndef ISXEQ DebugTry(DrawHUD()); //if (gGameState==GAMESTATE_INGAME && !bMouseLook && ScreenMode==3) //{ // DebugTry(pWndMgr->DrawCursor()); //} #endif #endif bRunNextCommand = TRUE; DebugTry(Pulse()); #ifndef ISXEQ_LEGACY #ifndef ISXEQ DebugTry(Benchmark(bmPluginsPulse, DebugTry(PulsePlugins()))); #endif if (pEQPlayNicePulse) { pEQPlayNicePulse(); } else { HMODULE hmEQPlayNice; if (((BeatCount % 63) == 0) && (hmEQPlayNice = GetModuleHandle("EQPlayNice.dll"))) { if (pEQPlayNicePulse = (fMQPulse)GetProcAddress(hmEQPlayNice, "Compat_ProcessFrame")) pEQPlayNicePulse(); } } #endif DebugTry(ProcessPendingGroundItems()); static bool ShownNews = false; if (gGameState == GAMESTATE_CHARSELECT && !ShownNews) { ShownNews = true; if (gCreateMQ2NewsWindow) CreateMQ2NewsWindow(); } #ifndef ISXEQ DWORD CurTurbo = 0; if (gDelayedCommands) {// delayed commands lockit lk(ghLockDelayCommand); DoCommand((PSPAWNINFO)pLocalPlayer, gDelayedCommands->szText); PCHATBUF pNext = gDelayedCommands->pNext; LocalFree(gDelayedCommands); gDelayedCommands = pNext; } while (bRunNextCommand) { if (!DoNextCommand()) break; if (!gTurbo) break;//bRunNextCommand = FALSE; if (++CurTurbo>gMaxTurbo) break;//bRunNextCommand = FALSE; } DoTimedCommands(); #endif }
bool CBanManager::Load( const char * szFileName ) { bool bParse = true; // Create the xml ban file instance m_pBanFile = new CXML( szFileName ); // Get the root node m_pRootNode = m_pBanFile->GetRootNode(); // Is the root node invalid? if( !m_pRootNode ) { // Create the root node m_pRootNode = m_pBanFile->CreateRootNode( "bans" ); // Save the file m_pBanFile->Save(); // Mark as no need to parse bParse = false; } // Should we parse the file? if( bParse ) { // CXMLNode * pNode = NULL; unsigned int uiCount = m_pRootNode->GetChildCount(); // Is there no bans? if( uiCount == 0 ) return true; // Loop over all children for( unsigned int i = 0; i < uiCount; i++ ) { // Get the current node pNode = m_pRootNode->GetNode( i ); // Is the node invalid? if( !pNode ) continue; // Get the current node name const char * szName = pNode->GetName(); // Is this a ban? if( !strcmp( szName, "ban" ) ) { const char *szSerial = "", *szBanner = "", *szReason = ""; unsigned long ulBanTime, ulUnbanTime; // Get the ban data szSerial = pNode->GetValue(); szBanner = pNode->GetAttribute( "banner" ); ulBanTime = (unsigned long)atol( pNode->GetAttribute( "time" ) ); ulUnbanTime = (unsigned long)atol( pNode->GetAttribute( "unban" ) ); szReason = pNode->GetAttribute( "reason" ); // Add the ban to the manager Add( szSerial, szBanner, ulBanTime, ulUnbanTime, szReason, false ); // Increase the total loaded bans m_iTotalBansLoaded++; } } // Mark as bans loaded m_bBansLoaded = true; // Pulse the ban manager Pulse( true ); // Were any bans loaded? if( m_iTotalBansLoaded > 0 ) { // Subtract the total purged bans from the total loaded. m_iTotalBansLoaded -= m_iTotalUnbans; // Did we purge ALL bans? if( m_iTotalBansLoaded == 0 ) CLogFile::Printf( "Successfully purged %d bans.", m_iTotalUnbans ); else CLogFile::Printf( "Successfully loaded %d bans. (%d purged)", m_iTotalBansLoaded, m_iTotalUnbans ); // Reset the total unban count m_iTotalUnbans = 0; } return true; } return false; }
void Entity::Update(const Camera& camera, float dt) { if (mSpinning) {Yaw(dt*movementMult);} if (mUpDown) {GoUpDown(dt);} if (mFlipping) {Pitch(dt*movementMult);} if (mRolling) {Roll(dt*movementMult);} if (mSideToSide) {GoSideToSide(dt);} if (mBackAndForth) {GoBackAndForth(dt);} if (mOrbit) { Yaw(dt*movementMult); Walk(dt*movementMult*100); } XMVECTOR R = XMLoadFloat3(&mRight); XMVECTOR U = XMLoadFloat3(&mUp); XMVECTOR L = XMLoadFloat3(&mLook); XMVECTOR P = XMLoadFloat3(&mPosition); // Keep axes orthogonal to each other and of unit length. L = XMVector3Normalize(L); U = XMVector3Normalize(XMVector3Cross(L, R)); // U, L already ortho-normal, so no need to normalize cross product. R = XMVector3Cross(U, L); // Fill in the world matrix entries. // float x = XMVectorGetX(XMVector3Dot(P, R)); // float y = XMVectorGetX(XMVector3Dot(P, U)); // float z = XMVectorGetX(XMVector3Dot(P, L)); float x = XMVectorGetX(P); float y = XMVectorGetY(P); float z = XMVectorGetZ(P); XMStoreFloat3(&mRight, R); XMStoreFloat3(&mUp, U); XMStoreFloat3(&mLook, L); mWorld(0, 0) = mRight.x; mWorld(1, 0) = mRight.y; mWorld(2, 0) = mRight.z; mWorld(3, 0) = x; mWorld(0, 1) = mUp.x; mWorld(1, 1) = mUp.y; mWorld(2, 1) = mUp.z; mWorld(3, 1) = y; if (reverseLook){ mWorld(0, 2) = -mLook.x; mWorld(1, 2) = -mLook.y; mWorld(2, 2) = -mLook.z; mWorld(3, 2) = z;} else { mWorld(0, 2) = mLook.x; mWorld(1, 2) = mLook.y; mWorld(2, 2) = mLook.z; mWorld(3, 2) = z;} mWorld(0, 3) = 0.0f; mWorld(1, 3) = 0.0f; mWorld(2, 3) = 0.0f; mWorld(3, 3) = 1.0f; if (hovering) { XMMATRIX M = XMLoadFloat4x4(&mWorld); XMMATRIX scaling = XMMatrixScaling(1.3f, 1.3f, 1.3f); XMStoreFloat4x4(&mWorld, scaling * M); } //GROWING MOVEMENTS if (mPulse) { Pulse(dt); } if (mGrowIn){ GrowIn(dt); } if (mGrowOut){ GrowOut(dt); } if (mSquishX || mSquishY || mSquishZ){ Squish(dt); if (mSquishX){ ScaleX(currProgress); } if (mSquishY){ ScaleY(currProgress); } if (mSquishZ){ ScaleZ(currProgress); }} if (progressBar) { ScaleX(currProgress); } if (billboard) { XMMATRIX M = XMLoadFloat4x4(&mWorld); XMVECTOR L = XMVector3Normalize(XMVectorSubtract(camera.GetPositionXM(), GetPositionXM())); XMVECTOR Look = XMLoadFloat3(&mLook); XMVECTOR angle = XMVector3AngleBetweenNormals(L, Look); float theAngle = XMVectorGetY(angle); XMMATRIX rotY; camera.GetPosition().x < mPosition.x ? rotY = XMMatrixRotationY(-theAngle) : rotY = XMMatrixRotationY(theAngle); XMStoreFloat4x4(&mWorld, rotY * M); } if (goToPos) { if (mDistanceLeft <= 0){ goToPos = false; } } if (mUseAnimation){ mAnim->Update(dt);} //update sphere collider mSphereCollider.Center = mPosition; if (mUseAAB){ UpdateAAB(); } if (mUseAABOnce){ UpdateAAB(); mUseAABOnce = false; } }