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

// Strings used for machine file entries
#define X_WORKOFFSET_ENTRY		"X"
#define Y_WORKOFFSET_ENTRY		"Y"
#define Z_WORKOFFSET_ENTRY		"Z"
#define U_WORKOFFSET_ENTRY		"U"
#define V_WORKOFFSET_ENTRY		"V"
#define W_WORKOFFSET_ENTRY		"W"

// Convert Work Coordinate ID to an array index

class WorkCoord : CObject
{

public:
	/// <summary>Constructor.</summary>
	WorkCoord(int new_id = 0) { Init(new_id); }
	/// <summary>Destructor.</summary>
	~WorkCoord(void) {}

	/// <summary>Assignment operator.</summary>
	WorkCoord& operator=(const WorkCoord& rhs);

	/// <summary>Generate configuration text for work coordinates and place in file.</summary>
	/// <param name="cfg_file">Stream to use.</param>
	void						Configure(std::fstream& cfg_file);
	/// <summary>Convert a work coordinate ID to a zero-based index.</summary>
	/// <param name="id">ID to convert.</param>
	/// <returns>Index.</returns>
	static int					ConvertToIndex(int id)	{ return id - FIRST_WORKCOOR; }
	/// <summary>Convert the current work coordinate ID to a zero based index.</summary>
	/// <returns>Index.</returns>
	int							GetIndex(void) { return ConvertToIndex(m_work_coor_id); }
	/// <summary>Initialize a work coordinate.</summary>
	/// <param name="new_id">Work coordinate ID.</param>
	void						Init(int new_id);
	/// <summary>Initialize the object.</summary>
	void						Initialize(void);
	/// <summary>Save the work coordinate settings to the machine file.</summary>
	/// <param name="ini_file">Machine file name and path.</param>
	void						SaveData(const char* ini_file);
	/// <summary>Restore the vwork coordinate settings from the machine file.</summary>
	/// <param name="ini_file">Machine file name and path.</param>
	void						RestoreData(const char* ini_file);

public:
	CDimension					X;								///< X work coordinate
	CDimension					Y;								///< Y work coordinate
	CDimension					Z;								///< Z work coordinate
	CDimension					U;								///< U work coordinate
	CDimension					V;								///< V work coordinate
	CDimension					W;								///< W work coordinate
	
private:
	int							m_work_coor_id;					///< work coordinate ID
};

#endif			// WORK_COORD_H
