/* $Id: ACTION.CPP 1.1 1995/07/20 11:23:36 leon Exp $
 */

#define Uses_MsgBox

#include <tvision/tv.h>


#include <stdio.h>  // sprintf()

#include <ctype.h>  // tolower()

#include <strstream.h> 



#include "gisel.h"

#include "comm.h"


/** Global settings **/
extern SettingsRec *Settings;
/** Homing speed for Home Motors command **/
extern HomingSpeedRec *HomingSpeed;
/** Current motor position in steps for X, Y and Z **/
extern long position[3];
/** Communication channel **/
extern Comm *comm;

static const int BufSize = 200;
static char Buffer[BufSize];
static strstream action(Buffer, BufSize, ios::out | ios::in);

/*
 * Returns upper or lower case letter
 */
inline char acknowledge(char c)
{
  return Settings->ack ?  toupper(c) : tolower(c);
}

#define IMMEDIATE(c) '@' << Settings->device << acknowledge(c)



void HomeMotors()
{
  action.seekp(0L);
  action << IMMEDIATE('d')
    << HomingSpeed->x << ','
   << HomingSpeed->y << ','
    << HomingSpeed->z << "\n";
  action << IMMEDIATE('7') << '\n';
  action << IMMEDIATE('r') << "7" << ends;
  comm->enqueue(action, "Home Motors");
  position[0] = position[1] = position[2] = 0;
}

void ZeroAbsolute()
{
//  action.seekp(0L);

//  action << IMMEDIATE('n') << "7"  << ends;

//  comm->enqueue(action, "Zero Absolute");

  comm->sendCommand("@0n7");
  position[0] = position[1] = position[2] = 0;
}



syntax highlighted by Code2HTML, v. 0.9.1