tarou yamada / ShootingSystem

Dependencies:   AmmoPusher AmmoSupplier Shooter

Dependents:   OBROT_ALL

Committer:
inst
Date:
Fri Aug 21 04:52:50 2015 +0000
Revision:
0:987c53b6a212
y evol

Who changed what in which revision?

UserRevisionLine numberNew contents of line
inst 0:987c53b6a212 1 MD
inst 0:987c53b6a212 2 (I2CServo)ShooterAngleManager : 発射角度変更機構 : ポテメ : I2CServo
inst 0:987c53b6a212 3 (I2CServo)ShooterPositionManager : 発射機構上下機構 : ポテメ : I2CServo
inst 0:987c53b6a212 4 AmmoPusher : 押出機構 : 2入力スイッチ : DigitalIn * 2, I2CMotor * 1
inst 0:987c53b6a212 5 AmmoSupplier : 補給機構 : 2モータ, レーザーON/OFF : DigitalIn, InterruptIn, I2CMotor * 2
inst 0:987c53b6a212 6
inst 0:987c53b6a212 7 リレーMD
inst 0:987c53b6a212 8 Shooter : 発射機構 : 出力3つ : *I2C ( LPC1114側のプログラム : RelayYMotorDriver )
inst 0:987c53b6a212 9
inst 0:987c53b6a212 10 About Shooter{
inst 0:987c53b6a212 11 LPC1114{
inst 0:987c53b6a212 12 DigitalOut( dp11, dp13, dp14 );
inst 0:987c53b6a212 13 }
inst 0:987c53b6a212 14 }
inst 0:987c53b6a212 15
inst 0:987c53b6a212 16
inst 0:987c53b6a212 17 全統一制御ShootingSystem
inst 0:987c53b6a212 18 interface:
inst 0:987c53b6a212 19 void update( Command command ){
inst 0:987c53b6a212 20 if ( command.getIsShootable() && ( !mIsShooting ) ){
inst 0:987c53b6a212 21 mIsShooting = true;
inst 0:987c53b6a212 22 mShooterAngleManager->setTargetPosition( command.getAngleOfShooting() );
inst 0:987c53b6a212 23 mShooterPositionManager->setTargetPosition( command.getPositionOfShooting() );
inst 0:987c53b6a212 24 mAmmoPusher->draw(); // 補給された時に受け取れるように引いておく
inst 0:987c53b6a212 25 }
inst 0:987c53b6a212 26
inst 0:987c53b6a212 27 // 弾押し出し機構が補給された弾を受け取る位置に来たら補給開始
inst 0:987c53b6a212 28 if ( mAmmoPusher->hasPusherFinishedDrawing() ){
inst 0:987c53b6a212 29 mAmmoSupplier->supply();
inst 0:987c53b6a212 30 }
inst 0:987c53b6a212 31
inst 0:987c53b6a212 32 // 射撃作業で
inst 0:987c53b6a212 33 //  ・角度調整
inst 0:987c53b6a212 34 //  ・位置調整
inst 0:987c53b6a212 35 //  ・弾補給
inst 0:987c53b6a212 36 //  ・押出機構の準備
inst 0:987c53b6a212 37 // が完了したら発射
inst 0:987c53b6a212 38 bool canShooterFire = mIsShooting;
inst 0:987c53b6a212 39 canShooterFire &= mShooterAngleManager->isStop();
inst 0:987c53b6a212 40 canShooterFire &= mShooterPositionManager->isSop();
inst 0:987c53b6a212 41 canShooterFire &= mAmmoPusher->hasPusherFinishedDrawing();
inst 0:987c53b6a212 42 canShooterFire &= mAmmoSupplier->hasSupplied();
inst 0:987c53b6a212 43 if ( canShooterFire ){
inst 0:987c53b6a212 44 mShooter->launch();
inst 0:987c53b6a212 45 mAmmoPusher->push();
inst 0:987c53b6a212 46
inst 0:987c53b6a212 47 if ( mAmmoPresser->hasPresserFinishedPushing() ){
inst 0:987c53b6a212 48 mAmmoPresser->draw();
inst 0:987c53b6a212 49 }
inst 0:987c53b6a212 50 }
inst 0:987c53b6a212 51 /*
inst 0:987c53b6a212 52 hasWorkFinished系は仕事の受注でフラグリセット、仕事の完了でフラグセット.
inst 0:987c53b6a212 53 つまり受注前に使用すると前回の仕事のフラグを返されるため正しく動作しない可能性がある.
inst 0:987c53b6a212 54 */
inst 0:987c53b6a212 55 }
inst 0:987c53b6a212 56 void update( Command command ){
inst 0:987c53b6a212 57 if ( command.getIsShootable() && ( !mIsShooting ) ){
inst 0:987c53b6a212 58 mIsShooting = true;
inst 0:987c53b6a212 59 mShooterAngleManager->setAngle( command.getAngleOfShooting() );
inst 0:987c53b6a212 60 mShooterPositionManager->setPosition( command.getPositionOfShooting() );
inst 0:987c53b6a212 61 mAmmoPusher->draw();
inst 0:987c53b6a212 62 }
inst 0:987c53b6a212 63
inst 0:987c53b6a212 64 // 弾押し出し機構が補給された弾を受け取る位置に来たら補給開始
inst 0:987c53b6a212 65 if ( mAmmoPusher->hasPusherFinishedDrawing() ){
inst 0:987c53b6a212 66 mAmmoSupplier->supply();
inst 0:987c53b6a212 67 }
inst 0:987c53b6a212 68
inst 0:987c53b6a212 69 // 射撃作業で
inst 0:987c53b6a212 70 //  ・角度調整
inst 0:987c53b6a212 71 //  ・位置調整
inst 0:987c53b6a212 72 //  ・弾補給
inst 0:987c53b6a212 73 //  ・押出機構の準備
inst 0:987c53b6a212 74 // が完了したら発射
inst 0:987c53b6a212 75 bool canShooterFire = mIsShooting;
inst 0:987c53b6a212 76 canShooterFire &= mShooterAngleManager->hasWorkFinished();
inst 0:987c53b6a212 77 canShooterFire &= mShooterPositionManager->hasWorkFinished();
inst 0:987c53b6a212 78 canShooterFire &= mAmmoPusher->hasPusherFinishedDrawing();
inst 0:987c53b6a212 79 canShooterFire &= mAmmoSupplier->hasSupplied();
inst 0:987c53b6a212 80 if ( canShooterFire ){
inst 0:987c53b6a212 81 mShooter->launch();
inst 0:987c53b6a212 82 mAmmoPusher->push();
inst 0:987c53b6a212 83
inst 0:987c53b6a212 84 if ( mAmmoPresser->hasPresserFinishedPushing() ){
inst 0:987c53b6a212 85 mAmmoPresser->draw();
inst 0:987c53b6a212 86 }
inst 0:987c53b6a212 87 }
inst 0:987c53b6a212 88 /*
inst 0:987c53b6a212 89 hasWorkFinished系は仕事の受注でフラグリセット、仕事の完了でフラグセット.
inst 0:987c53b6a212 90 つまり受注前に使用すると前回の仕事のフラグを返されるため正しく動作しない可能性がある.
inst 0:987c53b6a212 91 */
inst 0:987c53b6a212 92 }