コード例 #1
0
        /// <summary>
        /// Unpause the service, and immediately force it to update the charge status.
        /// </summary>
        public void Restart()
        {
            Log.Debug(Name + " Restarting...");
            lock (this)
            {
                // Setting the interval equal to executeInterval will cause the charge status
                // to be updated on the service's next 'tick'.
                _currentInterval = new TimeSpan(_executeInterval.Ticks);

                // Whenever we restart the service, assume a docked instrument is charging (until we find out otherwise)
                if (IsBatteryRechargable())
                {
                    State  = ChargingState.Charging;
                    _phase = ChargePhase.FullCharge;
                }
                else
                {
                    //State = ChargingState.NotCharging;
                    _phase = ChargePhase.ChargeOff;
                }

                _phaseStart = DateTime.UtcNow;

                Paused = false;
            }
        }
コード例 #2
0
ファイル: DefaultAIState.cs プロジェクト: Dante2001/phonegame
 public override void Charging(bool onPlate)
 {
     if (onPlate)
     {
         currentState = new ChargingState(details);
         currentState.Charging(onPlate);
     }
 }
コード例 #3
0
    protected new void Awake()
    {
        base.Awake();
        (_rend = GetComponent <SpriteRenderer>()).enabled = false;
        (_coll = GetComponent <Collider2D>()).enabled     = false;
        _rb = GetComponent <Rigidbody2D>();

        ChargingState   s1 = new ChargingState(_ASM, this);
        BallThrownState s2 = new BallThrownState(_ASM, this);

        s1.SetTargetStates(s2);
        _ASM.InitializeWithStates(new InactiveEnabledAttackState(_ASM, this), s1);
    }
コード例 #4
0
        public override void HandleMessage(dynamic jsonObject)
        {
            int?state = jsonObject.State;
            int?id    = jsonObject.ID;

            if (id.HasValue || !state.HasValue)
            {
                return;
            }

            ChargingState = (ChargingState)state.GetValueOrDefault();

            SendMessage(Topic, ChargingState.ToString());
            Logger.LogDebug($"Charging state handled. State: {ChargingState.ToString()}");
        }
コード例 #5
0
ファイル: BossMovement.cs プロジェクト: BigUngaBunga/BelowUs
        private void UpdateCharging()
        {
            switch (currentChargingState)
            {
            case ChargingState.Entry:     //Sets first location
                currentChargingState = ChargingState.Charge;
                FindNextTargetPosition();
                break;

            case ChargingState.Charge:
                UpdateMovementCharging();
                CheckifBossIsPassCircle();
                break;
            }
        }
コード例 #6
0
ファイル: ChargeControl.cs プロジェクト: Shynthavi/Ladeskab
        //Triggerhandler for UsbCharger

        private void ChargingCurrentValue(object sender, CurrentEventArgs e)
        {
            // *** Equivalence partitions *** //
            if (e.Current <= 0)
            {
                _state = ChargingState.NoConnection;
            }
            else if (e.Current > 0 && e.Current <= 5)
            {
                _state = ChargingState.FullyCharged;
            }
            else if (e.Current > 5 && e.Current <= 500)
            {
                _state = ChargingState.Charging;
            }
            else if (e.Current > 500)
            {
                _state = ChargingState.ChargingError;
            }

            switch (_state)
            {
            case ChargingState.NoConnection:
                _display.ShowMessage("Din telefon er ikke ordentlig tilsluttet. Prøv igen.");

                break;

            case ChargingState.Charging:
                _display.ShowMessage("Din telefon oplades.");

                break;

            case ChargingState.FullyCharged:
                _display.ShowMessage("Din telefon er fuldt opladt.");

                break;

            case ChargingState.ChargingError:
                _display.ShowMessage("Error: Prøv igen.");

                break;
            }
        }
コード例 #7
0
    void EvaluateChargingState()
    {
        if (chargingState == ChargingState.Charging)
        {
            if (currentCharge >= maxCharge)
            {
                currentCharge = maxCharge;
                chargingState = ChargingState.Charged;
            }
            else
            {
                currentCharge = currentCharge + chargingAmount;
                //Debug.Log("new charge: " + (currentCharge) );
            }

            ChargeInfo chargeInfo = new ChargeInfo();
            chargeInfo.chargeState   = chargingState;
            chargeInfo.currentCharge = currentCharge;
            //onChargeEvent.Invoke(chargeInfo);
        }
    }
コード例 #8
0
        public override void Update(float deltaTime, Camera cam)
        {
            ReloadTimer -= deltaTime;

            if (ReloadTimer < 0.0f)
            {
                ReloadTimer = 0.0f;
                // was this an optimization or related to something else? it cannot occur for charge-type weapons
                //IsActive = false;
                if (MaxChargeTime == 0.0f)
                {
                    IsActive = false;
                    return;
                }
            }

            float previousChargeTime = currentChargeTime;

            float chargeDeltaTime = tryingToCharge && ReloadTimer <= 0f ? deltaTime : -deltaTime;

            currentChargeTime = Math.Clamp(currentChargeTime + chargeDeltaTime, 0f, MaxChargeTime);

            tryingToCharge = false;

            if (currentChargeTime == 0f)
            {
                currentChargingState = ChargingState.Inactive;
            }
            else if (currentChargeTime < previousChargeTime)
            {
                currentChargingState = ChargingState.WindingDown;
            }
            else
            {
                // if we are charging up or at maxed charge, remain winding up
                currentChargingState = ChargingState.WindingUp;
            }

            UpdateProjSpecific(deltaTime);
        }
コード例 #9
0
        // Returns battery state for input report data
        internal BatteryState(byte[] data, bool viaUSB)
        {
            // Check report
            if (data != null)
            {
                // Battery state is @ byte 30 for USB, byte 32 for bluetooth
                int offset = (viaUSB ? 30 : 32);

                // Lower half is battery level
                int level = data[offset] & 0x0f;

                // Upper half is charging state
                int charging = data[offset] & 0x10;

                // Bluetooth power level is between 0 to 9
                // DS4Windows says the max BT level is 8
                // Cabled power level is between 0 to 10
                // Cabled power level > 10 means fully charged
                const double maxBatteryBT    = 8.0;
                const double maxBatteryUSB   = 10.0;
                double       batteryLevel    = -1;
                var          batteryCharging = ChargingState.Discharging;

                // Get values
                if (charging != 0)
                {
                    batteryLevel    = Math.Min(level, maxBatteryUSB) * 10.0;
                    batteryCharging = level > 10 ? ChargingState.FullyCharged : ChargingState.Charging;
                }
                else
                {
                    batteryLevel    = (Math.Min(level, maxBatteryBT) / maxBatteryBT) * 100;
                    batteryCharging = ChargingState.Discharging;
                }

                // Set properties
                this.Level         = batteryLevel;
                this.ChargingState = batteryCharging;
            }
        }
コード例 #10
0
        public override void HandleMessage(dynamic jsonObject)
        {
            int?id = jsonObject.ID;

            if (id.GetValueOrDefault() != 2)
            {
                return;
            }

            int?state = jsonObject.State;
            int?plug  = jsonObject.Plug;

            ChargingState = (ChargingState)state.GetValueOrDefault();
            var plugState = (PlugState)plug.GetValueOrDefault();

            SendMessage(ChargingStateMessageHandler.Topic, ChargingState.ToString());
            SendMessage(PlugStateMessageHandler.Topic, plugState.ToString());

            Logger.LogDebug("Report 2 handled. " +
                            $"State: {ChargingState.ToString()}," +
                            $"Plug: {plugState.ToString()}");
        }
コード例 #11
0
ファイル: WheelController.cs プロジェクト: J4stMart/WheelGame
    private void ComputeVelocity()
    {
        if (Mathf.Abs(velocity.x) < 0.1f)
        {
            velocity.x = 0;
            wheelVelocity = 0;
        }

        if (velocity.x == 0)
        {
            if ((Input.GetButton("Left") || Input.GetButton("Right")) && chargingState == ChargingState.CanCharge)
            {
                chargingState = ChargingState.IsCharging;
            }
            if ((Input.GetButton("Left") || Input.GetButton("Right")) && chargingState == ChargingState.IsCharging)
            {
                charge += Time.deltaTime * (chargeSpeed + Mathf.Sqrt(charge));
                charge = Mathf.Clamp(charge, 0, maxCharge);

                if (facingLeft)
                    wheelVelocity = -charge * speed;
                else
                    wheelVelocity = charge * speed;

                chargeBar.transform.localScale = new Vector2(charge / maxCharge, 1);
            }
            else if (Input.GetButtonUp("Left") || Input.GetButtonUp("Right"))
            {
                if (facingLeft)
                {
                    velocity.x = -charge * speed;
                }
                else
                {
                    velocity.x = charge * speed;
                }

                charge = 0;
                chargingState = ChargingState.CantCharge;
                chargeBar.transform.localScale = new Vector2(0, 1);
                chargeBar.transform.parent.gameObject.SetActive(false);
            }
        }
        else
        {
            if (Input.GetButton("Down") && brakeEnabled)
            {
                Vector2 brakeVelocity = velocity.normalized * Time.deltaTime * 30;
                velocity.x -= brakeVelocity.x;
                if (brakeVelocity.y > 0)
                    addYVelocity -= brakeVelocity.y;
            }
        }

        if (Input.GetButton("Left") && (velocity.x == 0 || grounded))
        {
            facingLeft = true;

            velocity.x = -Mathf.Abs(velocity.x);
        }
        else if (Input.GetButton("Right") && (velocity.x == 0 || grounded))
        {
            facingLeft = false;

            velocity.x = Mathf.Abs(velocity.x);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Respawn();
        }

        if (grounded)
        {
            if (velocity.x != 0)
            {
                velocity.x -= Mathf.Sign(velocity.x) * momentumReduction * Time.deltaTime;
                wheelVelocity = velocity.x;
            }
            else
            {
                if (chargingState != ChargingState.IsCharging)
                {
                    chargingState = ChargingState.CanCharge;
                    chargeBar.transform.parent.gameObject.SetActive(true);
                }
            }

            if (Input.GetButtonDown("Jump") && jumpEnabled)
            {
                addYVelocity = jumpTakeOffSpeed;
            }
        }
        else
        {
            velocity.x -= Mathf.Sign(velocity.x) * momentumReduction / 5 * Time.deltaTime;
        }
    }
コード例 #12
0
    public override void Begin()
    {
        base.Begin();

        GameSystem.SetTimeMultiplier(GameSystem.GAMEPLAY, 1.0);

        IdleState              idle              = new IdleState(this.listenerId);
        MovingForwardState     movingForward     = new MovingForwardState(this.listenerId);
        MovingBackwardState    movingBackward    = new MovingBackwardState(this.listenerId);
        QuickStepForwardState  quickStepForward  = new QuickStepForwardState(this.listenerId);
        QuickStepBackwardState quickStepBackward = new QuickStepBackwardState(this.listenerId);
        DashChargingState      dashCharging      = new DashChargingState(this.listenerId);
        DashState              dash              = new DashState(this.listenerId);
        FeintState             feint             = new FeintState(this.listenerId);
        ChargingState          charging          = new ChargingState(this.listenerId);
        ChargeRecoveryState    chargeRecovery    = new ChargeRecoveryState(this.listenerId);
        DashRecoveryState      dashRecovery      = new DashRecoveryState(this.listenerId);
        //SpecialActivateState specialActivate = new SpecialActivateState(this.listenerId);
        //SpecialChargingState specialCharging = new SpecialChargingState(this.listenerId);
        CollisionWinCondition  collisionWinCond  = new CollisionWinCondition(this.listenerId);
        CollisionLossCondition collisionLossCond = new CollisionLossCondition(this.listenerId);
        CollisionWinState      collisionWin      = new CollisionWinState(this.listenerId);
        CollisionLossState     collisionLoss     = new CollisionLossState(this.listenerId);

        PlayerReadyState   ready   = new PlayerReadyState(this.listenerId);
        PlayerPlayingState playing = new PlayerPlayingState(this.listenerId);
        PlayerPausedState  paused  = new PlayerPausedState(this.listenerId);
        VictoryState       victory = new VictoryState(this.listenerId);
        DefeatState        defeat  = new DefeatState(this.listenerId);

        //SpecialActivateCondition specialActivateCond = new SpecialActivateCondition(this.listenerId);
        DefeatCondition defeatCond = new DefeatCondition(this.listenerId);

        idle.AddStateChange("moveForward", movingForward);
        idle.AddStateChange("moveBackward", movingBackward);
        idle.AddStateChange("charge", charging);
        idle.AddStateChange("dashCharge", dashCharging);
        idle.AddStateChange("feint", feint);
        idle.AddStateChange("collisionWin", collisionWin);
        idle.AddStateChange("collisionLoss", collisionLoss);
        //idle.AddStateChange("specialActivate", specialActivate);
        idle.AddGameStateCondition(collisionWinCond);
        idle.AddGameStateCondition(collisionLossCond);
        //idle.AddGameStateCondition(specialActivateCond);
        movingForward.AddStateChange("stop", idle);
        movingForward.AddStateChange("quickStep", quickStepForward);
        movingForward.AddStateChange("moveBackward", movingBackward);
        movingForward.AddStateChange("charge", charging);
        movingForward.AddStateChange("dashCharge", dashCharging);
        movingForward.AddStateChange("feint", feint);
        movingForward.AddStateChange("collisionWin", collisionWin);
        movingForward.AddStateChange("collisionLoss", collisionLoss);
        //movingForward.AddStateChange("specialActivate", specialActivate);
        movingForward.AddGameStateCondition(collisionWinCond);
        movingForward.AddGameStateCondition(collisionLossCond);
        //movingForward.AddGameStateCondition(specialActivateCond);
        quickStepForward.AddStateChange("stop", idle);
        quickStepForward.AddStateChange("charge", charging);
        quickStepForward.AddStateChange("dashCharge", dashCharging);
        quickStepForward.AddStateChange("feint", feint);
        quickStepForward.AddStateChange("collisionWin", collisionWin);
        quickStepForward.AddStateChange("collisionLoss", collisionLoss);
        //quickStepForward.AddStateChange("specialActivate", specialActivate);
        quickStepForward.AddGameStateCondition(collisionWinCond);
        quickStepForward.AddGameStateCondition(collisionLossCond);
        //quickStepForward.AddGameStateCondition(specialActivateCond);
        movingBackward.AddStateChange("stop", idle);
        movingBackward.AddStateChange("quickStep", quickStepBackward);
        movingBackward.AddStateChange("moveForward", movingForward);
        movingBackward.AddStateChange("charge", charging);
        movingBackward.AddStateChange("dashCharge", dashCharging);
        movingBackward.AddStateChange("feint", feint);
        movingBackward.AddStateChange("collisionWin", collisionWin);
        movingBackward.AddStateChange("collisionLoss", collisionLoss);
        //movingBackward.AddStateChange("specialActivate", specialActivate);
        movingBackward.AddGameStateCondition(collisionWinCond);
        movingBackward.AddGameStateCondition(collisionLossCond);
        //movingBackward.AddGameStateCondition(specialActivateCond);
        quickStepBackward.AddStateChange("stop", idle);
        quickStepBackward.AddStateChange("charge", charging);
        quickStepBackward.AddStateChange("dashCharge", dashCharging);
        quickStepBackward.AddStateChange("feint", feint);
        quickStepBackward.AddStateChange("collisionWin", collisionWin);
        quickStepBackward.AddStateChange("collisionLoss", collisionLoss);
        //quickStepBackward.AddStateChange("specialActivate", specialActivate);
        quickStepBackward.AddGameStateCondition(collisionWinCond);
        quickStepBackward.AddGameStateCondition(collisionLossCond);
        //quickStepBackward.AddGameStateCondition(specialActivateCond);
        charging.AddStateChange("stop", chargeRecovery);
        charging.AddStateChange("collisionWin", collisionWin);
        charging.AddStateChange("collisionLoss", collisionLoss);
        charging.AddGameStateCondition(collisionWinCond);
        charging.AddGameStateCondition(collisionLossCond);
        dashCharging.AddStateChange("dash", dash);
        dashCharging.AddStateChange("collisionWin", collisionWin);
        dashCharging.AddStateChange("collisionLoss", collisionLoss);
        dashCharging.AddGameStateCondition(collisionWinCond);
        dashCharging.AddGameStateCondition(collisionLossCond);
        dash.AddStateChange("stop", dashRecovery);
        dash.AddStateChange("collisionWin", collisionWin);
        dash.AddStateChange("collisionLoss", collisionLoss);
        dash.AddGameStateCondition(collisionWinCond);
        dash.AddGameStateCondition(collisionLossCond);
        feint.AddStateChange("stop", idle);
        feint.AddStateChange("charge", charging);
        feint.AddStateChange("dashCharge", dashCharging);
        feint.AddStateChange("feint", feint);
        feint.AddStateChange("collisionWin", collisionWin);
        feint.AddStateChange("collisionLoss", collisionLoss);
        feint.AddGameStateCondition(collisionWinCond);
        feint.AddGameStateCondition(collisionLossCond);
        chargeRecovery.AddStateChange("recover", idle);
        chargeRecovery.AddStateChange("collisionWin", collisionWin);
        chargeRecovery.AddStateChange("collisionLoss", collisionLoss);
        chargeRecovery.AddGameStateCondition(collisionWinCond);
        chargeRecovery.AddGameStateCondition(collisionLossCond);
        dashRecovery.AddStateChange("recover", idle);
        dashRecovery.AddStateChange("collisionWin", collisionWin);
        dashRecovery.AddStateChange("collisionLoss", collisionLoss);
        dashRecovery.AddGameStateCondition(collisionWinCond);
        dashRecovery.AddGameStateCondition(collisionLossCond);

        /*specialActivate.AddStateChange("specialCharge", specialCharging);
         * specialActivate.AddStateChange("collisionWin", collisionWin);
         * specialActivate.AddStateChange("collisionLoss", collisionLoss);
         * specialActivate.AddGameStateCondition(collisionWinCond);
         * specialActivate.AddGameStateCondition(collisionLossCond);
         * specialCharging.AddStateChange("stop", idle);
         * specialCharging.AddStateChange("collisionWin", collisionWin);
         * specialCharging.AddStateChange("collisionLoss", collisionLoss);
         * specialCharging.AddGameStateCondition(collisionWinCond);
         * specialCharging.AddGameStateCondition(collisionLossCond);*/
        collisionWin.AddStateChange("recover", idle);
        collisionLoss.AddStateChange("recover", idle);

        ready.AddStateChange("play", playing);
        playing.AddStateChange("pause", paused);
        playing.AddGameStateCondition(defeatCond);
        paused.AddStateChange("play", playing);
        playing.AddStateChange("victory", victory);
        playing.AddStateChange("defeat", defeat);

        this.input = new GameInputState(this.listenerId, 0);
        this.input.SetInputMapping(GameInputState.LEFT_STICK_LEFT_RIGHT, "moveStick");
        this.input.SetInputMapping(GameInputState.D_PAD_LEFT_RIGHT, "moveStick");
        this.input.SetInputMapping(GameInputState.A, "chargeButton");
        this.input.SetInputMapping(GameInputState.B, "quickStepButton");
        this.input.SetInputMapping(GameInputState.X, "dashButton");
        this.input.SetInputMapping(GameInputState.Y, "feintButton");
        this.input.SetInputMapping(GameInputState.START, "start");

        this.AddCurrentState(this.input);
        this.AddCurrentState(idle);
        this.AddCurrentState(ready);
    }
コード例 #13
0
 private void UpdateState(ChargingState newState)
 {
     Current         = newState;
     LastStateChange = DateTimeProvider.Now;
 }
コード例 #14
0
    override public BT_Status UpdateAction()
    {
        float step = 0;

        //Make animation of waiting for charge
        if (!can_charge)
        {
            state_charge    = ChargingState.WAITING_TO_CHARGE;
            timer_charging += Time.deltaTime;

            get_damage.enabled = false;

            myAnimator.SetBool("player_hit", false);

            Charger_Filler.enabled    = true;
            Charger_Filler.fillAmount = 1 - timer_charging / time_charging_anim;

            if (timer_charging > time_charging_anim)
            {
                Charger_Filler.enabled  = false;
                can_charge              = true;
                charge_collider.enabled = true;
                CalculatePointToCharge();
            }
        }
        else
        {
            Vector3 mag_to_point = Vector3.zero;

            if (state_charge != ChargingState.STUNNED)
            {
                state_charge = ChargingState.CHARGING;
                step         = Time.deltaTime * charge_speed;

                mag_to_point = point_to_charge - transform.position;
            }

            if (mag_to_point.magnitude < 0.85f)
            {
                if ((bool)myBT.myBB.GetParameter("player_detected_charging") && state_charge != ChargingState.STUNNED)
                {
                    //Next charge
                    can_charge = false;
                    myBT.myBB.SetParameter("player_detected_charging", false);
                    myAnimator.SetBool("player_hit", true);
                    ResetValues();
                }
                else
                {
                    state_charge = ChargingState.STUNNED;
                    //stunned
                    timer_stunned     += Time.deltaTime;
                    get_damage.enabled = true;
                    inmortalGO.SetActive(false);

                    Stunned_Filler.enabled    = true;
                    Stunned_Filler.fillAmount = 1 - timer_stunned / Time_stunned;

                    myAnimator.SetBool("Stunned", true);

                    if (timer_stunned > Time_stunned || (bool)myBT.myBB.GetParameter("is_enemy_hit") == true)
                    {
                        Stunned_Filler.enabled = false;
                        can_charge             = false;
                        myBT.myBB.SetParameter("is_enemy_hit", false);
                        myBT.myBB.SetParameter("player_detected_charging", false);
                        ResetValues();
                        myAnimator.SetBool("Stunned", false);
                    }
                }
                charge_collider.enabled = false;
                //See if player get hit
                //if not stun
                //if yes next charge
            }
            else
            {
                transform.position = Vector3.MoveTowards(transform.position, point_to_charge, step);
            }
        }

        return(BT_Status.RUNNING);
    }
コード例 #15
0
        /// <summary>
        /// Helper method for Run() which communicates with instrument to determine its charging status
        /// then updates charger service status properties
        /// </summary>
        private void RunUpdateChargerState()
        {
            const string funcName = "RunUpdateChargerState";

            Log.Debug(string.Format("{0} invoking {1} on a \"{2}\" battery", Name, funcName, BatteryCode));

            if (!Controller.IsDocked())
            {
                Log.Debug(string.Format("{0}: instrument undocked.", funcName));
                return;
            }

            try
            {
                InstrumentChargingOperation op = new InstrumentChargingOperation();

                op.Execute();

                // Keep track of consecutively occurring phases, and when they first occur.
                if (_phase != op.InstrumentChargePhase)
                {
                    _phase      = op.InstrumentChargePhase;
                    _phaseStart = DateTime.UtcNow;
                }

                // If instrument is having any charging problems, report the error to server.
                // This will also allow the error to upload to iNet if they're an inet customer.
                if (_phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeFailure ||
                    _phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeFault
                    //                ||   _phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeOverTempFailure
                    //                ||   _phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeUnderTempFailure
                    //                ||   _phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeOff ( AND battery is lithium )
                    || _phase == ISC.iNet.DS.DomainModel.ChargePhase.PreChargeFault ||
                    _phase == ISC.iNet.DS.DomainModel.ChargePhase.ChargeTimeout)
                {
                    // Do not change this message.  iNet is parsing it!
                    string msg = string.Format("Instrument \"{0}\" has reported a \"{1}\" charging error (Battery=\"{2}\", type=\"{3}\").",
                                               op.InstrumentSerialNumber, _phase.ToString(), op.BatterySerialNumber, op.BatteryCode);
                    Master.ReporterService.ReportError(new DockingStationError(msg, DockingStationErrorLevel.Warning, op.InstrumentSerialNumber));
                }

                // BatteryCode should be empty if user has docked a completely dead
                // battery.  If the instrument has now charged up enough such that we
                // can now talk to it, then get the battery type.
                if (BatteryCode == string.Empty)
                {
                    BatteryCode = op.BatteryCode;
                }

                if (op.ChargingState == ChargingState.Error)
                {
                    // How much time has elasped between now and when we first saw the
                    // instrument go into error?

                    TimeSpan errorTimeElapsed = DateTime.UtcNow - _phaseStart;

                    Log.Debug(string.Format("{0} - BATTERY IN {1} PHASE!  ELAPSED TIME: {2}", Name, _phase.ToString(), errorTimeElapsed.ToString()));

                    // Instrument hasn't been in error too long?  Then
                    // just treat it as if the intrument is normally charging; no need to
                    // scare the user.  But if it's been stuck in error too
                    // long, then finally just report it as an error.

                    TimeSpan maxTimeAllowed = (_phase == ChargePhase.ChargeOverTempFailure || _phase == ChargePhase.ChargeUnderTempFailure) ? _maxTempFailureTimeAllowed : _maxErrorPhaseAllowed;

                    if (errorTimeElapsed <= maxTimeAllowed)
                    {
                        State = ChargingState.Charging;
                    }
                    else
                    {
                        State = ChargingState.Error;

                        // Do not change this message.  iNet is parsing it!
                        string msg = string.Format("Instrument \"{0}\" has been in \"{1}\" for an overextended period of time ({2}). (Battery=\"{3}\", type=\"{4}\")",
                                                   op.InstrumentSerialNumber, _phase.ToString(), errorTimeElapsed.ToString(), op.BatterySerialNumber, op.BatteryCode);

                        Log.Error(string.Format("{0} - {1}", Name, msg.ToUpper()));
                        Log.Error(string.Format("{0} - Reporting {1} to server", Name, op.InstrumentChargePhase.ToString()));

                        Master.ReporterService.ReportError(new DockingStationError(msg, DockingStationErrorLevel.Warning, op.InstrumentSerialNumber));
                    }
                }                 // end ChargingState.Error

                else              // op.State != ChargingState.Error
                {
                    State = op.ChargingState;
                }

                Log.Debug(Name + " - ChargingState=" + State);

                // When instrument is done charging, then turn it off!
                if (State == ChargingState.NotCharging)
                {
                    Log.Debug(Name + " - INSTRUMENT APPEARS FULLY CHARGED. TURNING OFF INSTRUMENT.");
                    Log.Debug(Name + " - WILL NO LONGER POLL INSTRUMENT FOR CHARGING STATUS.");
                    new InstrumentTurnOffOperation(InstrumentTurnOffOperation.Reason.ChargingComplete).Execute();
                }
            }
            catch (InstrumentPingFailedException e)
            {
                Log.Error(Name, e);
                if (!Controller.IsDocked())                   // May have got the exception because they undocked. Ignore it.
                {
                    State = ChargingState.NotCharging;
                }
                else
                {
                    State = ChargingState.Error;                      // Couldn't ping the instrument.  dead battery?
                }
            }
            catch (Exception e)
            {
                Log.Error(Name, e);

                // Whatever the error was, if the instrument isn't present, then it's
                // not charging.
                if (!Controller.IsDocked())
                {
                    State = ChargingState.NotCharging;
                }
                // Not sure what the error is.  Leave charging state as is.
            }
        }
コード例 #16
0
 private ChargingFrameData(ChargingState chargingState, float chargingTime)
 {
     ChargingState = chargingState;
     ChargingTime  = chargingTime;
 }
コード例 #17
0
 private void Magnify(Vector3 pos)
 {
     if (magnifyMode == MagnifyMode.OnClickSingle)
     {
         if (chargingState == ChargingState.Charged)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 magnifyArea.transform.position = pos;
                 Collider[] hitColliders = Physics.OverlapBox(magnifyArea.transform.position, magnifyArea.transform.localScale / 2, Quaternion.identity, m_LayerMask);
                 foreach (var coll in hitColliders)
                 {
                     //Debug.Log("Hit : " + coll.name);
                     SubjectManager subject = coll.gameObject.GetComponent <SubjectManager>();
                     subject.RevealSubjectStatus();
                     subject.IsolateInfectedSubject();
                     break;
                 }
                 onMagnifyUsed.Invoke(pos);
                 currentCharge = 0.0f;
                 chargingState = ChargingState.Charging;
             }
         }
     }
     else if (magnifyMode == MagnifyMode.OnClickMultiple)
     {
         if (chargingState == ChargingState.Charged)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 magnifyArea.transform.position = pos;
                 Collider[] hitColliders = Physics.OverlapBox(magnifyArea.transform.position, magnifyArea.transform.localScale / 2, Quaternion.identity, m_LayerMask);
                 foreach (var coll in hitColliders)
                 {
                     //Debug.Log("Hit : " + coll.name);
                     SubjectManager subject = coll.gameObject.GetComponent <SubjectManager>();
                     subject.RevealSubjectStatus();
                     subject.IsolateInfectedSubject();
                 }
                 onMagnifyUsed.Invoke(pos);
                 currentCharge = 0.0f;
                 chargingState = ChargingState.Charging;
             }
         }
     }
     else if (magnifyMode == MagnifyMode.OnHover || magnifyMode == MagnifyMode.OnHoverDemo)
     {
         bool isolateSubject = false;
         if (chargingState == ChargingState.Charged)
         {
             if (Input.GetMouseButtonDown(0) || magnifyMode == MagnifyMode.OnHoverDemo)
             {
                 isolateSubject = true;
                 onMagnifyUsed.Invoke(pos);
                 currentCharge = 0.0f;
                 chargingState = ChargingState.Charging;
             }
         }
         magnifyArea.transform.position = pos;
         Collider[] hitColliders = Physics.OverlapBox(magnifyArea.transform.position, magnifyArea.transform.localScale / 2, Quaternion.identity, m_LayerMask);
         foreach (var coll in hitColliders)
         {
             SubjectManager subject = coll.gameObject.GetComponent <SubjectManager>();
             subject.RevealSubjectStatus();
             if (isolateSubject && subject.GetSubjectStatus() == SubjectStatus.Infected)
             {
                 if (magnifyMode == MagnifyMode.OnHoverDemo)
                 {
                     clickFlash.ClickIt();
                     mouseclickFlash.ClickIt();
                 }
                 subject.IsolateInfectedSubject();
             }
         }
     }
 }