tarou yamada / ShootingSystem

Dependencies:   AmmoPusher AmmoSupplier Shooter

Dependents:   OBROT_ALL

ShootingSystemDoc.txt

Committer:
inst
Date:
2015-08-21
Revision:
0:987c53b6a212

File content as of revision 0:987c53b6a212:

MD
(I2CServo)ShooterAngleManager	 	: 発射角度変更機構	: ポテメ 					: I2CServo
(I2CServo)ShooterPositionManager	: 発射機構上下機構	: ポテメ					: I2CServo
AmmoPusher			 				: 押出機構			: 2入力スイッチ			: DigitalIn * 2, I2CMotor * 1
AmmoSupplier	 					: 補給機構			: 2モータ, レーザーON/OFF	: DigitalIn, InterruptIn, I2CMotor * 2

リレーMD
Shooter 							: 発射機構			: 出力3つ					: *I2C ( LPC1114側のプログラム : RelayYMotorDriver )

About Shooter{
	LPC1114{
		DigitalOut( dp11, dp13, dp14 );
	}
}


全統一制御ShootingSystem
interface:
	void update( Command command ){
		if ( command.getIsShootable() && ( !mIsShooting ) ){
			mIsShooting = true;
			mShooterAngleManager->setTargetPosition( command.getAngleOfShooting() );
			mShooterPositionManager->setTargetPosition( command.getPositionOfShooting() );
			mAmmoPusher->draw();	// 補給された時に受け取れるように引いておく
		}
		
		// 弾押し出し機構が補給された弾を受け取る位置に来たら補給開始
		if ( mAmmoPusher->hasPusherFinishedDrawing() ){
			mAmmoSupplier->supply();
		}
		
		// 射撃作業で
		//  ・角度調整
		//  ・位置調整
		//  ・弾補給
		//  ・押出機構の準備
		// が完了したら発射
		bool canShooterFire = mIsShooting;
		canShooterFire &= mShooterAngleManager->isStop();
		canShooterFire &= mShooterPositionManager->isSop();
		canShooterFire &= mAmmoPusher->hasPusherFinishedDrawing();
		canShooterFire &= mAmmoSupplier->hasSupplied();
		if ( canShooterFire ){
			mShooter->launch();
			mAmmoPusher->push();
			
			if ( mAmmoPresser->hasPresserFinishedPushing() ){
				mAmmoPresser->draw();
			}
		}
		/*
			hasWorkFinished系は仕事の受注でフラグリセット、仕事の完了でフラグセット.
			つまり受注前に使用すると前回の仕事のフラグを返されるため正しく動作しない可能性がある.
		*/
	}
	void update( Command command ){
		if ( command.getIsShootable() && ( !mIsShooting ) ){
			mIsShooting 		= true;
			mShooterAngleManager->setAngle( command.getAngleOfShooting() );
			mShooterPositionManager->setPosition( command.getPositionOfShooting() );
			mAmmoPusher->draw();
		}
		
		// 弾押し出し機構が補給された弾を受け取る位置に来たら補給開始
		if ( mAmmoPusher->hasPusherFinishedDrawing() ){
			mAmmoSupplier->supply();
		}
		
		// 射撃作業で
		//  ・角度調整
		//  ・位置調整
		//  ・弾補給
		//  ・押出機構の準備
		// が完了したら発射
		bool canShooterFire = mIsShooting;
		canShooterFire &= mShooterAngleManager->hasWorkFinished();
		canShooterFire &= mShooterPositionManager->hasWorkFinished();
		canShooterFire &= mAmmoPusher->hasPusherFinishedDrawing();
		canShooterFire &= mAmmoSupplier->hasSupplied();
		if ( canShooterFire ){
			mShooter->launch();
			mAmmoPusher->push();
			
			if ( mAmmoPresser->hasPresserFinishedPushing() ){
				mAmmoPresser->draw();
			}
		}
		/*
			hasWorkFinished系は仕事の受注でフラグリセット、仕事の完了でフラグセット.
			つまり受注前に使用すると前回の仕事のフラグを返されるため正しく動作しない可能性がある.
		*/
	}