//
//  spindle.h - machine spindle header file
//
//  $Id: spindle.h 53 2014-02-07 19:39:59Z brian $ 
//
//  Copyright (c) 1999-2014 by Precision Micro Control Corp. All rights reserved.
//
#ifndef SPINDLE_H
#define SPINDLE_H

// Strings used for machine file entries
#define SPINDLE_SECTION			"SPINDLE"

#define SPINDLE_MODE_ENTRY		"MODE"
#define SPINDLE_POLARITY_ENTRY	"POLARITY"
#define SPINDLE_SCALE_ENTRY		"SCALE"
#define SPINDLE_CONSTANT_ENTRY	"CONSTANT"
#define SPINDLE_SPEED_ENTRY		"SPEED"
#define SPINDLE_ACCEL_ENTRY		"ACCEL"
#define SPINDLE_DECEL_ENTRY		"DECEL"

/// <summary>
/// Spindle axis class
/// </summary>
class Spindle : CObject
{
public:
	/// <summary>Constructor.</summary>
	Spindle();
	/// <summary>Destructor.</summary>
	~Spindle() {}

	/// <summary>Generate configuration text for spindle and place in file.</summary>
	/// <param name="cfg_file">Stream to use.</param>
	void						Configure(std::fstream& cfg_file);
	/// <summary>Initialize the spindle object.</summary>
	/// <param name="axis_num">Cutter axxis number.</param>
	void						Initialize(int axis_num);
	/// <summary>Save the spindle settings to a machine file.</summary>
	/// <param name="ini_file">Machine file name and path.</param>
	void						SaveData(const char* ini_file);
	/// <summary>Restore the spindle settings from a machine file.</summary>
	/// <param name="ini_file">Machine file name and path.</param>
	void						RestoreData(const char* pszPathName);


	void SetCtrlrAxis(int iAxisNum) {CtrlrAxis = iAxisNum;};
	int GetCtrlrAxis() {return((int)CtrlrAxis);};
	
	double GetSpeed();
	
	const char *GetReadoutFormat() {return((const char *)ReadoutFormat);};

public:
	CAppInt CtrlrAxis;		// Motion controller axis number
	CAppInt Mode;
	CAppInt Polarity;
	CScale EncoderScale;				// Used for closed loop servo spindle
	CSpeed SpeedConstant;	// Used for open loop drive spindle
	CSpeed DefaultSpeed;
	CAcceleration Accel;
	CAcceleration Decel;
	
	CString ReadoutFormat;		// Format string for spindle's speed readout
	
};

#endif			// SPINDLE_H
