コード例 #1
0
    void Update()
    {
        if (m_useEndTimer && !isPaused())
        {
            m_endTimer -= Time.deltaTime;
            if (m_endTimer <= 0)
            {
                m_endTimer = 0;
                killPlayer();
            }

            //endTimerText.enabled = true;

            float minutes = Mathf.Floor(m_endTimer / 60);
            float seconds = (m_endTimer % 60);

            //endTimerText.text = minutes.ToString("00") + ":" + seconds.ToString("00");

            //Debug.Log("m_endTimer = " + m_endTimer);
        }
        else
        {
            //Debug.Log("No timer?");
            //endTimerText.enabled = false;
        }

                #if UNITY_EDITOR
        pauseTypeDisplay     = m_pauseType;
        prevPauseTypeDisplay = prevPauseType;
                #endif
    }
コード例 #2
0
 public bool ExitPauseState(PauseType exitType)
 {
     if (pauseType != exitType)
     {
         return(false);
     }
     return(ExitPauseState());
 }
コード例 #3
0
    public bool IsWorldPauseType(PauseType testType)
    {
        int check = (int)PauseType.CUTSCENE | (int)PauseType.TETHER_MENU | (int)PauseType.TETHER_TRANSITION | (int)PauseType.GAME;

        if (((int)testType & check) != 0)
        {
            return(true);
        }
        return(false);
    }
コード例 #4
0
    /*
     * Pause functionality
     */

    /*
     * /// <summary>
     * /// Sets whether the game is paused
     * /// </summary>
     * /// <returns><c>true</c>, if pause's state could be changed <c>false</c> otherwise.</returns>
     * /// <param name="state">Whether to pause or resume the game</param>
     * public static bool setPause(bool state)
     * {
     *      // Return if locked or the state isn't actually changing
     *      if (inst.pauseLock || inst.paused == state)
     *      {
     *              return false;
     *      }
     *
     *      inst.paused = state;
     *
     *      if (inst.pauseToggled != null)
     *      {
     *              inst.pauseToggled(state);
     *      }
     *      return true;
     * }
     *
     * public static bool isPaused()
     * {
     *      return inst.paused;
     * }
     *
     * public static void setPauseLock(bool state)
     * {
     *      inst.pauseLock = state;
     *
     *      if (inst.pauseLockedToggled != null)
     *      {
     *              inst.pauseLockedToggled(state);
     *      }
     * }
     */

    /// <summary>
    /// Tells the GameManager to enter (not exit) a specific pause state. Returns true if successful
    /// </summary>
    /// <param name="newPauseType">New pause type.</param>
    public bool EnterPauseState(PauseType newPauseType)
    {
        // Pause states have two levels
        // The lower level pause states are CUTSCENE, TETHER_TRANSITION, and ZOOM
        // The top level pause state is a full GAME pause, which can be accessed independently or on top of a lower level
        // If entering a top level pause through a lower level, when exiting the state machine must pass back down through the lower level

        Debug.Log("Enter pause state called: " + newPauseType);

        // Check for redunancy
        if (pauseType == newPauseType)
        {
            Debug.LogWarning("Trying to change GameManager pause type to the same pause type");
            return(false);
        }

        // In default, dashing, pushing

        // Don't allow entering a pause state of NONE (that would be exiting!)
        if (newPauseType == PauseType.NONE)
        {
            Debug.LogError("EnterPauseState cannot accept PauseType.NONE as a parameter - it would be considered exiting");
            return(false);
        }

        // Reset the backup pause state
        prevPauseType = PauseType.NONE;

        // If the current pause type is NONE, allow entry into any pause state
        if (pauseType == PauseType.NONE)
        {
            m_pauseType = newPauseType;
            if (pauseTypeToggled != null)
            {
                pauseTypeToggled(m_pauseType);
            }
            return(true);
        }
        // If the current pause type is one of the lower level states (below full game pause), elevate to game paused and save the previous pause state
        //else if ((int)pauseType == lowerPauseStates && newPauseType == PauseType.GAME)
        else if (IsLowerPauseType(pauseType) && newPauseType == PauseType.GAME)
        {
            // Back up the current pause type so it can be restored when unpausing
            prevPauseType = pauseType;

            m_pauseType = newPauseType;
            if (pauseTypeToggled != null)
            {
                pauseTypeToggled(m_pauseType);
            }
            return(true);
        }

        return(false);
    }
コード例 #5
0
 internal DebugInformation(Engine engine, Node currentNode, Location currentLocation, JsValue returnValue,
                           long currentMemoryUsage, PauseType pauseType, BreakPoint breakPoint)
 {
     _engine            = engine;
     CurrentNode        = currentNode;
     _currentLocation   = currentLocation;
     _returnValue       = returnValue;
     CurrentMemoryUsage = currentMemoryUsage;
     PauseType          = pauseType;
     BreakPoint         = breakPoint;
 }
コード例 #6
0
 public void DoGameOver(string text)
 {
     if (isGameRunning)
     {
         TogglePause(() => {
             this.pauseType      = PauseType.MENU;
             gameOverMenu.Header = text;
             gameOverMenu.gameObject.SetActive(true);
         });
     }
 }
コード例 #7
0
 public void unpause(PauseType type)
 {
     if (pauseStack.Count > 0 && pauseStack.Peek() == type)
     {
         pauseStack.Pop();
         unpauseEvent.Invoke(getPriority());
     }
     else
     {
         throw new System.Exception("Received unpause type of priority: " + (int)type + " when current priority is: " + getPriority());
     }
 }
コード例 #8
0
ファイル: PauseDisplay.cs プロジェクト: KHCmaster/PPD
 private void ChangePauseType(int dn)
 {
     pausetype += dn;
     if (pausetype < PauseType.Resume)
     {
         pausetype = PauseType.Return;
     }
     if (pausetype > PauseType.Return)
     {
         pausetype = PauseType.Resume;
     }
 }
コード例 #9
0
 private void TogglePause()
 {
     if (this.pauseType == PauseType.NOT_PAUSED)
     {
         this.pauseType = PauseType.MENU;
     }
     else
     {
         this.pauseType = PauseType.NOT_PAUSED;
     }
     TogglePause(() => pauseMenu.SetActive(!isGameRunning));
 }
コード例 #10
0
    public bool IsLowerPauseType(PauseType testType)
    {
        int check = (int)PauseType.CUTSCENE | (int)PauseType.TETHER_MENU | (int)PauseType.TETHER_TRANSITION | (int)PauseType.ZOOM;

        //Debug.Log(System.Convert.ToString(check, 2).PadLeft(32, '0')); //DEBUG
        //Debug.Log(System.Convert.ToString((int)testType, 2).PadLeft(32, '0')); //DEBUG

        //if (testType == PauseType.CUTSCENE || testType == PauseType.TETHER_MENU || testType == PauseType.TETHER_TRANSITION || testType == PauseType.ZOOM)
        if (((int)testType & check) != 0)
        {
            return(true);
        }
        return(false);
    }
コード例 #11
0
    /// <summary>
    /// Exits the current pause state, moving down a level to either NONE or the backup prevPauseType
    /// </summary>
    public bool ExitPauseState()
    {
        Debug.Log("Try exit pause state");

        // Throw a warning if trying to exit while not even paused
        if (pauseType == PauseType.NONE)
        {
            Debug.LogWarning("ExitPauseState cannot exit a PauseType of NONE");
            return(false);
        }
        // Allow fully exiting pause if in one of the lower level states
        //else if ((int)pauseType == lowerPauseStates)
        else if (IsLowerPauseType(pauseType))
        {
            m_pauseType = PauseType.NONE;
            if (pauseTypeToggled != null)
            {
                pauseTypeToggled(m_pauseType);
            }
            return(true);
        }
        // When exiting a top level game pause, check whether to return to NONE or a backup pause state
        else if (pauseType == PauseType.GAME)
        {
            Debug.Log("pauseType == GAME");

            // If a backup of the previous pause state was created, load the backup
            //if ((int)prevPauseType == lowerPauseStates)
            if (IsLowerPauseType(prevPauseType))
            {
                m_pauseType = prevPauseType;
                Debug.Log("Set pause state to prevPauseState of " + prevPauseType);
            }
            else
            {
                Debug.Log("prevPauseType of " + prevPauseType + " is not a lower pause type");
                m_pauseType = PauseType.NONE;
            }

            // Reset the backup pause state
            prevPauseType = PauseType.NONE;

            if (pauseTypeToggled != null)
            {
                pauseTypeToggled(m_pauseType);
            }
            return(true);
        }
        return(false);
    }
コード例 #12
0
    public void addPause(PauseType type)
    {
        int incomingPriority = (int)type;

        if (incomingPriority > getPriority())
        {
            pauseStack.Push(type);
            pauseEvent.Invoke(incomingPriority);
        }
        else
        {
            throw new System.Exception("Incomming pause type of priority: " + incomingPriority + " when current priority is: " + getPriority());
        }
    }
コード例 #13
0
 private void ChangePauseType(int dn)
 {
     buttons[(int)pausetype].Selected = false;
     pausetype += dn;
     if (pausetype < PauseType.Resume)
     {
         pausetype = PauseType.Return;
     }
     if (pausetype > PauseType.Return)
     {
         pausetype = PauseType.Resume;
     }
     buttons[(int)pausetype].Selected = true;
 }
コード例 #14
0
ファイル: Pausing.cs プロジェクト: grasmann/ProjectSanon
 /// <summary>
 /// Resume
 /// </summary>
 /// <param name="Type"></param>
 public static void Resume(PauseType Type = PauseType.Game)
 {
     switch (Type)
     {
         case PauseType.Game:
             ResumeGame();
             game_paused = false;
             break;
         case PauseType.Enemies:
             ResumeEnemies();
             enemies_paused = false;
             break;
     }
 }
コード例 #15
0
ファイル: Pausing.cs プロジェクト: grasmann/ProjectSanon
 /// <summary>
 /// Pause
 /// </summary>
 /// <param name="Type"></param>
 public static void Pause(PauseType Type = PauseType.Game)
 {
     switch (Type)
     {
         case PauseType.Game:
             PauseGame();
             game_paused = true;
             break;
         case PauseType.Enemies:
             PauseEnemies();
             enemies_paused = true;
             break;
     }
 }
コード例 #16
0
ファイル: Pausing.cs プロジェクト: grasmann/ProjectSanon
 /// <summary>
 /// Toggle Pause
 /// </summary>
 /// <param name="Type"></param>
 public static void Toggle(PauseType Type = PauseType.Game)
 {
     switch (Type)
     {
         case PauseType.Game:
             game_paused = !game_paused;
             if (!game_paused) Resume(Type);
             if (game_paused) Pause(Type);
             break;
         case PauseType.Enemies:
             enemies_paused = !enemies_paused;
             if (!enemies_paused) Resume(Type);
             if (enemies_paused) Pause(Type);
             break;
     }
 }
コード例 #17
0
        public static string PauseName(PauseType pauseType)
        {
            switch (pauseType)
            {
            case PauseType.Timer:
                return(Properties.Resources.List_TimerPause);

            case PauseType.RestLap:
                return(Properties.Resources.List_RestLap);

            case PauseType.NonReqPoint:
                return(Properties.Resources.List_NonRequired);

            default:
                return(ZoneFiveSoftware.Common.Visuals.CommonResources.Text.LabelStoppedTime);
            }
        }
コード例 #18
0
 private void ChangePauseType(int dn)
 {
     buttons[(int)pauseType].Selected = false;
     while (true)
     {
         pauseType += dn;
         if (pauseType < PauseType.Resume)
         {
             pauseType = PauseType.Return;
         }
         if (pauseType > PauseType.Return)
         {
             pauseType = PauseType.Resume;
         }
         if (buttons[(int)pauseType].Enabled)
         {
             break;
         }
     }
     buttons[(int)pauseType].Selected = true;
 }
コード例 #19
0
    void OnPauseTypeToggled(PauseType type)
    {
        if (particles == null)
        {
            return;
        }

        Debug.Log("On Pause Type Toggled: " + type);

        // Pause
        if (!disablePausing && !particles.isPaused)
        {
            Debug.Log("Test");

            if (GameManager.inst.IsWorldPauseType(type))
            {
                Debug.Log("Test2");

                pauseSaved = true;
                particles.Pause();
                //particlesEmission.enabled = false;
            }
        }

        // Unpause
        if (pauseSaved)
        {
            if (type == PauseType.NONE || type == PauseType.ZOOM)
            {
                Debug.Log("Test 3");

                pauseSaved = false;
                particles.Play();
                //particlesEmission.enabled = true;
            }
        }
    }
コード例 #20
0
        private void Pause(PauseType type, Node node = null, Location?location = null, JsValue returnValue = null,
                           BreakPoint breakPoint     = null)
        {
            var info = new DebugInformation(
                engine: _engine,
                currentNode: node,
                currentLocation: location ?? node.Location,
                returnValue: returnValue,
                currentMemoryUsage: _engine.CurrentMemoryUsage,
                pauseType: type,
                breakPoint: breakPoint
                );

            StepMode?result = type switch
            {
                // Conventionally, sender should be DebugHandler - but Engine is more useful
                PauseType.Step => Step?.Invoke(_engine, info),
                PauseType.Break => Break?.Invoke(_engine, info),
                PauseType.DebuggerStatement => Break?.Invoke(_engine, info),
                _ => throw new ArgumentException("Invalid pause type", nameof(type))
            };

            HandleNewStepMode(result);
        }
コード例 #21
0
        // Sets the state (and pausetype) of the new menu and displays it.
        // Saves the current state to allow going back to the old menu state on unpause
        public void setState(string state)
        {
            switch (state)
            {
            case "PAUSED_training":
                this.state = MenuState.PAUSED;
                // Set the menu to settings, but save state
                PreviousMainMenu = CurrentMenu;
                CurrentMenu      = Menus.SETTINGS;
                UpdateMenu();
                // Show menu
                MenuObject.SetActive(true);
                // Change Buttons
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("MainButtons").gameObject.SetActive(false);
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("PausedButtons").gameObject.SetActive(true);
                TrainingElements.SetActive(false);
                pauseType = PauseType.TRAINING;
                break;

            case "PAUSED_coreo":
                this.state = MenuState.PAUSED;
                // Set the menu to settings, but save state
                PreviousMainMenu = CurrentMenu;
                CurrentMenu      = Menus.SETTINGS;
                UpdateMenu();
                // Show menu
                MenuObject.SetActive(true);
                // Change Buttons
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("MainButtons").gameObject.SetActive(false);
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("PausedButtons").gameObject.SetActive(true);
                CoreoElements.SetActive(false);
                pauseType = PauseType.COREO;
                break;

            case "PAUSED_record":
                this.state       = MenuState.PAUSED;
                PreviousMainMenu = CurrentMenu;
                CurrentMenu      = Menus.SETTINGS;
                UpdateMenu();
                // Show menu
                MenuObject.SetActive(true);
                // Change Buttons
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("MainButtons").gameObject.SetActive(false);
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("PausedButtons").gameObject.SetActive(true);
                RecordElements.SetActive(false);
                pauseType = PauseType.RECORD;
                break;

            case "INMAIN":
                this.state = MenuState.INMAIN;
                // Revert Menu state
                CurrentMenu = PreviousMainMenu;
                UpdateMenu();
                // Hide Menu
                MenuObject.SetActive(false);
                // change buttins
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("MainButtons").gameObject.SetActive(true);
                MenuObject.transform.Find("TitleBarHolder").Find("Buttons").Find("PausedButtons").gameObject.SetActive(false);

                switch (pauseType)
                {
                case PauseType.TRAINING:
                    TrainingElements.SetActive(true);
                    break;

                case PauseType.COREO:
                    CoreoElements.SetActive(true);
                    break;

                case PauseType.RECORD:
                    RecordElements.SetActive(true);
                    break;

                default:
                    break;
                }

                break;
            }
        }
コード例 #22
0
        private void Charger_CouplerHPSafetyChaged(object sender, SCAppConstants.CouplerHPSafety e)
        {
            try
            {
                if (DebugParameter.isPassCouplerHPSafetySignal)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"pass coupler hp safey signal,flag:{DebugParameter.isPassCouplerHPSafetySignal}");
                    return;
                }
                AUNIT charger = sender as AUNIT;
                if (charger == null)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"charger is null");
                    return;
                }
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: $"Coupler hp safyte has changed,charger id:{charger.UNIT_ID} hp safety:{e}");
                var couplers = addressesBLL.cache.LoadCouplerAddresses(charger.UNIT_ID);
                var vhs      = vehicleBLL.cache.loadAllVh();
                switch (e)
                {
                case SCAppConstants.CouplerHPSafety.NonSafety:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrSet, $"Coupler position not safety.");
                    break;

                case SCAppConstants.CouplerHPSafety.Safyte:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrReset, $"Coupler position not safety.");
                    break;
                }
                foreach (var coupler in couplers)
                {
                    string coupler_adr_id = coupler.ADR_ID;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id}, start check has vh can pass...");
                    foreach (var vh in vhs)
                    {
                        if (vh.isTcpIpConnect &&
                            (vh.MODE_STATUS == VHModeStatus.AutoRemote ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging)
                            )
                        {
                            string vh_cur_adr_id = vh.CUR_ADR_ID;
                            bool   is_walkable   = guideBLL.IsRoadWalkable(coupler_adr_id, vh_cur_adr_id);
                            if (is_walkable)
                            {
                                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                              Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id} vh current adr:{vh_cur_adr_id}, is walkable start pause/continue action");
                                string     vh_id      = vh.VEHICLE_ID;
                                PauseType  pauseType  = PauseType.Normal;
                                PauseEvent pauseEvent = PauseEvent.Pause;
                                if (e == SCAppConstants.CouplerHPSafety.Safyte)
                                {
                                    pauseEvent = PauseEvent.Continue;
                                }
                                else
                                {
                                    pauseEvent = PauseEvent.Pause;
                                }
                                //Task.Run(() =>
                                //{
                                //    try
                                //    {
                                //        vehicleService.Send.Pause(vh_id, pauseEvent, pauseType);
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //        logger.Error(ex, "Exception:");
                                //    }
                                //});
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
            }
        }
コード例 #23
0
        private void RegisterVehilceEvent()
        {
            Get["AVEHICLES/{ID}"] = (p) =>
            {
                string   vh_id    = p.ID;
                AVEHICLE vh       = SCApplication.getInstance().VehicleBLL.getVehicleByID(vh_id);
                var      response = (Response)vh.ToString();
                response.ContentType = restfulContentType;

                return(response);
            };
            Get["AVEHICLES"] = (p) =>
            {
                string          vh_id    = p.ID;
                List <AVEHICLE> vhs      = SCApplication.getInstance().getEQObjCacheManager().getAllVehicle();
                var             response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };
            //Get["AVEHICLES/(?<all>)"] = (p) =>
            Get["AVEHICLES/_search"] = (p) =>
            {
                List <AVEHICLE> vhs = null;

                foreach (string name in Request.Query)
                {
                    switch (name)
                    {
                    case "SectionID":
                        string sec_id = Request.Query[name] ?? string.Empty;
                        vhs = SCApplication.getInstance().VehicleBLL.loadVehicleBySEC_ID(sec_id);
                        break;
                    }
                }
                var response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };

            Get["metrics"] = (p) =>
            {
                int total_idle_vh_clean        = SCApplication.getInstance().VehicleBLL.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Clean);
                int total_idle_vh_Dirty        = SCApplication.getInstance().VehicleBLL.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Dirty);
                int total_cmd_is_queue_count   = SCApplication.getInstance().CMDBLL.getCMD_MCSIsQueueCount();
                int total_cmd_is_running_count = SCApplication.getInstance().CMDBLL.getCMD_MCSIsRunningCount();

                string ohxc_excute_info = string.Empty;

                StringBuilder sb = new StringBuilder();
                setOhxCContent(sb, nameof(total_idle_vh_clean), total_idle_vh_clean, "current idle clean car");
                setOhxCContent(sb, nameof(total_idle_vh_Dirty), total_idle_vh_Dirty, "current idle dirty car");
                setOhxCContent(sb, nameof(total_cmd_is_queue_count), total_cmd_is_queue_count, "cmd number being queued");
                setOhxCContent(sb, nameof(total_cmd_is_running_count), total_cmd_is_running_count, "cmd number being executed");

                var response = (Response)sb.ToString();
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ViewerUpdate"] = (p) =>
            {
                SCApplication   scApp = SCApplication.getInstance();
                List <AVEHICLE> vhs   = scApp.getEQObjCacheManager().getAllVehicle();

                //foreach (AVEHICLE vh in vhs)
                //{
                //    scApp.VehicleService.PublishVhInfo(vh, null);
                //    SpinWait.SpinUntil(() => false, 10);
                //}

                var response = (Response)"OK";
                response.ContentType = restfulContentType;
                return(response);
            };

            //Post["api/io/T2STK100T01/waitin/CST01"] = (p) =>
            //{
            //    var response = (Response)"OK";
            //    response.ContentType = restfulContentType;
            //    return response;
            //};

            Post["AVEHICLES/SendCommand"] = (p) =>
            {
                var        scApp        = SCApplication.getInstance();
                bool       isSuccess    = true;
                string     vh_id        = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string     cst_id       = Request.Query.cst_id.Value ?? Request.Form.cst_id.Value ?? string.Empty;
                string     box_id       = Request.Query.box_id.Value ?? Request.Form.box_id.Value ?? string.Empty;
                string     lot_id       = Request.Query.lot_id.Value ?? Request.Form.lot_id.Value ?? string.Empty;
                string     from_port_id = Request.Query.from_port_id.Value ?? Request.Form.from_port_id.Value ?? string.Empty;
                string     to_port_id   = Request.Query.to_port_id.Value ?? Request.Form.to_port_id.Value ?? string.Empty;
                E_CMD_TYPE e_cmd_type   = default(E_CMD_TYPE);
                string     cmd_type     = Request.Query.cmd_type.Value ?? Request.Form.cmd_type.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    ACMD_OHTC cmd_obj  = null;
                    AVEHICLE  assignVH = null;

                    assignVH  = scApp.VehicleBLL.getVehicleByID(vh_id);
                    isSuccess = assignVH != null;
                    if (isSuccess)
                    {
                        isSuccess = Enum.TryParse(cmd_type, out e_cmd_type);
                        if (isSuccess)
                        {
                            switch (e_cmd_type)
                            {
                            case E_CMD_TYPE.Move:
                            case E_CMD_TYPE.Scan:
                            case E_CMD_TYPE.Load:
                            case E_CMD_TYPE.Unload:
                            case E_CMD_TYPE.LoadUnload:
                            case E_CMD_TYPE.MoveToMTL:
                            case E_CMD_TYPE.SystemOut:
                                string from_adr = "";
                                string to_adr   = "";
                                scApp.MapBLL.getAddressID(from_port_id, out from_adr);
                                scApp.MapBLL.getAddressID(to_port_id, out to_adr);

                                scApp.CMDBLL.doCreatTransferCommand(vh_id, out cmd_obj,
                                                                    cmd_type: e_cmd_type,
                                                                    source: from_port_id,
                                                                    destination: to_port_id,
                                                                    cst_id: cst_id,
                                                                    box_id: box_id,
                                                                    lot_id: lot_id,
                                                                    source_address: from_adr,
                                                                    destination_address: to_adr,
                                                                    gen_cmd_type: SCAppConstants.GenOHxCCommandType.Manual);
                                sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info =
                                    sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                                isSuccess = check_result_info.IsSuccess;
                                result    = check_result_info.ToString();
                                if (isSuccess)
                                {
                                    isSuccess = scApp.VehicleService.doSendOHxCCmdToVh(assignVH, cmd_obj);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command to vehicle failed!";
                                    }
                                }
                                else
                                {
                                    result = "Command create failed!";
                                    //bcf.App.BCFApplication.onWarningMsg(this, new bcf.Common.LogEventArgs("Command create fail.", check_result_info.Num));
                                }
                                break;

                            case E_CMD_TYPE.Home:
                                string cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
                                //isSuccess = scApp.VehicleService.TransferRequset(vh_id, cmd_id, ActiveType.Home,
                                //                                    "", "", "", new string[0], new string[0], new string[0], new string[0],
                                //                                    "", "", "", "");
                                break;

                            case E_CMD_TYPE.Teaching:
                                isSuccess = scApp.VehicleService.TeachingRequest(vh_id, from_port_id, to_port_id);
                                break;
                            }
                        }
                        else
                        {
                            result = $"Try parse Command Type:[{cmd_type}] failed!";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendReset"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    AVEHICLE assignVH = null;

                    assignVH  = scApp.VehicleBLL.getVehicleByID(vh_id);
                    isSuccess = assignVH != null;

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.VehicleStatusRequest(vh_id, true);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = "Send vehicle status request failed.";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendCancelAbort"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                string result = string.Empty;
                //try
                //{
                //    AVEHICLE assignVH = null;

                //    assignVH = scApp.VehicleBLL.getVehicleByID(vh_id);

                //    isSuccess = assignVH != null;

                //    if (isSuccess)
                //    {
                //        string mcs_cmd_id = assignVH.MCS_CMD;
                //        if (!string.IsNullOrWhiteSpace(mcs_cmd_id))
                //        {
                //            ACMD_MCS mcs_cmd = scApp.CMDBLL.getCMD_MCSByID(mcs_cmd_id);
                //            if (mcs_cmd == null)
                //            {
                //                result = $"Can't find MCS command:[{mcs_cmd_id}] in database.";
                //            }
                //            else
                //            {
                //                CMDCancelType actType = default(CMDCancelType);
                //                if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                //                {
                //                    actType = CMDCancelType.CmdCancel;
                //                    isSuccess = scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(mcs_cmd_id, actType);
                //                    if (isSuccess) result = "OK";
                //                    else result = "Send command cancel/abort failed.";
                //                }
                //                else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                //                {
                //                    actType = CMDCancelType.CmdAbort;
                //                    isSuccess = scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(mcs_cmd_id, actType);
                //                    if (isSuccess) result = "OK";
                //                    else result = "Send command cancel/abort failed.";
                //                }
                //                else
                //                {
                //                    result = $"MCS command:[{mcs_cmd_id}] can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}";
                //                }
                //            }
                //        }
                //        else
                //        {
                //            string ohtc_cmd_id = assignVH.OHTC_CMD;
                //            if (string.IsNullOrWhiteSpace(ohtc_cmd_id))
                //            {
                //                result = $"Vehicle:[{vh_id}] do not have command.";
                //            }
                //            else
                //            {
                //                ACMD_OHTC ohtc_cmd = scApp.CMDBLL.getCMD_OHTCByID(ohtc_cmd_id);
                //                if (ohtc_cmd == null)
                //                {
                //                    result = $"Can't find vehicle command:[{ohtc_cmd_id}] in database.";
                //                }
                //                else
                //                {
                //                    CMDCancelType actType = ohtc_cmd.CMD_STAUS >= E_CMD_STATUS.Execution ? CMDCancelType.CmdAbort : CMDCancelType.CmdCancel;
                //                    isSuccess = scApp.VehicleService.doAbortCommand(assignVH, ohtc_cmd_id, actType);
                //                    if (isSuccess)
                //                    {
                //                        result = "OK";
                //                    }
                //                    else
                //                    {
                //                        result = "Send vehicle status request failed.";
                //                    }
                //                }
                //            }
                //        }
                //    }
                //    else
                //    {
                //        result = $"Vehicle :[{vh_id}] not found!";
                //    }
                //}
                //catch (Exception ex)
                //{
                //    isSuccess = false;
                //    result = "Execption happend!";
                //    logger.Error(ex, "Execption:");
                //}
                (isSuccess, result) = scApp.VehicleService.ProcessVhCmdCancelAbortRequest(vh_id);
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/PauseEvent"] = (p) =>
            {
                bool          isSuccess  = false;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                PauseEvent    pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(event_type, out pauseEvent);
                if (isSuccess)
                {
                    isSuccess = scApp.VehicleService.PauseRequest
                                    (vh_id, pauseEvent, SCAppConstants.OHxCPauseType.Normal);
                }

                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/PauseStatusChange"] = (p) =>
            {
                bool          isSuccess  = false;
                string        result     = string.Empty;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        pauseType  = Request.Query.pauseType.Value ?? Request.Form.pauseType.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                SCAppConstants.OHxCPauseType pause_type = default(SCAppConstants.OHxCPauseType);
                PauseEvent pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(pauseType, out pause_type);

                if (isSuccess)
                {
                    isSuccess = Enum.TryParse(event_type, out pauseEvent);

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.PauseRequest
                                        (vh_id, pauseEvent, pause_type);
                        if (isSuccess)
                        {
                            //AVEHICLE vh = scApp.VehicleBLL.getVehicleByID(vh_id);
                            //vh.NotifyVhStatusChange();
                            result = "OK";
                        }
                        else
                        {
                            result = $"Send pause request to vehicle:{vh_id} failed.";
                        }
                    }
                    else
                    {
                        result = $"Can't recognize Pause Event:{event_type}.";
                    }
                }
                else
                {
                    result = $"Can't recognize Pause Type:{pauseType}.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ModeStatusChange"] = (p) =>
            {
                bool          isSuccess   = false;
                string        result      = string.Empty;
                SCApplication scApp       = SCApplication.getInstance();
                string        vh_id       = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        modeStatus  = Request.Query.modeStatus.Value ?? Request.Form.modeStatus.Value ?? string.Empty;
                VHModeStatus  mode_status = default(VHModeStatus);
                isSuccess = Enum.TryParse(modeStatus, out mode_status);

                if (isSuccess)
                {
                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleBLL.updataVehicleMode(vh_id, mode_status);
                        if (isSuccess)
                        {
                            AVEHICLE vh = scApp.VehicleBLL.getVehicleByID(vh_id);
                            vh.NotifyVhStatusChange();
                            result = "OK";
                        }
                        else
                        {
                            result = $"Update vehicle:{vh_id} mode status failed.";
                        }
                    }
                }
                else
                {
                    result = $"Can't recognize mode status:{modeStatus}.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ResetAlarm"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string result    = string.Empty;
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                try
                {
                    //isSuccess = scApp.VehicleService.AlarmResetRequest(vh_id);
                    isSuccess = scApp.TransferService.OHBC_AlarmAllCleared(vh_id);
                    if (isSuccess)
                    {
                        result = "OK";
                    }
                    else
                    {
                        result = "Reset alarm failed.";
                    }
                }
                catch (Exception ex)
                {
                    result = "Reset alarm failedwith exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/Debug_Function"] = (p) =>
            {
                var    scApp      = SCApplication.getInstance();
                string result     = string.Empty;
                bool   isSuccess  = true;
                string resuleJson = string.Empty;
                using (Stream stream = Request.Body)
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
                    {
                        resuleJson = reader.ReadToEnd();
                    }
                }
                var     fun_enable         = JsonConvert.DeserializeObject(resuleJson);
                JObject jo                 = JObject.Parse(resuleJson);
                dynamic dyna               = fun_enable as dynamic;
                var     func_num           = dyna.Func_Num?.Value ?? 0;
                string  func_name          = dyna.Func_Name?.Value ?? string.Empty;
                string  vh_id              = dyna.VH_ID?.Value ?? string.Empty;
                string  cst_id             = dyna.Cst_ID?.Value ?? string.Empty;
                string  from_adr           = dyna.From_Adr?.Value ?? string.Empty;
                string  to_adr             = dyna.To_Adr?.Value ?? string.Empty;
                var     operatingMode      = dyna.OperatingMode?.Value ?? null;
                var     operatingPowerMode = dyna.OperatingPowerMode?.Value ?? null;
                var     abort_type         = dyna.Abort_Type?.Value ?? null;
                var     pauseEvent         = dyna.PauseEvent?.Value ?? null;
                var     pauseType          = dyna.PauseType?.Value ?? null;
                var     blockzoneQueue     = dyna.BlockZoneQueue?.Value ?? null;
                var     pauseFirst         = dyna.PauseFirst?.Value ?? null;
                var     seg_id             = dyna.Seg_ID?.Value ?? null;
                //string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                var noticeCar = scApp.getEQObjCacheManager().getVehicletByVHID(vh_id);
                try
                {
                    if (func_num != 0)
                    {
                        if (func_num is Int64 i)
                        {
                            switch (i)
                            {
                            case 1:
                                asyExecuteAction(scApp.VehicleService.HostBasicVersionReport, vh_id);
                                break;

                            case 2:
                                asyExecuteAction(scApp.VehicleService.HostBasicVersionReport, vh_id);
                                break;

                            case 11:
                                asyExecuteAction(scApp.VehicleService.BasicInfoReport, vh_id);
                                break;

                            case 13:
                                asyExecuteAction(scApp.VehicleService.TavellingDataReport, vh_id);
                                break;

                            case 15:
                                asyExecuteAction(scApp.VehicleService.SectionDataReport, vh_id);
                                break;

                            case 17:
                                asyExecuteAction(scApp.VehicleService.AddressDataReport, vh_id);
                                break;

                            case 19:
                                asyExecuteAction(scApp.VehicleService.ScaleDataReport, vh_id);
                                break;

                            case 21:
                                asyExecuteAction(scApp.VehicleService.ControlDataReport, vh_id);
                                break;

                            case 23:
                                asyExecuteAction(scApp.VehicleService.GuideDataReport, vh_id);
                                break;

                            case 35:
                                scApp.VehicleService.CarrierIDRenameRequset(vh_id, noticeCar.CST_ID, cst_id);
                                break;

                            case 71:
                                scApp.VehicleService.TeachingRequest(vh_id, from_adr, to_adr);
                                break;

                            case 41:
                                OperatingVHMode vhMode = (OperatingVHMode)operatingMode;
                                scApp.VehicleService.ModeChangeRequest(vh_id, vhMode);
                                break;

                            case 45:
                                OperatingPowerMode powerMode = (OperatingPowerMode)operatingPowerMode;
                                scApp.VehicleService.PowerOperatorRequest(vh_id, operatingPowerMode);
                                break;

                            case 37:
                                CMDCancelType cmdCancelType = (CMDCancelType)abort_type;
                                noticeCar.sned_Str37(noticeCar.OHTC_CMD, abort_type);
                                break;

                            case 39:
                                PauseEvent _pauseEvent = (PauseEvent)pauseEvent;
                                PauseType  _pauseType  = (PauseType)pauseType;
                                scApp.VehicleService.PauseRequest(vh_id, _pauseEvent, pauseType);
                                break;

                            case 61:
                                asyExecuteAction(scApp.VehicleService.IndividualUploadRequest, vh_id);
                                break;

                            case 63:
                                asyExecuteAction(scApp.VehicleService.IndividualChangeRequest, vh_id);
                                break;

                            case 91:
                                asyExecuteAction(scApp.VehicleService.AlarmResetRequest, vh_id);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(func_name))
                    {
                        if (func_name is string str)
                        {
                            switch (str)
                            {
                            case "btn_SendAll":
                                asyExecuteAction(scApp.VehicleService.doDataSysc, vh_id);
                                break;

                            case "btn_reset_teach_result":
                                List <ASECTION> sections = scApp.CatchDataFromDB_Section;
                                foreach (var sec in sections)
                                {
                                    if (scApp.MapBLL.resetSecTechingTime(sec.SEC_ID))
                                    {
                                        sec.LAST_TECH_TIME = null;
                                    }
                                }
                                break;

                            case "btn_cmd_override_test":
                                scApp.VehicleService.VhicleChangeThePath(vh_id, pauseFirst);
                                break;

                            case "btn_Force_FinishCmd":
                                scApp.CMDBLL.forceUpdataCmdStatus2FnishByVhID(vh_id);
                                break;

                            case "btn_Refresh_Vh_Status":
                                scApp.VehicleService.VehicleStatusRequest(vh_id, true);
                                break;

                            case "btn_forceReleaseAllBlock":
                                scApp.VehicleService.forceReleaseBlockControl(vh_id);
                                break;

                            case "btn_open_tcp_port":
                                scApp.VehicleService.startVehicleTcpIpServer(vh_id);
                                break;

                            case "btn_close_tcp_port":
                                scApp.VehicleService.stopVehicleTcpIpServer(vh_id);
                                break;

                            case "btn_changeToRemove":
                                if (!noticeCar.IS_INSTALLED)
                                {
                                    result = ($"{vh_id} is removed ready!");
                                    break;
                                }
                                scApp.VehicleService.Remove(vh_id);
                                result = $"{vh_id} remove ok";
                                break;

                            case "btn_changeToInstall":
                                if (noticeCar.IS_INSTALLED)
                                {
                                    result = ($"{vh_id} is install ready!");
                                    break;
                                }
                                scApp.VehicleService.Install(vh_id);
                                result = $"{vh_id} install ok";
                                break;

                            case "btn_changeToAutoRemote":
                                scApp.VehicleService.VehicleAutoModeCahnge(vh_id, VHModeStatus.AutoRemote);
                                break;

                            case "btn_changeToAutoLocal":
                                scApp.VehicleService.VehicleAutoModeCahnge(vh_id, VHModeStatus.AutoLocal);
                                break;

                            case "btn_forceReleaseALLBlock":
                                scApp.VehicleService.forceReleaseBlockControl();
                                break;

                            case "btn_release_block":
                                scApp.VehicleService.reCheckBlockControl(blockzoneQueue);
                                break;

                            case "btn_refresh_vh_order_in_seg":
                                var seg_obj = scApp.SegmentBLL.cache.GetSegment(seg_id);
                                seg_obj.RefreshVhOrder(scApp.VehicleBLL, scApp.SectionBLL);
                                break;

                            case "btn_portInServeice":

                                break;

                            case "btn_portOutOfServeice":

                                break;

                            default:
                                break;
                            }
                        }
                    }

                    isSuccess = scApp.VehicleService.AlarmResetRequest(vh_id);
                    if (isSuccess)
                    {
                        result = "OK";
                    }
                    else
                    {
                        result = "Reset alarm failed.";
                    }
                }
                catch (Exception ex)
                {
                    result = "Reset alarm failedwith exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["Engineer/ForceCmdFinish"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                bool   isSuccess = scApp.CMDBLL.forceUpdataCmdStatus2FnishByVhID(vh_id);
                if (isSuccess)
                {
                    var vh = scApp.VehicleBLL.getVehicleByID(vh_id);
                    vh.NotifyVhExcuteCMDStatusChange();
                }
                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ScanSelected/{UserID}"] = (p) =>
            {
                var    scApp      = SCApplication.getInstance();
                bool   isSuccess  = true;
                bool   allSuccess = true;
                string result     = string.Empty;
                //string action = p.Action.Value;
                string userid     = p.UserID.Value;
                string resultJson = string.Empty;
                using (Stream stream = Request.Body)
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
                    {
                        resultJson = reader.ReadToEnd();
                    }
                }
                dynamic d = JsonConvert.DeserializeObject(resultJson);
                //string shelf_id = d.shelf_id?.Value;
                UserOperationLog userOperationLog = new UserOperationLog()
                {
                    Action     = "ScanSelected",
                    UserID     = userid,
                    ActionTime = DateTime.Now,
                };
                try
                {
                    var shelf = d.shelf;
                    foreach (string item in shelf)
                    {
                        if (scApp.TransferService.isShelfPort(item))
                        {
                            scApp.TransferService.SetScanCmd("", "", item);
                        }
                    }
                    //foreach (var v in )
                    //{
                    //	if (isShelfPort(v.Carrier_LOC))
                    //	{
                    //		SetScanCmd("", "", v.Carrier_LOC);
                    //	}
                    //}
                    //bool enable = d.enable?.Value;
                    //string s = scApp.TransferService.Manual_ShelfEnable(shelf_id, enable);
                    isSuccess = true;
                    result    = isSuccess ? "OK" : "Update Shlef Enable failed.";
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }
                SCUtility.UserOperationLog(userOperationLog);
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ScanAll/{UserID}"] = (p) =>
            {
                var    scApp      = SCApplication.getInstance();
                bool   isSuccess  = true;
                bool   allSuccess = true;
                string result     = string.Empty;
                //string action = p.Action.Value;
                string userid     = p.UserID.Value;
                string resultJson = string.Empty;
                using (Stream stream = Request.Body)
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
                    {
                        resultJson = reader.ReadToEnd();
                    }
                }
                dynamic d = JsonConvert.DeserializeObject(resultJson);
                //string shelf_id = d.shelf_id?.Value;
                UserOperationLog userOperationLog = new UserOperationLog()
                {
                    Action     = "ScanAll",
                    UserID     = userid,
                    ActionTime = DateTime.Now,
                };
                try
                {
                    scApp.TransferService.ScanALL();
                    isSuccess = true;
                    result    = isSuccess ? "OK" : "Update Shlef Enable failed.";
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }
                SCUtility.UserOperationLog(userOperationLog);
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };
        }
コード例 #24
0
        private void addPausesAsResults(IList <ChildTrailResult> splits, int lastNormalSplit, ICollection <IValueRange <DateTime> > pauses, PauseType pauseType)
        {
            foreach (IValueRange <DateTime> v in pauses)
            {
                //Pauses could extend outside the borders
                DateTime lower = v.Lower;
                if (lower == DateTime.MinValue)
                {
                    lower = m_subResultInfo.Points[0].Time;
                }
                DateTime upper = v.Upper;
                if (upper == DateTime.MaxValue)
                {
                    upper = m_subResultInfo.Points[m_subResultInfo.Points.Count - 1].Time;
                }

                //skip very short pauses
                TimeSpan duration = upper - lower;
                if (duration < TimeSpan.FromSeconds(1) &&
                    (this.StartTime - lower < TimeSpan.FromSeconds(1) ||
                     upper - this.EndTime < TimeSpan.FromSeconds(1)))
                {
                    continue;
                }

                //Match the pause to a split
                for (int j = 0; j <= lastNormalSplit; j++)
                {
                    if (splits[j].m_subResultInfo.Points[0].Time > DateTime.MinValue &&
                        splits[j].m_subResultInfo.Points[1].Time > DateTime.MinValue &&
                        //pause is started within this split
                        (splits[j].m_subResultInfo.Points[0].Time <= lower && lower <= splits[j].m_subResultInfo.Points[1].Time ||
                         //(First) lap, ends in the split
                         /*splits[j].*/ m_subResultInfo.Points[0].Time <= upper && upper < splits[j].m_subResultInfo.Points[1].Time ||
                         //For splits we want pauses also before after first normal split
                         this.Trail.IsSplits && (
                             upper < splits[j].m_subResultInfo.Points[0].Time ||
                             j == lastNormalSplit && splits[j].m_subResultInfo.Points[1].Time < lower)))
                    {
                        TrailResultInfo  t  = new TrailResultInfo(this.m_subResultInfo.Activity, this.m_subResultInfo.Reverse);
                        TrailGPSLocation tl = new TrailGPSLocation(PausedChildTrailResult.PauseName(pauseType), false);
                        t.Points.Add(new TrailResultPoint(tl, lower, duration));
                        t.Points.Add(new TrailResultPoint(tl, upper, TimeSpan.Zero));

                        PausedChildTrailResult tr = new PausedChildTrailResult(this, splits[j], -1, t, pauseType);
                        if (pauseType == PauseType.RestLap)
                        {
                            if (this.m_lapPauseMapping.ContainsKey(v))
                            {
                                tr.m_LapInfo = this.m_lapPauseMapping[v];
                            }
                        }
                        splits.Add(tr);
                        break;
                    }
                }
            }
        }
コード例 #25
0
        private void RegisterVehilceEvent()
        {
            Get["AVEHICLES/{ID}"] = (p) =>
            {
                string   vh_id    = p.ID;
                AVEHICLE vh       = SCApplication.getInstance().VehicleBLL.cache.getVehicle(vh_id);
                var      response = (Response)vh.ToString();
                response.ContentType = restfulContentType;

                return(response);
            };
            Get["AVEHICLES"] = (p) =>
            {
                string          vh_id    = p.ID;
                List <AVEHICLE> vhs      = SCApplication.getInstance().getEQObjCacheManager().getAllVehicle();
                var             response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };
            //Get["AVEHICLES/(?<all>)"] = (p) =>
            Get["AVEHICLES/_search"] = (p) =>
            {
                List <AVEHICLE> vhs = null;

                foreach (string name in Request.Query)
                {
                    switch (name)
                    {
                    case "SectionID":
                        string sec_id = Request.Query[name] ?? string.Empty;
                        vhs = SCApplication.getInstance().VehicleBLL.cache.loadVehicleBySEC_ID(sec_id);
                        break;
                    }
                }
                var response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };

            Get["metrics"] = (p) =>
            {
                int total_idle_vh_clean        = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Clean);
                int total_idle_vh_Dirty        = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Dirty);
                int total_cmd_is_queue_count   = SCApplication.getInstance().CMDBLL.getCMD_MCSIsQueueCount();
                int total_cmd_is_running_count = SCApplication.getInstance().CMDBLL.getCMD_MCSIsRunningCount();

                string ohxc_excute_info = string.Empty;

                StringBuilder sb = new StringBuilder();
                setOhxCContent(sb, nameof(total_idle_vh_clean), total_idle_vh_clean, "current idle clean car");
                setOhxCContent(sb, nameof(total_idle_vh_Dirty), total_idle_vh_Dirty, "current idle dirty car");
                setOhxCContent(sb, nameof(total_cmd_is_queue_count), total_cmd_is_queue_count, "cmd number being queued");
                setOhxCContent(sb, nameof(total_cmd_is_running_count), total_cmd_is_running_count, "cmd number being executed");

                var response = (Response)sb.ToString();
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ViewerUpdate"] = (p) =>
            {
                SCApplication   scApp = SCApplication.getInstance();
                List <AVEHICLE> vhs   = scApp.getEQObjCacheManager().getAllVehicle();

                //foreach (AVEHICLE vh in vhs)
                //{
                //    scApp.VehicleService.PublishVhInfo(vh, null);
                //    SpinWait.SpinUntil(() => false, 10);
                //}

                var response = (Response)"OK";
                response.ContentType = restfulContentType;
                return(response);
            };

            //Post["api/io/T2STK100T01/waitin/CST01"] = (p) =>
            //{

            //    var response = (Response)"OK";
            //    response.ContentType = restfulContentType;
            //    return response;
            //};

            Post["AVEHICLES/SendCommand"] = (p) =>
            {
                var        scApp        = SCApplication.getInstance();
                bool       isSuccess    = true;
                string     vh_id        = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string     carrier_id   = Request.Query.carrier_id.Value ?? Request.Form.carrier_id.Value ?? string.Empty;
                string     from_port_id = Request.Query.from_port_id.Value ?? Request.Form.from_port_id.Value ?? string.Empty;
                string     to_port_id   = Request.Query.to_port_id.Value ?? Request.Form.to_port_id.Value ?? string.Empty;
                E_CMD_TYPE e_cmd_type   = default(E_CMD_TYPE);
                string     cmd_type     = Request.Query.cmd_type.Value ?? Request.Form.cmd_type.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    ACMD     cmd_obj  = null;
                    AVEHICLE assignVH = null;

                    assignVH  = scApp.VehicleBLL.cache.getVehicle(vh_id);
                    isSuccess = assignVH != null;
                    if (isSuccess)
                    {
                        isSuccess = Enum.TryParse(cmd_type, out e_cmd_type);
                        if (isSuccess)
                        {
                            switch (e_cmd_type)
                            {
                            case E_CMD_TYPE.Move:
                            case E_CMD_TYPE.Load:
                            case E_CMD_TYPE.Unload:
                            case E_CMD_TYPE.LoadUnload:
                                string from_adr = from_port_id;
                                string to_adr   = to_port_id;
                                //scApp.MapBLL.getAddressID(from_port_id, out from_adr);
                                //scApp.MapBLL.getAddressID(to_port_id, out to_adr);
                                scApp.CMDBLL.doCreatCommand(vh_id, out cmd_obj,
                                                            cmd_type: e_cmd_type,
                                                            source: from_adr,
                                                            destination: to_adr,
                                                            carrier_id: carrier_id,
                                                            gen_cmd_type: SCAppConstants.GenOHxCCommandType.Manual);
                                sc.BLL.CMDBLL.CommandCheckResult check_result_info =
                                    sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                                isSuccess = check_result_info.IsSuccess;
                                result    = check_result_info.ToString();
                                if (isSuccess)
                                {
                                    //isSuccess = scApp.VehicleService.doSendCommandToVh(assignVH, cmd_obj);
                                    isSuccess = scApp.VehicleService.Send.Command(assignVH, cmd_obj);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command to vehicle failed!";
                                    }
                                }
                                else
                                {
                                    result = "Command create failed!";
                                    //bcf.App.BCFApplication.onWarningMsg(this, new bcf.Common.LogEventArgs("Command create fail.", check_result_info.Num));
                                }
                                break;

                            case E_CMD_TYPE.Teaching:
                                isSuccess = scApp.VehicleService.Send.Teaching(vh_id, from_port_id, to_port_id);
                                break;
                            }
                        }
                        else
                        {
                            result = $"Try parse Command Type:[{cmd_type}] failed!";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendReset"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    AVEHICLE assignVH = null;
                    assignVH = scApp.VehicleBLL.cache.getVehicle(vh_id);

                    isSuccess = assignVH != null;

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.Send.StatusRequest(vh_id, true);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = "Send vehicle status request failed.";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendCancelAbort"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string cmd_id    = "";//todo kevin 需要指定cmd id
                string result    = string.Empty;
                try
                {
                    ACMD cmd = scApp.CMDBLL.GetCMD_OHTCByID(cmd_id);
                    if (cmd == null)
                    {
                        result    = $"Can't find command:[{cmd_id}] in database.";
                        isSuccess = false;
                    }
                    AVEHICLE assignVH = null;
                    if (isSuccess)
                    {
                        assignVH  = scApp.VehicleBLL.cache.getVehicle(vh_id);
                        isSuccess = assignVH != null;
                    }
                    if (isSuccess)
                    {
                        string mcs_cmd_id = cmd_id;
                        if (!string.IsNullOrWhiteSpace(mcs_cmd_id))
                        {
                            ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                            if (mcs_cmd == null)
                            {
                                result = $"Can't find MCS command:[{mcs_cmd_id}] in database.";
                            }
                            else
                            {
                                CancelActionType actType = default(CancelActionType);
                                if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                                {
                                    actType   = CancelActionType.CmdCancel;
                                    isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command cancel/abort failed.";
                                    }
                                }
                                else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                                {
                                    actType   = CancelActionType.CmdAbort;
                                    isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command cancel/abort failed.";
                                    }
                                }
                                else
                                {
                                    result = $"MCS command:[{mcs_cmd_id}] can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}";
                                }
                            }
                        }
                        else
                        {
                            string ohtc_cmd_id = cmd_id;
                            if (string.IsNullOrWhiteSpace(ohtc_cmd_id))
                            {
                                result = $"Vehicle:[{vh_id}] do not have command.";
                            }
                            else
                            {
                                ACMD ohtc_cmd = scApp.CMDBLL.GetCMD_OHTCByID(ohtc_cmd_id);
                                if (ohtc_cmd == null)
                                {
                                    result = $"Can't find vehicle command:[{ohtc_cmd_id}] in database.";
                                }
                                else
                                {
                                    CancelActionType actType = ohtc_cmd.CMD_STATUS >= E_CMD_STATUS.Execution ? CancelActionType.CmdAbort : CancelActionType.CmdCancel;
                                    isSuccess = scApp.VehicleService.Send.Cancel(assignVH.VEHICLE_ID, ohtc_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send vehicle status request failed.";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/PauseEvent"] = (p) =>
            {
                bool          isSuccess  = false;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                PauseEvent    pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(event_type, out pauseEvent);
                if (isSuccess)
                {
                    isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, PauseType.Normal);
                }

                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };


            Post["AVEHICLES/PauseStatusChange"] = (p) =>
            {
                bool          isSuccess  = false;
                string        result     = string.Empty;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        pauseType  = Request.Query.pauseType.Value ?? Request.Form.pauseType.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                PauseType     pause_type = default(PauseType);
                PauseEvent    pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(pauseType, out pause_type);

                if (isSuccess)
                {
                    isSuccess = Enum.TryParse(event_type, out pauseEvent);

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, pause_type);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = $"Send pause request to vehicle:{vh_id} failed.";
                        }
                    }
                    else
                    {
                        result = $"Can't recognize Pause Event:{event_type}.";
                    }
                }
                else
                {
                    result = $"Can't recognize Pause Type:{pauseType}.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ModeStatusChange"] = (p) =>
            {
                string        result      = string.Empty;
                bool          isSuccess   = false;
                SCApplication scApp       = SCApplication.getInstance();
                string        vh_id       = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        modeStatus  = Request.Query.modeStatus.Value ?? Request.Form.modeStatus.Value ?? string.Empty;
                VHModeStatus  mode_status = default(VHModeStatus);
                isSuccess = Enum.TryParse(modeStatus, out mode_status);
                try
                {
                    if (isSuccess)
                    {
                        scApp.VehicleBLL.cache.updataVehicleMode(vh_id, mode_status);
                        result = "OK";
                    }
                    else
                    {
                        result = $"Can't recognize mode status:{modeStatus}.";
                    }
                }
                catch (Exception ex)
                {
                    result = $"Update vehicle:{vh_id} mode status failed.";
                    logger.Error(ex, "Exception");
                }
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ResetAlarm"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string result    = string.Empty;
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                try
                {
                    isSuccess = scApp.VehicleService.Send.AlarmReset(vh_id);
                    if (isSuccess)
                    {
                        result = "OK";
                    }
                    else
                    {
                        result = "Reset alarm failed.";
                    }
                }
                catch (Exception ex)
                {
                    result = "Reset alarm failedwith exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["Engineer/ForceCmdFinish"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                bool   isSuccess = scApp.CMDBLL.forceUpdataCmdStatus2FnishByVhID(vh_id);
                if (isSuccess)
                {
                    var vh = scApp.VehicleBLL.cache.getVehicle(vh_id);
                    //vh.NotifyVhExcuteCMDStatusChange();
                    vh.onExcuteCommandStatusChange();
                }
                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };
        }
コード例 #26
0
 public PausedChildTrailResult(ParentTrailResult par, ChildTrailResult ctr, int order, TrailResultInfo indexes, PauseType pauseType) :
     base(par, order, indexes, 0)
 {
     this.RelatedChildResult = ctr;
     this.pauseType          = pauseType;
 }
コード例 #27
0
ファイル: ProcessingManager.cs プロジェクト: godbanyan/new
 /// <summary>
 /// 停止加工线程
 /// </summary>
 public static void StopProcess()
 {
     //如果是由试教过程停止,则先保存试教后的数据
     if (RunStatus == RunStatus.TryRunning) {
         saveModel();
     }
     //运行状态设为“停止”
     RunStatus = RunStatus.Stop;
     if (IsProcessing) {
         TryMode = TryProcessingMode.OnlyStationOne;
         //暂停模式设为不暂停
         PauseMode = PauseType.No;
         //终止加工
         processor.Abort();
         OneStationCompleted = null;
         //停止加工完成的信号输出
         RM32.SetPortIO(14, 0);
         RM32.SetPortIO(15, 0);
         IsProcessing = false;
         //停止试教监视器
         Monitor.StopDebugMonitor();
         //停止原点复归
         Servo.HomeBackEscape();
         //对伺服下达停止运动指令
         Servo.StopMove();
         spanTimer.Stop();
         //关闭主轴
         Spindle.TurnOff();
     }
 }
コード例 #28
0
 public void SetPauseType(PauseType type, bool isPause)
 {
     pauseType      = type;
     this.isPause   = isPause ? 1 : 0;
     Time.timeScale = isPause ? 0 : 1;
 }
コード例 #29
0
ファイル: PauseDisplay.cs プロジェクト: KHCmaster/PPD
 public override void Retry()
 {
     pausetype = 0;
     Hidden    = true;
 }
コード例 #30
0
ファイル: Pausing.cs プロジェクト: grasmann/ProjectSanon
 /// <summary>
 /// Check if paused
 /// </summary>
 /// <param name="Type"></param>
 /// <returns></returns>
 public static bool Paused(PauseType Type = PauseType.Game)
 {
     switch (Type)
     {
         case PauseType.Game:
             return game_paused;
         case PauseType.Enemies:
             return enemies_paused;
     }
     return false;
 }