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

// Strings used for machine file entries
#define X_TOOLOFFSET_ENTRY			"X"
#define Y_TOOLOFFSET_ENTRY			"Y"
#define Z_TOOLOFFSET_ENTRY			"Z"
#define TOOLRADIUS_ENTRY			"R"
#define TOOLWEAR_ENTRY				"W"
#define TOOLWEARFACTOR_ENTRY		"F"
#define TOOLORIENTATION_ENTRY		"Q"
#define TOOLDESCRIPTION_ENTRY		"DESCRIPTION"

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

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

	/// <summary>Generate configuration text for tool and place in file.</summary>
	/// <param name="cfg_file">Stream to use.</param>
	void						Configure(std::fstream& cfg_file);
	/// <summary>Convert a tool 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_TOOL; }
	/// <summary>Convert the current tool ID to a zero based index.</summary>
	/// <returns>Index.</returns>
	int							GetIndex(void) { return ConvertToIndex(m_tool_id); }
	/// <summary>Initialize a tool.</summary>
	/// <param name="new_id">Tool ID.</param>
	void						Init(int new_id);
	/// <summary>Initialize the object.</summary>
	void						Initialize(void);
	/// <summary>Save the tool 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 tool 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
	CDimension					Y;								///< Y
	CDimension					Z;								///< Z
	CDimension					R;								///< Radius
	CDimension					W;								///< Radius Wear
	CAppDouble					F;								///< Wear Factor
	CAppInt						Q;								///< 
	CAppString					Description;					///< Description
	
private:
	int							m_tool_id;						///< tool id
};

#endif			// TOOL_H
