123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- //时间:20200610
- //作者:郝爽
- //功能:六孔坐标位置
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using FileManager;
- using System.Xml;
- namespace MeasureData
- {
- //六轴坐标系统
- public class SemPosition : ISlo
- {
- private float m_x, m_y, m_z, m_r, m_t, m_m;
- #region X
- //限定范围
- const float Xmax = 100;
- const float Xmin = 0;
- public float X
- {
- get { return this.m_x; }
- set => this.m_x = rangeCheckedX(value);
- }
- private static float rangeCheckedX(float x)
- {
- if (x > Xmax) x = Xmax;
- else if (x < Xmin) x = Xmin;
- return x;
- }
- #endregion
- #region Y
- //限定范围
- const float Ymax = 100;
- const float Ymin = 0;
- public float Y
- {
- get { return this.m_y; }
- set => this.m_y = rangeCheckedY(value);
- }
- private static float rangeCheckedY(float y)
- {
- if (y > Ymax) y = Ymax;
- else if (y < Ymin) y = Ymin;
- return y;
- }
- #endregion
- #region Z
- //限定范围
- const float Zmax = 100;
- const float Zmin = (float)0.005;
- public float Z
- {
- get { return this.m_z; }
- set => this.m_z = rangeCheckedZ(value);
- }
- private static float rangeCheckedZ(float z)
- {
- if (z > Zmax) z = Zmax;
- else if (z < Zmin) z = Zmin;
- return z;
- }
- #endregion
- #region R
- //限定范围
- const float Rmax = 360;
- const float Rmin = 0;
- public float R
- {
- get { return this.m_r; }
- set => this.m_r = rangeCheckedR(value);
- }
- private static float rangeCheckedR(float r)
- {
- if (r > Rmax) r = Rmax;
- else if (r < Rmin) r = Rmin;
- return r;
- }
- #endregion
- #region T
- //限定范围
- const float Tmax = 180;
- const float Tmin = 0;
- public float T
- {
- get { return this.m_t; }
- set => this.m_t = rangeCheckedT(value);
- }
- private static float rangeCheckedT(float t)
- {
- if (t > Tmax) t = Tmax;
- else if (t < Tmin) t = Tmin;
- return t;
- }
- #endregion
- #region M
- //限定范围
- const float Mmax = 100;
- const float Mmin = 0;
- public float M
- {
- get { return this.m_m; }
- set => this.m_m = rangeCheckedM(value);
- }
- private static float rangeCheckedM(float m)
- {
- if (m > Mmax) m = Mmax;
- else if (m < Mmin) m = Mmin;
- return m;
- }
- #endregion
- #region WD
- private float m_wd;
- public float WD
- {
- get { return m_wd; }
- set { this.m_wd = value; }
- }
- #endregion
- #region BeamShiftX
- private float beamShiftX;
- public float BeamShiftX
- {
- get { return beamShiftX; }
- set { this.beamShiftX = value; }
- }
- #endregion
- #region BeamShiftY
- private float beamShiftY;
- public float BeamShiftY
- {
- get { return beamShiftY; }
- set { this.beamShiftY = value; }
- }
- #endregion
- public SemPosition()
- {
- m_x = 0;
- m_y = 0;
- m_z = 0;
- m_r = 0;
- m_t = 0;
- m_m = 0;
- m_wd = 0;
- BeamShiftX = 0;
- BeamShiftY = 0;
- }
- public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
- {
- Slo slo_sp = new Slo();
- xDouble ptx = new xDouble();
- ptx.AssignValue(this.X);
- slo_sp.Register("X", ptx);
- xDouble pty = new xDouble();
- pty.AssignValue(this.Y);
- slo_sp.Register("Y", pty);
- xDouble ptz = new xDouble();
- ptz.AssignValue(this.Z);
- slo_sp.Register("Z", ptz);
- xDouble ptt = new xDouble();
- ptt.AssignValue(this.T);
- slo_sp.Register("T", ptt);
- xDouble ptr = new xDouble();
- ptr.AssignValue(this.R);
- slo_sp.Register("R", ptr);
- xDouble ptm = new xDouble();
- ptm.AssignValue(this.M);
- slo_sp.Register("M", ptm);
- xDouble ptwd = new xDouble();
- ptm.AssignValue(this.WD);
- slo_sp.Register("WD", ptwd);
- xDouble ptbsx = new xDouble();
- ptm.AssignValue(this.beamShiftX);
- slo_sp.Register("BeamShiftX", ptbsx);
- xDouble ptbsy = new xDouble();
- ptm.AssignValue(this.beamShiftY);
- slo_sp.Register("BeamShiftY", ptbsy);
- if (isStoring)
- {
- slo_sp.Serialize(true, xml, rootNode);
- }
- else
- {
- slo_sp.Serialize(false, xml, rootNode);
- this.X = (float)ptx.value();
- this.Y = (float)pty.value();
- this.Z = (float)ptz.value();
- this.T = (float)ptt.value();
- this.R = (float)ptr.value();
- this.M = (float)ptm.value();
- this.WD = (float)ptwd.value();
- this.BeamShiftX = (float)ptbsx.value();
- this.BeamShiftY = (float)ptbsy.value();
- }
- }
- }
- }
|