Ejemplo n.º 1
0
        private string GetStatusText(ref AirlockStatus status)
        {
            sb.Begin();

            sb.Header("ГЕРМОШЛЮЗ");
            sb.Title("СОСТОЯНИЕ");

            char icon = ' ';

            switch (fsm.StateCat)
            {
            case StateCategory.Ready:
                icon = CHAR_GREEN;
                break;

            case StateCategory.Locked:
                icon = CHAR_RED;
                break;

            case StateCategory.Transition:
                icon = CHAR_YELLOW;
                break;

            case StateCategory.InUse:
                icon = CHAR_CYAN;
                break;
            }
            sb.Value(icon, fsm.State);

            status.ExternalDoors.Print(sb, "ВНЕШ. ДВЕРЬ");
            status.InternalDoors.Print(sb, "ВНУТР. ДВЕРЬ");
            status.AirVents.Print(sb, "ДАВЛЕНИЕ");

            var hasWarnings          = !string.IsNullOrEmpty(fsm.Warning);
            var hasAirlockHullBreach = status.InternalDoors.IsClosed && status.ExternalDoors.IsClosed && !status.AirVents.IsAirtight;
            var hasShipHullBreach    = status.InternalDoors.IsOpen && status.ExternalDoors.IsClosed && !status.AirVents.IsAirtight;

            if (hasWarnings || hasAirlockHullBreach || hasShipHullBreach)
            {
                sb.Title("ВНИМАНИЕ");
                if (hasWarnings)
                {
                    sb.Value(fsm.Warning);
                }

                if (hasAirlockHullBreach)
                {
                    sb.Value(CHAR_RED, "Шлюз негерметичен");
                }

                if (hasShipHullBreach)
                {
                    sb.Value(CHAR_RED, "Корабль негерметичен");
                }
            }

            sb.End();

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private void GetStatus(out AirlockStatus status)
        {
            status = new AirlockStatus();

            status.IsObstructed = GetObstructionStatus();
            GetStatus(AL_DOOR_INNER, ref status.InternalDoors);
            GetStatus(AL_DOOR_OUTER, ref status.ExternalDoors);
            GetStatus(AL_AIRVENTS, ref status.AirVents);
        }
Ejemplo n.º 3
0
            public void Update(IController control, Event e, ref AirlockStatus status)
            {
                if (state == null || e == Event.RESET)
                {
                    state     = IDLE;
                    stateTime = DateTime.UtcNow;
                    Update(control, Event.INIT, ref status);

                    if (e == Event.RESET)
                    {
                        return;
                    }
                }

                var ctx = new StateCtx
                {
                    Event   = e,
                    Status  = status,
                    Control = control,
                    Time    = (DateTime.UtcNow - stateTime).TotalSeconds
                };
                var result = state(ref ctx);

                if (result != null)
                {
                    description = result.Value.Description;

                    if (state != result.Value.NextState)
                    {
                        state     = result.Value.NextState;
                        stateTime = DateTime.UtcNow;

                        Update(control, Event.INIT, ref status);
                    }
                }
            }