bool ZipArchive::copyFileToNewZip(CentralDir *cdir, Stream *newZipStream) { // [tom, 1/24/2007] Using the stored compressor allows us to copy the raw // data regardless of compression method without having to re-compress it. Compressor *comp = Compressor::findCompressor(Stored); if(comp == NULL) return false; if(! mStream->setPosition(cdir->mLocalHeadOffset)) return false; // Copy file header // FIXME [tom, 1/24/2007] This will currently not copy the extra fields FileHeader fh; if(! fh.read(mStream)) return false; cdir->mLocalHeadOffset = newZipStream->getPosition(); if(! fh.write(newZipStream)) return false; // Copy file data Stream *readS = comp->createReadStream(cdir, mStream); if(readS == NULL) return false; bool ret = newZipStream->copyFrom(readS); // [tom, 1/24/2007] closeFile() just frees the relevant filters and // thus it is safe to call from here. closeFile(readS); return ret; }
int main(int argc, char **argv) { //::testing::InitGoogleTest(&argc, argv); //return RUN_ALL_TESTS(); if(argc != 3){ cout << "Uso: " << endl; cout << argv[0] << " -c archivoAComprimir"<< endl; cout << argv[0] << " -d archivoADescomprimir"<< endl; exit(1); } string path=argv[2]; if(!strcmp(argv[1],"-c")){ Compressor * comp = new Compressor(); comp->compress(path); //remove(path.c_str()); delete comp; } if(!strcmp(argv[1],"-d")){ Decompressor * decomp = new Decompressor(); decomp->decompress(path); delete decomp; } return 0; }
void ManageCompressor () { if (m_compressor->GetPressureSwitchValue()) { m_compressor->Stop(); } else { m_compressor->Start(); } }
bool Deck::importDana(QString fileName) { QFileInfo fi(fileName); QString baseName = fi.baseName().toLower(); QString tempFolder = utils::combinePaths(tempPath(), baseName); QString deckPath = utils::combinePaths(tempFolder, "deck.xml"); QString iconPath = utils::combinePaths(tempFolder, "icon.png"); utils::createDirectory(tempFolder); Compressor c; if(!c.decompressFolder(fileName, tempFolder)) { return false; } /// importFromXml(deckPath); utils::removeFile(deckPath); utils::copyDirectory(getDeckPath(), tempFolder); /// load icon pixmap loadPixmap( iconPath ); return true; }
void RobotDemo::toggleCompressor(){ if(compressor->Enabled()){ compressor->Stop(); } else{ compressor->Start(); } }
int main(int argc, char*argv[]) { if (argc < 2) { return 1; } bool unpack = strstr(argv[1], ".pack") != nullptr; FILE* fptr = fopen(argv[1], "rb"); if (!fptr) { printf("Could not open %s\n", argv[1]); return 1; } fseek(fptr, 0, SEEK_END); u32 size = ftell(fptr); fseek(fptr, 0, SEEK_SET); int os = 0; CompressionParameters params; memset(¶ms, 0, sizeof(params)); if (unpack) { fread(&os, 4, 1, fptr); fread(¶ms.contextCount, 1, 1, fptr); fread(params.weights, params.contextCount, 1, fptr); fread(params.contexts, params.contextCount, 1, fptr); size -= ftell(fptr); } u8* data = (u8*)malloc(size + 10); memset(data, 0, size + 10); data += 10; // Ugly, but we can ensure we have a few zero bytes at the beginning of the input. fread(data, 1, size, fptr); fclose(fptr); char ofn[256]; strcpy(ofn, argv[1]); if (unpack) { *strrchr(ofn, '.') = 0; strcat(ofn, ".unpack"); } else { strcat(ofn, ".pack"); } u8* out = (u8*)malloc(65536); memset(out, 0, 65536); out += 10; // Ugly, but we can ensure we have a few zero bytes at the beginning of the output. FILE* ofptr = fopen(ofn, "wb"); if (!ofptr) { printf("Could not open %s\n", argv[1]); return 1; } if (unpack) { Compressor* comp = new Compressor(); comp->Decompress(¶ms, &data[size - 4], out, os); fwrite(out, os, 1, ofptr); } else { Compressor* comp = new Compressor(); os = 65528; comp->Compress(¶ms, data, size, out, &os); Invert(out, os); fwrite(&size, 4, 1, ofptr); fwrite(¶ms.contextCount, 1, 1, ofptr); fwrite(params.weights, params.contextCount, 1, ofptr); fwrite(params.contexts, params.contextCount, 1, ofptr); fwrite(out, os, 1, ofptr); } fclose(ofptr); return 0; }
char *Math::decompress(Compressor::Format format, const char *cbytes, size_t compressedsize, size_t &rawsize) { Compressor *compressor = Compressor::getCompressor(format); if (compressor == nullptr) throw love::Exception("Invalid compression format."); return compressor->decompress(format, cbytes, compressedsize, rawsize); }
//------------------------------------------------------------------------------ void Compressor::decompress(std::istream &source, std::ostream &sink) { Compressor cmp; cmp.istream_ = &source; cmp.startDecompression(); copy(*cmp.uncompressedIstream_, sink); }
void toggleCompressor(bool start, bool stop) { if(start) { comp599->Start(); } else if(stop) { comp599->Stop(); } }
//! Compresses data to a DXT format using nVidia's Texture Tools library. // The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1. // DxtSize is used to return the size in bytes of the DXTC data returned. ILAPI ILubyte* ILAPIENTRY ilNVidiaCompressDXT(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DxtFormat, ILuint *DxtSize) { if (Data == NULL) { // We cannot operate on a null pointer. ilSetError(IL_INVALID_PARAM); return NULL; } // The nVidia Texture Tools library does not support volume textures yet. if (Depth != 1) { ilSetError(IL_INVALID_PARAM); return NULL; } InputOptions inputOptions; inputOptions.setTextureLayout(TextureType_2D, Width, Height); inputOptions.setMipmapData(Data, Width, Height); inputOptions.setMipmapGeneration(false, -1); //@TODO: Use this in certain cases. OutputOptions outputOptions; ilOutputHandlerMem outputHandler(Width, Height, DxtFormat); outputOptions.setOutputHeader(false); outputOptions.setOutputHandler(&outputHandler); if (outputHandler.NewData == NULL) return NULL; CompressionOptions compressionOptions; switch (DxtFormat) { case IL_DXT1: compressionOptions.setFormat(Format_DXT1); break; case IL_DXT1A: compressionOptions.setFormat(Format_DXT1a); break; case IL_DXT3: compressionOptions.setFormat(Format_DXT1); break; case IL_DXT5: compressionOptions.setFormat(Format_DXT5); break; default: // Does not support DXT2 or DXT4. ilSetError(IL_INVALID_PARAM); break; } Compressor compressor; compressor.process(inputOptions, compressionOptions, outputOptions); *DxtSize = outputHandler.Size; return outputHandler.NewData; }
// CompressSimpleHelper //------------------------------------------------------------------------------ void TestCompressor::CompressSimpleHelper( const char * data, size_t size, size_t expectedCompressedSize, bool shouldCompress ) const { // raw input strings may not be aligned on Linux/OSX, so copy // them to achieve our required alignment char * alignedData = FNEW( char[ size ] ); memcpy( alignedData, data, size ); data = alignedData; // compress Compressor c; const bool compressed = c.Compress( data, size ); TEST_ASSERT( compressed == shouldCompress ); const size_t compressedSize = c.GetResultSize(); if ( expectedCompressedSize > 0 ) { TEST_ASSERT( compressedSize == expectedCompressedSize ); } void const * compressedMem = c.GetResult(); // decompress Compressor d; d.Decompress( compressedMem ); const size_t decompressedSize = d.GetResultSize(); TEST_ASSERT( decompressedSize == size ); TEST_ASSERT( memcmp( data, d.GetResult(), size ) == 0 ); FDELETE_ARRAY( alignedData ); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); if (argc < 2) { qDebug("insufficient arguments..."); usage(); exit (0); } QString option = argv[1]; Compressor *c = new Compressor (); if (option == "--help" || option == "/?") { usage(); exit(0); } else if (argc < 4) { qDebug() << "insufficient arguments..."; usage(); exit(0); } if (option == "-c") { c->compress(argv[2], argv[3]); } else if (option == "-d") { c->decompress(argv[2], argv[3]); } else { qDebug("unknown option!"); usage(); exit (0); } delete c; qDebug("Done!"); exit (1); return a.exec(); }
int main() { Compressor c; //cout << "compressing" << endl; // c.compress("/auto_home/nlephilippe/Téléchargements/test1.txt", "/auto_home/nlephilippe/Téléchargements/compc"); c.compress("/home/noe/Téléchargements/test1.txt", "/home/noe/Téléchargements/compc"); // cout << endl; Decompressor d; //cout << "decompressing" << endl; //d.decompress("/auto_home/nlephilippe/Téléchargements/compc", "/auto_home/nlephilippe/Téléchargements/outc.bin"); d.decompress("/home/noe/Téléchargements/compc", "/home/noe/Téléchargements/outc.txt"); cout << endl; return 0; }
void teleDrive() { drive->setLinVelocity(-oi->getDriveJoystick()->GetY(Joystick::kRightHand)); drive->setTurnSpeed(oi->getDriveJoystick()->GetX(Joystick::kRightHand), oi->getDriveJoystickButton(1)); drive->drive(); drive->shift(oi->getDriveJoystickButton(8), oi->getDriveJoystickButton(9)); if(oi->getDriveJoystickButton(6)) { comp599->Start(); } else if(oi->getDriveJoystickButton(7)) { comp599->Stop(); } }
void OperatorControl(void) { OperatorControlInit(); compressor.Start(); testActuator.Start(); while (IsOperatorControl()) { ProgramIsAlive(); //No need to do waits because ProgramIsAlive function does a wait. //Wait(0.005); bool isButtonPressed = stick.GetRawButton(3); SmartDashboard::PutNumber("Actuator Button Status",isButtonPressed); if (isButtonPressed) { testActuator.Go(); } float leftYaxis = stick.GetY(); float rightYaxis = stick.GetRawAxis(5); //RawAxis(5); TankDrive(leftYaxis,rightYaxis); // drive with arcade style (use right stick)for joystick 1 SmartDashboard::PutNumber("Left Axis",leftYaxis); SmartDashboard::PutNumber("Right Axis",rightYaxis); } }
Robot() : stick(0), //the joystick is in the first USB port compressor(0), piston(0) { compressor.SetClosedLoopControl(true); }
RobotSystem(void): robotInted(false) ,stick(1) // as they are declared above. ,stick2(2) ,line1(10) ,line2(11) ,line3(12) //,camera(AxisCamera::GetInstance()) ,updateCAN("CANUpdate",(FUNCPTR)UpdateCAN) ,cameraTask("CAMERA", (FUNCPTR)CameraTask) ,compressor(14,1) ,EncArm(2,3) ,EncClaw(5,6) ,PIDArm(.04,0,0) // .002, .033 ,PIDClaw(.014,.0000014,0) ,LowArm(.1) /* ,MiniBot1(4) ,MiniBot2(2) ,ClawGrip(3) */ ,MiniBot1a(8,1) ,MiniBot1b(8,2) ,MiniBot2a(8,3) ,MiniBot2b(8,4) ,ClawOpen(8, 8) ,ClawClose(8,7) ,LimitClaw(7) ,LimitArm(13) { // myRobot.SetExpiration(0.1); GetWatchdog().SetEnabled(false); GetWatchdog().SetExpiration(1); compressor.Start(); debug("Waiting to init CAN"); Wait(2); Dlf = new CANJaguar(6,CANJaguar::kSpeed); Dlb = new CANJaguar(3,CANJaguar::kSpeed); Drf = new CANJaguar(7,CANJaguar::kSpeed); Drb = new CANJaguar(2,CANJaguar::kSpeed); arm1 = new CANJaguar(5); arm1_sec = new CANJaguar(8); arm2 = new CANJaguar(4); EncArm.SetDistancePerPulse(.00025); EncClaw.SetDistancePerPulse(.00025); EncClaw.SetReverseDirection(false); EncArm.SetReverseDirection(true); EncArm.Reset(); EncClaw.Reset(); updateCAN.Start((int)this); //cameraTask.Start((int)this); EncArm.Start(); EncClaw.Start(); debug("done initing"); }
void TeleopPeriodic(void ) { /* * Code placed in here will be called only when a new packet of information * has been received by the Driver Station. Any code which needs new information * from the DS should go in here */ //Start compressor compressor->Start(); driveTrainValues(); deadzone(); //Drivetrain..... //When button eight is pressed robot drives at 25% speed printf("right: %f and left: %f\n", useright, useleft); if (gamepad->GetRawButton(8)) { drivetrain->TankDrive((-0.5*(useleft)), (-0.5*(useright))); //Negative for switched wires } else { drivetrain->SetLeftRightMotorOutputs(-useleft, -useright); //Normal driving //Negative for switched wires } }
void AutonomousPeriodic(void) { //Start compressor compressor->Start(); //Autonomous code goes here }
void OperatorControl() { compressor.Start(); while (IsOperatorControl()) { if(stick.GetRawButton(6)) //press the upper right trigger { piston.Set(true); } else if(stick.GetRawButton(8)) //press the lower right trigger { piston.Set(false); } } compressor.Stop(); }
/** * Runs the motors with arcade steering. */ void OperatorControl(void) { GetWatchdog().SetEnabled(true); compressor->Start(); GetWatchdog().SetExpiration(0.5); bool valve_state = false; while (IsOperatorControl()) { motor->Set(stick->GetY()); if (stick->GetRawButton(1) && !valve_state) { valve->Set(true); valve_state = true; } if (!stick->GetRawButton(1) && valve_state) { valve->Set(false); valve_state = false; } // Update driver station //dds->sendIOPortData(valve); GetWatchdog().Feed(); } }
void Run(CompressorInputs input) { //cout << input.enable; //compressor->Set(Relay::kOn); //compressor->Set(input.enable ? Relay::kOn : Relay::kOff); //cout << compressor->GetPressureSwitchValue(); lcd->PrintfLine(DriverStationLCD::kUser_Line5, "Pressure Switch: %x", compressor->GetPressureSwitchValue()); }
/** * Initialization code for test mode should go here. * * Use this method for initialization code which will be called each time * the robot enters test mode. */ void RA14Robot::TestInit() { myCam->Disable(); myCompressor->Start(); Config::LoadFromFile("config.txt"); Config::Dump(); myCamera->Set(Relay::kForward); // turn on light }
virtual void RobotInit() { CommandBase::init(); SmartDashboard::init(); autonomousCommand = new AutonomousCommandGroup(); compressor = new Compressor(COMPRESSOR_SWITCH, COMPRESSOR_RELAY); compressor->Start(); }
virtual void RobotInit() { CommandBase::init(); mainCompressor = new Compressor(COMPRESSOR_PRESSURE_SWITCH, COMPRESSOR_RELAY);// COMPRESSOR_RELAY); autonomousCommand = new cmdAutonomousScheduler(); //DEFINE COMMANDS HERE mainCompressor->Start(); CommandBase::loaderSubsystem->LowerLoader(); CommandBase::winchSubsystem->Retract(); }
void TeleopPeriodic() { comp599->Start(); while(IsOperatorControl()) { teleDrive(); } }
void RobotInit(void) { /* Once the start function is called no further programming * is required. However if needed the Stop() function can be * called. * */ airCompressor->Start(); }
//! Compresses data to a DXT format using nVidia's Texture Tools library. // This version is supposed to be completely internal to DevIL. // The data must be in unsigned byte RGBA format. The alpha channel will be ignored if DxtType is IL_DXT1. ILuint ilNVidiaCompressDXTFile(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DxtFormat) { ILuint FilePos = itellw(); // The nVidia Texture Tools library does not support volume textures yet. if (Depth != 1) { ilSetError(IL_INVALID_PARAM); return 0; } InputOptions inputOptions; inputOptions.setTextureLayout(TextureType_2D, Width, Height); inputOptions.setMipmapData(Data, Width, Height); inputOptions.setMipmapGeneration(false, -1); //@TODO: Use this in certain cases. OutputOptions outputOptions; ilOutputHandlerFile outputHandler(Width, Height, DxtFormat); outputOptions.setOutputHeader(false); outputOptions.setOutputHandler(&outputHandler); CompressionOptions compressionOptions; switch (DxtFormat) { case IL_DXT1: compressionOptions.setFormat(Format_DXT1); break; case IL_DXT1A: compressionOptions.setFormat(Format_DXT1a); break; case IL_DXT3: compressionOptions.setFormat(Format_DXT1); break; case IL_DXT5: compressionOptions.setFormat(Format_DXT5); break; default: // Does not support DXT2 or DXT4. ilSetError(IL_INVALID_PARAM); break; } Compressor compressor; compressor.process(inputOptions, compressionOptions, outputOptions); return itellw() - FilePos; // Return the number of characters written. }
/******************************** CONTINUOUS ROUTINES ********************************/ void DisabledContinuous(void) { printf("Running in disabled continuous...\n"); GetWatchdog().Feed(); //Stop the presses... drivetrain->Drive(0.0, 0.0); compressor->Stop(); }
void TeleopInit() { step = 0; drive->setLinVelocity(0); drive->setTurnSpeed(0, false); drive->drive(); comp599->Start(); timer->Start(); }