// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved


// This software makes use of tools and libraries obtained from open source projects or released for

// use by relevant hardware manufactures. However, this software is NOT a part of any open source project.

// It is released only on a "need to know" basis for beta testers of the "RiceCNC Interpolation Engine".

// Recipents of this source code must respect the confidential nature of this software and prevent any

// distribution that could result in counterfeit copies of the "RiceCNC Interpolation Engine".


// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved

#include <SetArcVector.h>

#include <Axis.h>

#include <TorchHeightControl.h>

#include <Machine.h>


const char SetArcVector::myName[] =

     "SetArcVector";


const char*

     SetArcVector::name() {


     return

          myName; };


SetArcVector::SetArcVector( char* data ) {

     axisNameC                    = ' ';

     

     xyArcLength                    = 0.0;

     headRotationAngleRad     = 0.0;

     zArcOffset                    = 0.0;

     

     sscanf( data+3,

          "%c %f %f %f %f %f",

          &axisNameC,

          &xyArcLength,

          &headRotationAngleRad,

          &zArcOffset );


     headRotationAngleRad     *= M_PI / 180.0; };


bool

     SetArcVector::execute( Machine* machine ) {


     TorchHeightControl*     axis     =

          (TorchHeightControl*)machine->findAxis(

               axisNameC,

               NULL );


     if ( axis )

          axis->setArcVector(

               xyArcLength,

               headRotationAngleRad,

               zArcOffset );


     return

          true; };


void

     SetArcVector::report( String* msgPtr ) {


     char data[40] = "";

     if ( axis )

          snprintf( data, 40,

               " Plasma %c arc vector set\n",

               axisNameC );

     else

          snprintf( data, 40,

               "E Plasma axis %c invalid\n",

               axisNameC );


     *msgPtr += String( data ); };