Ejemplo n.º 1
0
        //  ███████╗██╗   ██╗███████╗███╗   ██╗████████╗███████╗
        //  ██╔════╝██║   ██║██╔════╝████╗  ██║╚══██╔══╝██╔════╝
        //  █████╗  ██║   ██║█████╗  ██╔██╗ ██║   ██║   ███████╗
        //  ██╔══╝  ╚██╗ ██╔╝██╔══╝  ██║╚██╗██║   ██║   ╚════██║
        //  ███████╗ ╚████╔╝ ███████╗██║ ╚████║   ██║   ███████║
        //  ╚══════╝  ╚═══╝  ╚══════╝╚═╝  ╚═══╝   ╚═╝   ╚══════╝
        //
        internal void RaiseActionCompletedEvent()
        {
            Action lastAction     = this.motionCursor.GetLastAction();
            int    pedingWrite    = this.writeCursor.ActionsPendingCount();
            int    pendingBuffer  = this.motionCursor.ActionsPendingCount();
            ActionCompletedArgs e = new ActionCompletedArgs(lastAction, pedingWrite + pendingBuffer, pendingBuffer);

            this.parentRobot.OnActionCompleted(e);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parse the response and decide what to do with it.
        /// </summary>
        /// <param name="res"></param>
        private void ParseResponse(string res)
        {
            // If first char is an id marker (otherwise, we can't know which action it is)
            // @TODO: this is hardcoded for ABB, do this programmatically...
            if (res[0] == ABBCommunicationProtocol.STR_MESSAGE_ID_CHAR)
            {
                // @TODO: dd some sanity here for incorrectly formatted messages
                _responseChunks = res.Split(' ');
                string idStr = _responseChunks[0].Substring(1);
                int    id    = Convert.ToInt32(idStr);
                this._motionCursor.ApplyActionsUntilId(id);
                //Console.WriteLine(_motionCursor);
                this._parentDriver.parentControl.parentRobot.OnMotionCursorUpdated(EventArgs.Empty);

                Action lastAction     = this._motionCursor.lastAction;
                int    remaining      = this._motionCursor.ActionsPending();
                ActionCompletedArgs e = new ActionCompletedArgs(lastAction, remaining);
                this._parentDriver.parentControl.parentRobot.OnActionCompleted(e);
            }
        }
Ejemplo n.º 3
0
        ///// <summary>
        ///// Parse the response and decide what to do with it. Returns true if the message was understood.
        ///// </summary>
        ///// <param name="res"></param>
        //private bool ProcessResponse(string res)
        //{
        //    // If first char is an id marker (otherwise, we can't know which action it is)
        //    // @TODO: this is hardcoded for ABB, do this programmatically...
        //    if (res[0] == URCommunicationProtocol.STR_MESSAGE_ID_CHAR)
        //    {
        //        // @TODO: dd some sanity here for incorrectly formatted messages
        //        _responseChunks = res.Split(' ');
        //        string idStr = _responseChunks[0].Substring(1);
        //        int id = Convert.ToInt32(idStr);
        //        _receivedIDs.Add(id);
        //        this._motionCursor.ApplyActionsUntilId(id);
        //        //Console.WriteLine(_motionCursor);
        //        this._parentDriver.parentControl.parentRobot.OnMotionCursorUpdated(EventArgs.Empty);

        //        Action lastAction = this._motionCursor.lastAction;
        //        int remaining = this._motionCursor.ActionsPending();
        //        ActionCompletedArgs e = new ActionCompletedArgs(lastAction, remaining);
        //        this._parentDriver.parentControl.parentRobot.OnActionCompleted(e);

        //        return true;
        //    }

        //    return false;
        //}

        private bool ProcessResponse(int id)
        {
            // Some messages actually contain several instructions (like a pop call may).
            // In this case, ids are -1 except for the last instruction, that contains the right id.
            // If an id is below 1, just ignore it.
            if (id < 1)
            {
                return(false);
            }

            _receivedIDs.Add(id);
            this._motionCursor.ApplyActionsUntilId(id);
            //Console.WriteLine(_motionCursor);
            this._parentDriver.parentControl.parentRobot.OnMotionCursorUpdated(EventArgs.Empty);

            Action lastAction     = this._motionCursor.lastAction;
            int    remaining      = this._motionCursor.ActionsPending();
            ActionCompletedArgs e = new ActionCompletedArgs(lastAction, remaining);

            this._parentDriver.parentControl.parentRobot.OnActionCompleted(e);

            return(true);
        }
Ejemplo n.º 4
0
 public static void OnActionCompleted(object sender, ActionCompletedArgs e)
 {
     wssv.WebSocketServices.Broadcast($"{{\"msg\":\"action-completed\",\"data\":[{e.RemainingActions}]}}");
 }