void BaseInFileStream::ReadyForSend() { if (!Feed()) { FATAL("Feed failed"); if (_pOutStreams != NULL) _pOutStreams->info->EnqueueForDelete(); } }
MAUIMoblet::MAUIMoblet() { lprintfln("MAUIMoblet::Memory Heap %d, Free Heap %d", heapTotalMemory(), heapFreeMemory()); Engine& engine = Engine::getSingleton(); engine.setDefaultFont(Util::getFontBlack()); engine.setDefaultSkin(Util::getSkinBack()); MAExtent screenSize = maGetScrSize(); scrWidth = EXTENT_X(screenSize); scrHeight = EXTENT_Y(screenSize); feed = Feed(); String data = ""; Util::getData("fd.sav", data); if (data.length() <= 0) { data = ""; } feed.setAll(data.c_str()); Util::getData("lb.sav", data); if (data.length() <= 0) { data = ""; } feed.setAlbum(data.c_str()); data = ""; if (feed.getLoaded()) { next = new AlbumLoadScreen(&feed); next->show(); } else { next = new OptionsScreen(&feed, OptionsScreen::ST_LOGIN_OPTIONS); next->show(); } }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::FeedControls() { FLastFeededControl = NULL; Feed(ControlsAddItem); AdjustListColumnsWidth(ServerView); AdjustListColumnsWidth(ProtocolView); AdjustListColumnsWidth(SpaceAvailableView); }
//--------------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::ClipboardButtonClick( TObject * /*Sender*/) { TInstantOperationVisualizer Visualizer; NeedSpaceAvailable(); FLastFeededControl = NULL; FClipboard = L""; Feed(ClipboardAddItem); CopyToClipboard(FClipboard); }
void CacheHash::Update(const char *aData, uint32_t aLen) { const uint8_t *data = reinterpret_cast<const uint8_t*>(aData); MOZ_ASSERT(!mFinalized); if (mBufPos) { while (mBufPos != 4 && aLen) { mBuf += uint32_t(*data) << 8*mBufPos; data++; mBufPos++; aLen--; } if (mBufPos == 4) { mBufPos = 0; Feed(mBuf); mBuf = 0; } } if (!aLen) return; while (aLen >= 4) { Feed(data[0] + (uint32_t(data[1]) << 8) + (uint32_t(data[2]) << 16) + (uint32_t(data[3]) << 24)); data += 4; aLen -= 4; } switch (aLen) { case 3: mBuf += data[2] << 16; case 2: mBuf += data[1] << 8; case 1: mBuf += data[0]; } mBufPos = aLen; }
CacheHash::Hash32_t CacheHash::GetHash() { if (!mFinalized) { if (mBufPos) { Feed(mBuf, mBufPos); } mC += mLength; hashmix(mA, mB, mC); mFinalized = true; } return mC; }
void InitWatchdog() { struct stat buf; if(stat(DogPath, &buf) != 0) { if(Exec::System("modprobe softdog") != 0) return; } do { sched_yield(); Dog = open(DogPath, O_RDWR); } while(Dog == -1); SetTimeout(Timeout); Feed(); }
bool BaseInFileStream::Feed() { //1. Are we in paused state? if (_paused) return true; //2. First, send audio and video codecs if (!_audioVideoCodecsSent) { if (!SendCodecs()) { FATAL("Unable to send audio codec"); return false; } } //2. Determine if the client has enough data on the buffer and continue //or stay put uint32_t elapsedTime = (uint32_t) (time(NULL) - _startFeedingTime); if ((int32_t) _totalSentTime - (int32_t) elapsedTime >= _clientSideBufferLength) { return true; } //3. Test to see if we have sent the last frame if (_currentFrameIndex >= _totalFrames) { FINEST("Done streaming file"); _pOutStreams->info->SignalStreamCompleted(); _paused = true; return true; } //FINEST("_totalSentTime: %.2f; _playLimit: %.2f", (double) _totalSentTime, _playLimit); if (_playLimit >= 0) { if (_playLimit < (double) _totalSentTime) { FINEST("Done streaming file"); _pOutStreams->info->SignalStreamCompleted(); _paused = true; return true; } } //4. Read the current frame from the seeking file if (!_pSeekFile->SeekTo(_framesBaseOffset + _currentFrameIndex * sizeof (MediaFrame))) { FATAL("Unablt to seek inside seek file"); return false; } if (!_pSeekFile->ReadBuffer((uint8_t *) & _currentFrame, sizeof (_currentFrame))) { FATAL("Unable to read frame from seeking file"); return false; } //5. Take care of metadata if (_currentFrame.type == MEDIAFRAME_TYPE_DATA) { _currentFrameIndex++; if (!FeedMetaData(_pFile, _currentFrame)) { FATAL("Unable to feed metadata"); return false; } return Feed(); } //6. get our hands on the correct buffer, depending on the frame type: audio or video IOBuffer &buffer = _currentFrame.type == MEDIAFRAME_TYPE_AUDIO ? _audioBuffer : _videoBuffer; //7. Build the frame if (!BuildFrame(_pFile, _currentFrame, buffer)) { FATAL("Unable to build the frame"); return false; } //8. Compute the timestamp _totalSentTime = (uint32_t) (_currentFrame.absoluteTime / 1000) - _totalSentTimeBase; //9. Do the feedeng if (!_pOutStreams->info->FeedData( GETIBPOINTER(buffer), //pData GETAVAILABLEBYTESCOUNT(buffer), //dataLength 0, //processedLength GETAVAILABLEBYTESCOUNT(buffer), //totalLength (uint32_t) _currentFrame.absoluteTime, //absoluteTimestamp _currentFrame.type == MEDIAFRAME_TYPE_AUDIO //isAudio )) { FATAL("Unable to feed audio data"); return false; } //10. Discard the data buffer.IgnoreAll(); //11. Increment the frame index _currentFrameIndex++; //12. Done. We either feed again if frame length was 0 //or just return true if (_currentFrame.length == 0) { return Feed(); } else { return true; } }
task autonomous()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// { int programmingSkills=0; int match=0; int red=0; int blue=0; int cube=0; int skyrise=0; SensorValue[leftLifttEncoder] = 0; SensorValue[rightLiftEncoder] = 0; if(SensorValue[autoPot2] > 1000) // competition or match { programmingSkills=1; } else match=1; if(SensorValue[autoPot] < 2500) //red or blue { red=1; } else blue=1; if(SensorValue[autoPot3] > 2000) // skyrise or cubes { skyrise=1; } else cube=1; // DriveLoop(-1, 800, 0.11, 0.000000, 0.001); // DriveLoop( 1, 800, 0.11, 0.000000, 0.001); if(match==1 && skyrise==1 && red==1)//------------------RED SKYRISE------- { SensorValue[latch] = 1; armDown(0, 90); wait1Msec(300); armUp(130, 90); autoFeed(300, -127); autoFeed(1,0); wait1Msec(500); armDown(105, 90); autoGrab(1); armUp(300, 90); liftMotors(-18); DriveLoop(-1,-1, 890, 0.15, 0.00000001, 0.1, 120, 30); armDown(0, 90); autoGrab(0); //drop one armUp(160, 90); liftMotors(-10); DriveLoop(1,1, 890, 0.15, 0.00000001, 0.1, 120, 30); armDown(105, 90); autoGrab(1); armUp(200, 90); DriveLoop(-1,-1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(220, 90); autoGrab(0); //drop two armUp(290, 90); liftMotors(-15); DriveLoop(1,1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(105, 90); autoGrab(1); armUp(390, 90); DriveLoop(-1,-1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(320, 90); autoGrab(0); //drop three armUp(400, 90); Feed(-40); driveForward(127, -60, 160); Feed(-127); wait1Msec(1000); Feed(0); wait1Msec(5000000); } if(match==1 && skyrise==1 && blue==1)//---BLUE SKYRISE----- { SensorValue[latch] = 1; wait1Msec(300); armUp(160, 90); autoFeed(300, -127); autoFeed(1,0); wait1Msec(500); armDown(80, 90); autoGrab(1); armUp(185, 90); liftMotors(-20); DriveLoop(-1,-1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(0, 90); autoGrab(0); //drop one armUp(180, 90); liftMotors(-10); DriveLoop(1,1, 890, 0.15, 0.00000001, 0.1, 120, 30); armDown(80, 90); autoGrab(1); armUp(220, 90); DriveLoop(-1,-1, 925, 0.15, 0.00000001, 0.1, 120, 30); armDown(180, 90); autoGrab(0); //drop two armUp(250, 90); liftMotors(-15); DriveLoop(1,1, 925, 0.15, 0.00000001, 0.1, 120, 30); armDown(80, 90); autoGrab(1); armUp(340, 90); DriveLoop(-1,-1, 920, 0.15, 0.00000001, 0.1, 120, 30); armDown(320, 90); autoGrab(0); //drop three armUp(400, 90); driveForward(-60, 120, 100); Feed(-127); driveForward(-60, 120, 170); wait1Msec(5000); Feed(0); wait1Msec(5000000); } if(programmingSkills==1) //--------------------------------SKILLS------------- { SensorValue[latch] = 1; armDown(0, 90); wait1Msec(300); armUp(130, 90); autoFeed(300, -127); autoFeed(1,0); wait1Msec(500); armDown(90, 90); autoGrab(1); armUp(300, 90); liftMotors(-15); DriveLoop(-1,-1, 890, 0.15, 0.00000001, 0.1, 120, 30); armDown(0, 90); autoGrab(0); //drop one armUp(160, 90); liftMotors(-10); DriveLoop(1,1, 890, 0.15, 0.00000001, 0.1, 120, 30); armDown(90, 90); autoGrab(1); armUp(200, 90); DriveLoop(-1,-1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(220, 90); autoGrab(0); //drop two armUp(290, 90); liftMotors(-10); DriveLoop(1,1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(90, 90); autoGrab(1); armUp(380, 90); DriveLoop(-1,-1, 900, 0.15, 0.00000001, 0.1, 120, 30); armDown(320, 90); autoGrab(0); //drop three armUp(370, 90); liftMotors(-15); DriveLoop(1,1, 905, 0.12, 0.00000001, 0.1, 80, 30); armDown(90, 90); autoGrab(1); armUp(560, 90); DriveLoop(-1,-1, 915, 0.12, 0.00000001, 0.1, 80, 30); armDown(530, 90); autoGrab(0); //drop four armUp(610, 90); liftMotors(-15); DriveLoop(1,1, 915, 0.12, 0.00000001, 0.1, 80, 30); armDown(90, 90); autoGrab(1); armUp(750, 90); DriveLoop(-1,-1, 925, 0.12, 0.00000001, 0.1, 80, 30); armDown(700, 90); autoGrab(0); //drop five armUp(750, 90); liftMotors(-15); DriveLoop(1,1, 950, 0.12, 0.00000001, 0.1, 80, 30); armDown(90, 90); autoGrab(1); armUp(950, 90); DriveLoop(-1,-1, 950, 0.11, 0.00000001, 0.1, 80, 30); armDown(900, 90); autoGrab(0); //drop six armUp(950, 90); liftMotors(-15); DriveLoop(1,1, 950, 0.11, 0.00000001, 0.1, 80, 30); armDown(90, 90); autoGrab(1); armUp(1220, 90); DriveLoop(-1,-1, 900, 0.12, 0.00000001, 0.1, 80, 30); armDown(1110, 90); autoGrab(0); //drop seven armUp(1220, 90); /*liftMotors(100); wait1Msec(500); liftMotors(15);*/ driveForward(70, -70, 225); driveForward(70, 70, 100); autoFeed(750, -127); SensorValue[conveyer] = 1; driveForward(70, -70, 825); armDown(20, 127); liftMotors(-100); wait1Msec(500); liftMotors(-15); driveForward(70, 70, 100); autoFeed(1000, 127); driveForward(70, -70, 225); driveForward(70, 70, 100); autoFeed(1000, 127); driveForward(70, -70, 1000); armUp(1220, 127); driveForward(70, 70, 225); autoFeed(750, -127); wait1Msec(500); driveForward(70, 70, 50); autoFeed(750, -127); driveForward(-70, -70, 200); /*DriveLoop(1,-1, 250, 0.17, 0.00000001, 0.05, 120, 43); DriveLoop(1,1, 140, 0.14, 0.00000001, 0.05, 80, 35); autoFeed(1500, -127); DriveLoop(-1,-1, 140, 0.14, 0.00000001, 0.05, 80, 35); liftMotors(-50); DriveLoop(-1,1, 350, 0.17, 0.00000001, 0.05, 120, 43); liftMotors(-15); DriveLoop(1,1, 825, 0.12, 0.00000001, 0.05, 80, 35); DriveLoop(-1,1, 410, 0.12, 0.00000001, 0.05, 120, 43); liftMotors(-127); wait1Msec(1250); liftMotors(-15); DriveLoop(1,1, 175, 0.12, 0.00000001, 0.05, 80, 35); autoFeed(750, 127); wait1Msec(5000000);*/ } if(match==1 && cube==1 && red==1) //-----------RED CUBES Match { DriveLoop(-1,1, 400, 0.12, 0.00000001, 0.05, 120, 50); DriveLoop( 1,-1, 400, 0.12, 0.00000001, 0.05, 120, 50); wait1Msec(50000000000); /*SensorValue[latch] = 1; driveStop(300); armUp(1550, 90); liftMotors(-10); autoFeed(600, -127); autoFeed(1,0); wait1Msec(50); armDown(1200, 120); liftMotors(-127); wait1Msec(250); liftMotors(-15); driveForward(100, 100, 425); autoFeed(900, 127); //feed in red1 stopRobot(10); liftMotors(60); driveForward(100, 100, 350); armUp(2300, 90); driveForward(90, -60, 250); autoFeed(800, -127); //feed out red1 autoFeed(1,0); driveForward(-90, 60, 420); armDown(1200, 110); driveForward(100, 100, 100); wait1Msec(50); driveForward(70, -70, 125); liftMotors(-127); wait1Msec(450); liftMotors(-15); driveForward(100, 100, 650); autoFeed(700, 127); //pick up blue autoFeed(1, 0); driveForward(-70, 70, 15); autoFeed(375, 127); //move blue autoFeed(1, 0); driveForward(100, 100, 530); autoFeed(600, 127); //pick up red2 driveForward(-70, 70, 10); autoFeed(1, 0); armUp(1800, 90); driveForward(90, -60, 250); wait1Msec(75); autoFeed(550, -127); //drop red2 autoFeed(1,0); driveBack(-90, -90, -100); driveForward(-70, 70, 420); armDown(1390, 90); liftMotors(-10); driveForward(90, 90, 400);*/ } if(match==1 && cube==1 && blue==1) //-----------BLUE CUBES------------- { SensorValue[latch] = 1; wait1Msec(300); armUp(1550, 90); liftMotors(-10); autoFeed(600, -127); autoFeed(1,0); wait1Msec(50); armDown(1425, 120); liftMotors(-127); wait1Msec(100); liftMotors(-15); SensorValue[conveyer] = 1; driveForward(100, 100, 425); autoFeed(925, 127); //feed in blue1 stopRobot(10); liftMotors(40); driveForward(100, 100, 415); armUp(2300, 90); driveForward(-90, 60, 265); // driveForward(90, 90, 20); autoFeed(800, -127); //feed out blue1 autoFeed(1,0); // driveBack(-90, -90, -20); driveForward(90, -60, 430); liftMotors(-40); driveForward(100, 100, 200); driveForward(-70, 70, 90); armDown(1425, 120); liftMotors(-127); wait1Msec(150); liftMotors(-15); driveForward(100, 100, 470); autoFeed(850, 127); //pick up red autoFeed(1, 0); // driveForward(-70, 70, 15); autoFeed(250, 127); //move red autoFeed(1, 0); driveForward(100, 100, 590); autoFeed(650, 127); //pick up blue2 // driveForward(-70, 70, 10); autoFeed(1, 0); armUp(1800, 90); driveForward(-90, 60, 290); driveForward(90, 90, 40); autoFeed(550, -127); //drop blue2 autoFeed(1,0); driveBack(-90, -90, -100); driveForward(-70, 70, 420); armDown(1390, 90); liftMotors(-10); driveForward(90, 90, 400); SensorValue[latch] = 1; wait1Msec(300); armUp(1550, 90); liftMotors(-10); autoFeed(600, -127); autoFeed(1,0); wait1Msec(50); armDown(1200, 120); liftMotors(-127); wait1Msec(250); liftMotors(-15); driveForward(100, 100, 425); autoFeed(900, 127); //feed in red1 stopRobot(10); liftMotors(60); driveForward(100, 100, 350); armUp(2300, 90); driveForward(-90, 60, 250); autoFeed(800, -127); //feed out red1 autoFeed(1,0); driveForward(90, -60, 420); armDown(1450, 110); driveForward(100, 100, 100); wait1Msec(50); driveForward(-70, 70, 85); armDown(1200, 110); liftMotors(-127); wait1Msec(450); liftMotors(-15); driveForward(100, 100, 650); autoFeed(700, 127); //pick up blue autoFeed(1, 0); // driveForward(-70, 70, 15); autoFeed(375, 127); //move blue autoFeed(1, 0); driveForward(100, 100, 530); autoFeed(600, 127); //pick up red2 // driveForward(-70, 70, 10); autoFeed(1, 0); armUp(1800, 90); driveForward(-90, 60, 260); wait1Msec(75); autoFeed(550, -127); //drop red2 autoFeed(1,0); driveBack(-90, -90, -100); driveForward(-70, 70, 420); armDown(1390, 90); liftMotors(-10); driveForward(90, 90, 400); } }
void autoFeed(int mTime, int speed) { Feed(speed); wait1Msec(mTime); Feed(0); }
int wmain(int argc, wchar_t* argv[]) { if(argc != 4) { const auto NamePtr = wcsrchr(argv[0], L'\\'); std::wcout << L"Usage:\n" << (NamePtr? NamePtr+1 : argv[0]) << L" input_template_file output_template_file new_lng_file" << std::endl; return -1; } const std::wstring InFeedName = argv[1], OutFeedName = argv[2], LngName = argv[3]; std::wifstream Feed(InFeedName), Lng(LngName); std::wcout << L"Reading " << LngName << std::endl; std::wstring LngHeader; std::getline(Lng, LngHeader); std::list<std::wstring> LngLines; std::wstring Buffer; while(!Lng.eof()) { std::getline(Lng, Buffer); if(!Buffer.compare(0, 1, L"\"")) { LngLines.push_back(Buffer); } } std::wcout << L"Reading " << InFeedName << std::endl; std::list<std::wstring> FeedLines; while(!Feed.eof()) { getline(Feed, Buffer); FeedLines.push_back(Buffer); } size_t ConstsCount = 0; for(auto i = FeedLines.begin(); i != FeedLines.end(); ++i) { // assume that all constants starts with 'M'. if(!i->compare(0, 1, L"M")) { ++ConstsCount; } } if(ConstsCount != LngLines.size()) { std::wcerr << L"Error: lines count mismatch: " << InFeedName << " - " << ConstsCount << L", " << LngName << L" - " << LngLines.size() << std::endl; return -1; } if(FeedLines.back().empty()) { FeedLines.pop_back(); } auto Ptr = FeedLines.begin(); if(!Ptr->compare(0, 14, L"\xef\xbb\xbfm4_include(")) { ++Ptr; } #define SKIP_EMPTY_LINES_AND_COMMENTS while(Ptr->empty() || !Ptr->compare(0, 1, L"#")) {++Ptr;} SKIP_EMPTY_LINES_AND_COMMENTS // skip header name ++Ptr; SKIP_EMPTY_LINES_AND_COMMENTS std::wstringstream strStream(*Ptr); size_t Num; strStream >> Num; std::wcout << Num << L" languages found." << std::endl; auto NumPtr = Ptr; ++Ptr; bool Update = false; size_t UpdateIndex = Num; for(size_t i = 0; i < Num; ++i, ++Ptr) { SKIP_EMPTY_LINES_AND_COMMENTS if(!Ptr->compare(0, LngName.length(), LngName)) { Update = true; UpdateIndex = i; break; } } if(Update) { std::wcout << LngName << " already exist (id == " << UpdateIndex << L"). Updating." << std::endl; } else { std::wcout << L"Inserting new language (id == " << UpdateIndex << L") from " << LngName << std::endl; strStream.clear(); strStream << Num+1; *NumPtr = strStream.str(); std::wstring ShortLngName = LngHeader.substr(LngHeader.find(L'=', 0)+1); ShortLngName.resize(ShortLngName.find(L','), 0); std::wstring FullLngName = LngHeader.substr(LngHeader.find(L',', 0)+1); FeedLines.insert(Ptr, LngName+L" " + ShortLngName + L" \"" + FullLngName + L"\""); } for(auto i = LngLines.begin(); i != LngLines.end(); ++i) { // assume that all constants start with 'M'. while(Ptr->compare(0, 1, L"M")) { ++Ptr; } ++Ptr; for(size_t j = 0; j < UpdateIndex || !UpdateIndex; ++j) { while(Ptr != FeedLines.end() && Ptr->compare(0, 1, L"\"") && Ptr->compare(0, 5, L"upd:\"")) { ++Ptr; } if(!UpdateIndex) { break; } ++Ptr; } if(Update) { const wchar_t* Str = Ptr->c_str(); size_t l = Ptr->length(); if(!Ptr->compare(0, 4, L"upd:")) { Str += 4; l -= 4; } if(i->compare(0, l, Str)) { *Ptr = *i; } } else { FeedLines.insert(Ptr, *i); } } std::wcout << L"Writing to " << OutFeedName << std::endl; std::wofstream oFeed(OutFeedName); for(auto i = FeedLines.begin(); i != FeedLines.end(); ++i) { oFeed << *i << L'\n'; } std::wcout << L"Done." << std::endl; return 0; }