trnsport.bak

来自「a program that generates a pulse-width m」· BAK 代码 · 共 173 行

BAK
173
字号
/* Transport tasks, classes CTransport1 and CTransport2
File: trnsport.cpp

Created June 12, 1997, DM Auslander

Handles the transport of the assembled object from the assembly area
to the oven for curing of the glue, then on to the unload area where
the unload robot removes the object.

The two classes have been combined back to a single class.
*/

#include <math.h>
#include <tasks.hpp>

// States:
#define Initialize 0
#define Start 1
#define AtReady 2
#define MoveToAssy 3
#define CloseClamp 4
#define MoveToOven 5
#define Cure 6
#define MoveToUnload 7
#define OpenClamp 8
#define UnLoad 9
#define MoveToReady 10

static int InitialState = Start;

CTransport::CTransport(char *name,int aArmNo,BaseTask *aMotionTask,
    BaseTask *aClampTask,BaseTask *aUnloadRobotTask,int ProcNo)
        : BaseTask(name,ProcNo)
    {
    ClampTask = aClampTask;
    MotionTask = aMotionTask;
    UnloadRobotTask = aUnloadRobotTask;
    ArmNo = aArmNo;  // So internal functions can tell which arm
    	// this is if they have to (not currently used)
    LoadPos = 0.04;  // target positions
    ReadyPos = 0.25;
    OvenPos = 0.96;
    UnloadPos = 1.3;
    AccSlow = 0.006;  // Motion parameters
    AccFast = 0.015;
    VcSlow = 0.06;
    VcFast = 0.1;
    CreateGlobal(5);  // Create global data bases
    CreateStateNameArray(20);  // So the audit trail will have
        // state names
    RegisterStateName("Initialize",Initialize);
    RegisterStateName("Start",Start);
    RegisterStateName("AtReady",AtReady);
    RegisterStateName("MoveToAssy",MoveToAssy);
    RegisterStateName("CloseClamp",CloseClamp);
    RegisterStateName("MoveToOven",MoveToOven);
    RegisterStateName("MoveToOven",MoveToOven);
    RegisterStateName("Cure",Cure);
    RegisterStateName("MoveToUnload",MoveToUnload);
    RegisterStateName("OpenClamp",);
    RegisterStateName("UnLoad",UnLoad);
    RegisterStateName("MoveToReady",MoveToReady);
    }

int CTransport::Run(void)
    {
    int MsgIndex;
    double MsgValue;
    int done = 1;  // Default is don't ask for more scans
    NumScans++; // Increment scan count

    if (State == Initialize)
        {
        State = InitialState;
        NextState = InitialState;
        return (0);
        }
    if (NextState != -1)
        {
        // record audit trail here if desired
        AuditTrail(this, State, NextState);
        State = NextState;
        NextState = -1;
        RunEntry = 1;
        }
    else
        RunEntry = 0;

    switch (State)
        {
        case Start:
        		// Entry
            if(RunEntry)
            	{
               // Set acceleration and cruise velocity to fast
               SendMessage(MotionTask,MOTION_MSG_ACCEL,0,AccFast,
                   MESSAGE_OVERWRITE);
               SendMessage(MotionTask,MOTION_MSG_VCRUISE,0,
                   VcFast,MESSAGE_OVERWRITE);
               SendMessage(MotionTask,MOTION_CMD_NEW_PAR);
               // Send a move command to belt #1 Motion task
               SendMessage(MotionTask,MOTION_CMD_START_PROFILE,
                   TRANSPORT_MSG_MoveDone,OvenPos);

               }
            // Action
            // Test/Exit
            break;
        case AtReady:
        		// Entry
            // Action
            // Test/Exit
            break;
        case MoveToAssy:
        		// Entry
            // Action
            // Test/Exit
            break;
        case CloseClamp:
        		// Entry
            // Action
            // Test/Exit
            break;
        case MoveToOven:
        		// Entry
            if(RunEntry)
            	{
                // Set acceleration and cruise velocity to slow
                SendMessage(MotionTask,MOTION_MSG_ACCEL,0,AccSlow,
                    MESSAGE_OVERWRITE);
                SendMessage(MotionTask,MOTION_MSG_VCRUISE,0,
                    VcSlow,MESSAGE_OVERWRITE);
                SendMessage(MotionTask,MOTION_CMD_NEW_PAR);
                // Send a move command to belt #1 Motion task
                SendMessage(MotionTask,MOTION_CMD_START_PROFILE,
                    TRANSPORT_MSG_MoveDone,OvenPos);
               }
            // Action
            // Test/Exit
            break;
        case Cure:
        		// Entry
            // Action
            // Test/Exit
            break;
        case MoveToUnload:
        		// Entry
            // Action
            // Test/Exit
            break;
        case OpenClamp:
        		// Entry
            // Action
            // Test/Exit
            break;
        case UnLoad:
        		// Entry
            // Action
            // Test/Exit
            break;
        case MoveToReady:
        		// Entry
            // Action
            // Test/Exit
            break;

        default:
            StopControl("<Transport> Illegal state");
        }
    return(done);
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?