#include <rccl.h>
#include <stdio.h>

extern simMonitor();

extern FILE *setpClf;
extern FILE *setpJlf;
FILE *clf;
FILE *jlf;

#ifdef VXWORKS_CFG
#define main sim_
#endif

main()
{
        TRSF_PTR t;
        POS_PTR p0;
        MANIP *mnp;
        JNTS rcclpark;
        char *robotName;

        rcclSetOptions (RCCL_ERROR_EXIT | RCCL_SIMULATE);       /*(1)*/
        rcclSetInterval (100);                                  /*(2)*/

        robotName = getDefaultRobot();
        if (!getRobotPosition (rcclpark.v, "rcclpark", robotName))
         { printf ("position 'rcclpark' not defined for robot\n");
           exit(-1);
         }
        t = allocTrans (NULL, UNDEF);
        p0 = makePosition (NULL, T6, EQ, t, TL, T6);

        mnp = rcclCreate (robotName, 0);
        rcclStart();

        runMonitorFxn (mnp, simMonitor, 0);                     /*(3)*/

        movej (mnp, &rcclpark);
        waitForCompleted (mnp);
        readTrans (mnp->here, t);                               /*(4)*/

        if ((clf = fopen ("clf", "w")) == NULL)                 /*(5)*/
         { printf ("Can't open Cartesian log file 'clf'\n");
           exit (-1);
         }
        if ((jlf = fopen ("jlf", "w")) == NULL)
         { printf ("Can't open joint log file 'clf'\n");
           exit (-1);
         }
        setpJlf = jlf;
        setpClf = clf;
        rcclBlock();                                            /*(6)*/

        setMod (mnp, 'c');
        t->p.x += 100.0;                                
        move (mnp, p0);                                         
        stop (mnp, 1000.0);
        movej (mnp, &rcclpark);
        stop (mnp, 1000.0);
        waitForCompleted (mnp);                                 /*(7)*/

        setpJlf = NULL;                                         /*(8)*/
        setpClf = NULL;
        fclose (clf);
        fclose (jlf);

        rcclRelease (YES);
}
