using System;

namespace Project
{
	[Serializable]
	public class sPositionData
	{
		public float inpositionrange { get; set; }
		public short Axis;
		public double Position { get; set; }
		public double Acc;
		public double _dcc;
		public double Dcc
		{
			get
			{
				if (_dcc == 0) return Acc;
				else return _dcc;
			}
			set
			{
				_dcc = value;
			}
		}
		public double Speed;
		public Boolean isError { get { return Speed == 0; } }
		public string Message;

		public sPositionData(sPositionData baseData)
		{
			this.Clear();
			this.Position = baseData.Position;
			this.Acc = baseData.Acc;
			this.Dcc = baseData.Dcc;
			this._dcc = baseData._dcc;
			this.Speed = baseData.Speed;
			this.Axis = baseData.Axis;
			this.Message = baseData.Message;
			this.inpositionrange = baseData.inpositionrange;
		}

		public sPositionData Clone()
		{
            return new sPositionData
            {
                Position = this.Position,
                Acc = this.Acc,
                Dcc = this.Dcc,
				//isError = this.isError,
				Message = this.Message,
				Speed = this.Speed,
				_dcc = this.Dcc,
				Axis = this.Axis,
				inpositionrange = this.inpositionrange,
			};
		}

		public sPositionData()
		{
			Clear();
		}
		public sPositionData(double pos)
		{
			Clear();
			this.Position = pos;
		}

		//public void SetPosition(double pos) { this.Position = pos; }

		public void Clear()
		{
			Axis = -1;
			inpositionrange = 0f;
			Position = 0;
			Acc = 500;
			_dcc = 0;
			Speed = 0;
			Message = "Not Set";
		}
		public override string ToString()
		{
			return $"Pos:{Position},Spd:{Speed}";
		}
	}

}
