ParamSetingDialog.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. using PaintDotNet.Base.CommTool;
  2. using PaintDotNet.Base.SettingModel;
  3. using StageController;
  4. using StageController.M3H;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.IO.Ports;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. namespace PaintDotNet.Hardware
  18. {
  19. public delegate void SetHandler(LoadingStageModel loadingStageModel);
  20. public class ParamSetingDialog : PdnBaseForm, IStageEvent
  21. {
  22. public event SetHandler Setted;
  23. // int i = 1;
  24. LoadingStageModel loadingStageModel = null;
  25. List<LoadingStageModel.Item> lists = new List<LoadingStageModel.Item>();
  26. TableLayoutPanel table = new TableLayoutPanel();
  27. private int m_speedCheckedCnt = 0;
  28. //声明组件
  29. private System.Windows.Forms.GroupBox groupBox1;
  30. private System.Windows.Forms.GroupBox groupBox2;
  31. private System.Windows.Forms.GroupBox groupBox3;
  32. private System.Windows.Forms.GroupBox groupBox4;
  33. private System.Windows.Forms.GroupBox groupBox5;
  34. private System.Windows.Forms.Button btnClose;
  35. private System.Windows.Forms.Button btnSave;
  36. private System.Windows.Forms.GroupBox groupBox6;
  37. private System.Windows.Forms.TextBox tbxspeed;
  38. private System.Windows.Forms.Label label1;
  39. private System.Windows.Forms.Label label3;
  40. private System.Windows.Forms.TextBox tbzspeed;
  41. private System.Windows.Forms.Label label2;
  42. private System.Windows.Forms.TextBox tbyspeed;
  43. private System.Windows.Forms.Label label5;
  44. private System.Windows.Forms.Label label4;
  45. private System.Windows.Forms.TextBox tbtripx;
  46. private System.Windows.Forms.Label label8;
  47. private System.Windows.Forms.Label label9;
  48. private System.Windows.Forms.TextBox tbnav;
  49. private System.Windows.Forms.Label label6;
  50. private System.Windows.Forms.Label label7;
  51. private System.Windows.Forms.TextBox tbtripy;
  52. private System.Windows.Forms.Label label11;
  53. private System.Windows.Forms.Label label14;
  54. private System.Windows.Forms.TextBox tboecheck;
  55. private System.Windows.Forms.Label label13;
  56. private System.Windows.Forms.TextBox tbbps;
  57. private System.Windows.Forms.Label label12;
  58. private System.Windows.Forms.Button btnGetVersion;
  59. private System.Windows.Forms.Label lblVersion;
  60. private System.Windows.Forms.Label label15;
  61. private System.Windows.Forms.TextBox tbz;
  62. private System.Windows.Forms.Label label19;
  63. private System.Windows.Forms.TextBox tbxy;
  64. private System.Windows.Forms.Label label18;
  65. private System.Windows.Forms.Label label17;
  66. private System.Windows.Forms.Button btnadd;
  67. private System.Windows.Forms.Label label20;
  68. private System.Windows.Forms.ComboBox cmbPort;
  69. private DataGridView dgvSpeed;
  70. private DataGridViewCheckBoxColumn isShow;
  71. private DataGridViewTextBoxColumn name;
  72. private DataGridViewTextBoxColumn lSpeed;
  73. private DataGridViewTextBoxColumn zSpeed;
  74. private DataGridViewButtonColumn btnDel;
  75. private System.Windows.Forms.Panel panel1;
  76. private Form parentForm;
  77. private Label label10;
  78. private Label label16;
  79. private GroupBox groupBox3_HDS;
  80. private TextBox textBoxIP;
  81. private Label label23;
  82. private AxisController m_axisController;
  83. public ParamSetingDialog(Form form)
  84. {
  85. parentForm = form;
  86. InitializeComponent();
  87. InitializeLanguageText();
  88. if (!AxisController.ControllerType.Equals("HDS"))
  89. this.groupBox3_HDS.Visible = false;
  90. else
  91. {
  92. this.groupBox2.Visible = false;
  93. this.groupBox6.Location = new System.Drawing.Point(12, 74);
  94. this.groupBox6.Size = new System.Drawing.Size(382 + 243, 111);
  95. this.label11.Visible = false;
  96. int offsetX = 5;
  97. this.tbtripx.Location = new System.Drawing.Point(27 + offsetX, 20);
  98. this.tbtripy.Location = new System.Drawing.Point(27 + offsetX, 58);
  99. this.label6.Location = new System.Drawing.Point(108 + offsetX, 61);
  100. this.label5.Location = new System.Drawing.Point(108 + offsetX, 23);
  101. this.label7.Location = new System.Drawing.Point(4 + offsetX, 61);
  102. this.label4.Location = new System.Drawing.Point(4 + offsetX, 23);
  103. }
  104. loadingStageModel = Startup.instance.loadingStageModel;
  105. lists = loadingStageModel.items;
  106. try
  107. {
  108. string addrvalue = this.loadingStageModel.BaseSetAddr;
  109. this.textBoxIP.Text = addrvalue;//.ToString();
  110. }
  111. catch (Exception)
  112. { }
  113. int bpsvalue = this.loadingStageModel.BaseSetBps;
  114. string port = this.loadingStageModel.BaseSetPort;
  115. string oddevencheckvalue = this.loadingStageModel.BaseSetOddEvenCheck;
  116. string navvalue = this.loadingStageModel.TripNavWin;
  117. string tripxvalue = this.loadingStageModel.TripX;
  118. string tripyvalue = this.loadingStageModel.TripY;
  119. string stepxvalue = this.loadingStageModel.SteppingX;
  120. string stepyvalue = this.loadingStageModel.SteppingY;
  121. string stepzvalue = this.loadingStageModel.SteppingZ;
  122. //设备值存储
  123. this.tbbps.Text = bpsvalue.ToString();
  124. this.tboecheck.Text = oddevencheckvalue;
  125. //基础值存储
  126. this.tbtripx.Text = tripxvalue;
  127. this.tbtripy.Text = tripyvalue;
  128. this.tbnav.Text = navvalue;
  129. //cbport.Text
  130. this.tbxspeed.Text = stepxvalue;
  131. this.tbyspeed.Text = stepyvalue;
  132. this.tbzspeed.Text = stepzvalue;
  133. // 串口列表
  134. GetSerialLst();
  135. // 运行速度列表
  136. dgvSpeedLoad();
  137. }
  138. private void GetSerialLst()
  139. {
  140. //清除cmbPort显示
  141. cmbPort.SelectedIndex = -1;
  142. cmbPort.Items.Clear();
  143. //获取串口列表
  144. string[] serialLst = SerialPort.GetPortNames();
  145. if (serialLst.Length > 0)
  146. {
  147. //取串口列表进行排序
  148. Array.Sort(serialLst);
  149. //将串口列表输出到comboBox
  150. cmbPort.Items.AddRange(serialLst);
  151. cmbPort.SelectedIndex = 0;
  152. }
  153. }
  154. public const int WM_DEVICE_CHANGE = 0x219; //设备改变
  155. public const int DBT_DEVICEARRIVAL = 0x8000; //设备插入
  156. public const int DBT_DEVICE_REMOVE_COMPLETE = 0x8004; //设备移除
  157. //消息处理
  158. protected override void WndProc(ref Message m)
  159. {
  160. switch (m.Msg) //判断消息类型
  161. {
  162. case WM_DEVICE_CHANGE: //设备改变消息
  163. {
  164. GetSerialLst(); //设备改变时重新获取串口列表
  165. }
  166. break;
  167. }
  168. base.WndProc(ref m);
  169. }
  170. private void dgvSpeed_CellContentClick(object sender, DataGridViewCellEventArgs e)
  171. {
  172. // 修改显示是否选中
  173. if (dgvSpeed.Columns[e.ColumnIndex].Name == "isShow" && e.RowIndex >= 0)
  174. {
  175. bool selectValue = Convert.ToBoolean(dgvSpeed.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue);
  176. if (selectValue)
  177. {
  178. if (m_speedCheckedCnt < 9)
  179. {
  180. lists[e.RowIndex].SChecked = 1;
  181. m_speedCheckedCnt++;
  182. }
  183. else
  184. {
  185. dgvSpeedLoad();
  186. MessageBox.Show("最多选择9条记录");
  187. }
  188. }
  189. else
  190. {
  191. if (lists[e.RowIndex].SChecked == 1)
  192. {
  193. m_speedCheckedCnt--;
  194. }
  195. lists[e.RowIndex].SChecked = 0;
  196. if (m_speedCheckedCnt > 9)
  197. {
  198. MessageBox.Show(PdnResources.GetString("Menu.Selectupto9records.Text"));
  199. }
  200. }
  201. }
  202. //点击button按钮事件
  203. if (dgvSpeed.Columns[e.ColumnIndex].Name == "btnDel" && e.RowIndex >= 0)
  204. {
  205. DialogResult result = MessageBox.Show(PdnResources.GetString("Menu.suredeletit.Text") + "?", PdnResources.GetString("Menu.Tips.text"), MessageBoxButtons.OKCancel);
  206. if (result == DialogResult.OK)
  207. {
  208. lists.RemoveAt(e.RowIndex);
  209. //dgvSpeed.Rows.RemoveAt(e.RowIndex);
  210. dgvSpeedLoad();
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// 运行速度列表加载
  216. /// </summary>
  217. private void dgvSpeedLoad()
  218. {
  219. dgvSpeed.Columns[0].Width = 80;
  220. dgvSpeed.Columns[1].Width = 80;
  221. m_speedCheckedCnt = 0;
  222. this.dgvSpeed.Rows.Clear();
  223. foreach (LoadingStageModel.Item item in lists)
  224. {
  225. int index = this.dgvSpeed.Rows.Add();
  226. if (item.SChecked == 1)
  227. {
  228. this.dgvSpeed.Rows[index].Cells[0].Value = true;
  229. m_speedCheckedCnt++;
  230. }
  231. else
  232. {
  233. this.dgvSpeed.Rows[index].Cells[0].Value = false;
  234. }
  235. //string lspeed = ("00" + item.LSpeed);
  236. //lspeed = lspeed.Substring(lspeed.Length - 3);
  237. //string zspeed = ("00" + item.ZSpeed);
  238. //zspeed = zspeed.Substring(zspeed.Length - 3);
  239. this.dgvSpeed.Rows[index].Cells[1].Value = (index + 1).ToString();
  240. this.dgvSpeed.Rows[index].Cells[2].Value = item.LSpeed;
  241. this.dgvSpeed.Rows[index].Cells[3].Value = item.ZSpeed;
  242. }
  243. this.dgvSpeed.ClearSelection();
  244. this.dgvSpeed.CurrentCell = null;
  245. if (dgvSpeed.Rows.Count > 0)
  246. this.dgvSpeed.Rows[0].Selected = false;
  247. }
  248. private void InitializeLanguageText()
  249. {
  250. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  251. this.btnClose.Text = PdnResources.GetString("Menu.File.Close.Text");
  252. this.btnSave.Text = PdnResources.GetString("Menu.ensure.text");
  253. this.groupBox2.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.steppingaccuracy.text");
  254. this.label20.Text = PdnResources.GetString("Menu.unit.text") + ":" + PdnResources.GetString("Menu.Micron.text");
  255. this.groupBox3_HDS.Text = PdnResources.GetString("Menu.BasicSettings.text");
  256. this.groupBox3.Text = PdnResources.GetString("Menu.BasicSettings.text");
  257. this.label14.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.Paritycorrection.text") + ":";
  258. this.label13.Text = PdnResources.GetString("Menu.Baudrate.text") + ":";
  259. this.label12.Text = PdnResources.GetString("Menu.Deviceport.text") + ":";
  260. this.groupBox4.Text = PdnResources.GetString("Menu.model.text");
  261. this.btnGetVersion.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.Read.text");
  262. this.label15.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.Currentstagemodel.text") + ":";
  263. this.groupBox5.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.Speedsetting.text");
  264. this.isShow.HeaderText = PdnResources.GetString("Menu.display.text");
  265. this.lSpeed.HeaderText = PdnResources.GetString("Menu.Stage.text");
  266. this.zSpeed.HeaderText = PdnResources.GetString("Menu.Zaxis.text");
  267. this.name.HeaderText = PdnResources.GetString("Menu.name.text");
  268. this.btnDel.HeaderText = PdnResources.GetString("Menu.operation.text");
  269. this.btnDel.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  270. this.btnDel.ToolTipText = PdnResources.GetString("Menu.Edit.Delete.Text");
  271. this.btnadd.Text = PdnResources.GetString("Menu.Addto.text");
  272. this.label19.Text = PdnResources.GetString("Menu.Zaxis.text");
  273. this.label18.Text = PdnResources.GetString("Menu.Stage.text");
  274. this.label17.Text = PdnResources.GetString("Menu.Runningspeed.text") + ":";
  275. this.groupBox6.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.travel.text");
  276. this.label8.Text = PdnResources.GetString("Menu.Micron.text");
  277. this.label9.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.navigatewindow.text") + ":";
  278. this.label6.Text = PdnResources.GetString("Menu.Micron.text");
  279. this.label5.Text = PdnResources.GetString("Menu.Micron.text");
  280. this.Text = PdnResources.GetString("Menu.Hardwantrol.Locatavtion.Locationnavigationparamssettings.text");
  281. }
  282. /// <summary>
  283. /// Required method for Designer support - do not modify
  284. /// the contents of this method with the code editor.
  285. /// </summary>
  286. private void InitializeComponent()
  287. {
  288. this.groupBox1 = new System.Windows.Forms.GroupBox();
  289. this.btnClose = new System.Windows.Forms.Button();
  290. this.btnSave = new System.Windows.Forms.Button();
  291. this.groupBox2 = new System.Windows.Forms.GroupBox();
  292. this.label20 = new System.Windows.Forms.Label();
  293. this.label3 = new System.Windows.Forms.Label();
  294. this.tbzspeed = new System.Windows.Forms.TextBox();
  295. this.label2 = new System.Windows.Forms.Label();
  296. this.tbyspeed = new System.Windows.Forms.TextBox();
  297. this.label1 = new System.Windows.Forms.Label();
  298. this.tbxspeed = new System.Windows.Forms.TextBox();
  299. this.groupBox3 = new System.Windows.Forms.GroupBox();
  300. this.cmbPort = new System.Windows.Forms.ComboBox();
  301. this.label14 = new System.Windows.Forms.Label();
  302. this.tboecheck = new System.Windows.Forms.TextBox();
  303. this.label13 = new System.Windows.Forms.Label();
  304. this.tbbps = new System.Windows.Forms.TextBox();
  305. this.label12 = new System.Windows.Forms.Label();
  306. this.groupBox4 = new System.Windows.Forms.GroupBox();
  307. this.btnGetVersion = new System.Windows.Forms.Button();
  308. this.lblVersion = new System.Windows.Forms.Label();
  309. this.label15 = new System.Windows.Forms.Label();
  310. this.groupBox5 = new System.Windows.Forms.GroupBox();
  311. this.label16 = new System.Windows.Forms.Label();
  312. this.label10 = new System.Windows.Forms.Label();
  313. this.panel1 = new System.Windows.Forms.Panel();
  314. this.dgvSpeed = new System.Windows.Forms.DataGridView();
  315. this.isShow = new System.Windows.Forms.DataGridViewCheckBoxColumn();
  316. this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  317. this.lSpeed = new System.Windows.Forms.DataGridViewTextBoxColumn();
  318. this.zSpeed = new System.Windows.Forms.DataGridViewTextBoxColumn();
  319. this.btnDel = new System.Windows.Forms.DataGridViewButtonColumn();
  320. this.btnadd = new System.Windows.Forms.Button();
  321. this.tbz = new System.Windows.Forms.TextBox();
  322. this.label19 = new System.Windows.Forms.Label();
  323. this.tbxy = new System.Windows.Forms.TextBox();
  324. this.label18 = new System.Windows.Forms.Label();
  325. this.label17 = new System.Windows.Forms.Label();
  326. this.groupBox6 = new System.Windows.Forms.GroupBox();
  327. this.label11 = new System.Windows.Forms.Label();
  328. this.label8 = new System.Windows.Forms.Label();
  329. this.label6 = new System.Windows.Forms.Label();
  330. this.label9 = new System.Windows.Forms.Label();
  331. this.label7 = new System.Windows.Forms.Label();
  332. this.tbnav = new System.Windows.Forms.TextBox();
  333. this.tbtripy = new System.Windows.Forms.TextBox();
  334. this.label5 = new System.Windows.Forms.Label();
  335. this.label4 = new System.Windows.Forms.Label();
  336. this.tbtripx = new System.Windows.Forms.TextBox();
  337. this.groupBox3_HDS = new System.Windows.Forms.GroupBox();
  338. this.textBoxIP = new System.Windows.Forms.TextBox();
  339. this.label23 = new System.Windows.Forms.Label();
  340. this.groupBox1.SuspendLayout();
  341. this.groupBox2.SuspendLayout();
  342. this.groupBox3.SuspendLayout();
  343. this.groupBox4.SuspendLayout();
  344. this.groupBox5.SuspendLayout();
  345. this.panel1.SuspendLayout();
  346. ((System.ComponentModel.ISupportInitialize)(this.dgvSpeed)).BeginInit();
  347. this.groupBox6.SuspendLayout();
  348. this.groupBox3_HDS.SuspendLayout();
  349. this.SuspendLayout();
  350. //
  351. // groupBox1
  352. //
  353. this.groupBox1.Controls.Add(this.btnClose);
  354. this.groupBox1.Controls.Add(this.btnSave);
  355. this.groupBox1.Location = new System.Drawing.Point(12, 3);
  356. this.groupBox1.Name = "groupBox1";
  357. this.groupBox1.Size = new System.Drawing.Size(625, 65);
  358. this.groupBox1.TabIndex = 1;
  359. this.groupBox1.TabStop = false;
  360. this.groupBox1.Text = "操作";
  361. //
  362. // btnClose
  363. //
  364. this.btnClose.Location = new System.Drawing.Point(526, 24);
  365. this.btnClose.Name = "btnClose";
  366. this.btnClose.Size = new System.Drawing.Size(75, 23);
  367. this.btnClose.TabIndex = 1;
  368. this.btnClose.Text = "关闭";
  369. this.btnClose.UseVisualStyleBackColor = true;
  370. this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
  371. //
  372. // btnSave
  373. //
  374. this.btnSave.Location = new System.Drawing.Point(434, 24);
  375. this.btnSave.Name = "btnSave";
  376. this.btnSave.Size = new System.Drawing.Size(75, 23);
  377. this.btnSave.TabIndex = 0;
  378. this.btnSave.Text = "确定";
  379. this.btnSave.UseVisualStyleBackColor = true;
  380. this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
  381. //
  382. // groupBox2
  383. //
  384. this.groupBox2.Controls.Add(this.label20);
  385. this.groupBox2.Controls.Add(this.label3);
  386. this.groupBox2.Controls.Add(this.tbzspeed);
  387. this.groupBox2.Controls.Add(this.label2);
  388. this.groupBox2.Controls.Add(this.tbyspeed);
  389. this.groupBox2.Controls.Add(this.label1);
  390. this.groupBox2.Controls.Add(this.tbxspeed);
  391. this.groupBox2.Location = new System.Drawing.Point(12, 74);
  392. this.groupBox2.Name = "groupBox2";
  393. this.groupBox2.Size = new System.Drawing.Size(237, 111);
  394. this.groupBox2.TabIndex = 2;
  395. this.groupBox2.TabStop = false;
  396. this.groupBox2.Text = "步进精度";
  397. //
  398. // label20
  399. //
  400. this.label20.Location = new System.Drawing.Point(126, 61);
  401. this.label20.Name = "label20";
  402. this.label20.Size = new System.Drawing.Size(96, 22);
  403. this.label20.TabIndex = 12;
  404. this.label20.Text = "单位:微米";
  405. //
  406. // label3
  407. //
  408. this.label3.AutoSize = true;
  409. this.label3.Location = new System.Drawing.Point(6, 61);
  410. this.label3.Name = "label3";
  411. this.label3.Size = new System.Drawing.Size(17, 12);
  412. this.label3.TabIndex = 5;
  413. this.label3.Text = "Z:";
  414. //
  415. // tbzspeed
  416. //
  417. this.tbzspeed.Location = new System.Drawing.Point(29, 58);
  418. this.tbzspeed.Name = "tbzspeed";
  419. this.tbzspeed.Size = new System.Drawing.Size(75, 21);
  420. this.tbzspeed.TabIndex = 4;
  421. this.tbzspeed.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  422. //
  423. // label2
  424. //
  425. this.label2.AutoSize = true;
  426. this.label2.Location = new System.Drawing.Point(124, 23);
  427. this.label2.Name = "label2";
  428. this.label2.Size = new System.Drawing.Size(17, 12);
  429. this.label2.TabIndex = 3;
  430. this.label2.Text = "Y:";
  431. //
  432. // tbyspeed
  433. //
  434. this.tbyspeed.Location = new System.Drawing.Point(147, 20);
  435. this.tbyspeed.Name = "tbyspeed";
  436. this.tbyspeed.Size = new System.Drawing.Size(75, 21);
  437. this.tbyspeed.TabIndex = 2;
  438. this.tbyspeed.Text = "0.762";
  439. this.tbyspeed.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  440. //
  441. // label1
  442. //
  443. this.label1.AutoSize = true;
  444. this.label1.Location = new System.Drawing.Point(6, 23);
  445. this.label1.Name = "label1";
  446. this.label1.Size = new System.Drawing.Size(17, 12);
  447. this.label1.TabIndex = 1;
  448. this.label1.Text = "X:";
  449. //
  450. // tbxspeed
  451. //
  452. this.tbxspeed.Location = new System.Drawing.Point(29, 20);
  453. this.tbxspeed.Name = "tbxspeed";
  454. this.tbxspeed.Size = new System.Drawing.Size(75, 21);
  455. this.tbxspeed.TabIndex = 0;
  456. this.tbxspeed.Text = "0.762";
  457. this.tbxspeed.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  458. //
  459. // groupBox3
  460. //
  461. this.groupBox3.Controls.Add(this.cmbPort);
  462. this.groupBox3.Controls.Add(this.label14);
  463. this.groupBox3.Controls.Add(this.tboecheck);
  464. this.groupBox3.Controls.Add(this.label13);
  465. this.groupBox3.Controls.Add(this.tbbps);
  466. this.groupBox3.Controls.Add(this.label12);
  467. this.groupBox3.Location = new System.Drawing.Point(12, 191);
  468. this.groupBox3.Name = "groupBox3";
  469. this.groupBox3.Size = new System.Drawing.Size(625, 76);
  470. this.groupBox3.TabIndex = 3;
  471. this.groupBox3.TabStop = false;
  472. this.groupBox3.Text = "基础设置";
  473. //
  474. // cmbPort
  475. //
  476. this.cmbPort.FormattingEnabled = true;
  477. this.cmbPort.Location = new System.Drawing.Point(85, 31);
  478. this.cmbPort.Name = "cmbPort";
  479. this.cmbPort.Size = new System.Drawing.Size(81, 20);
  480. this.cmbPort.TabIndex = 12;
  481. //
  482. // label14
  483. //
  484. this.label14.Location = new System.Drawing.Point(389, 34);
  485. this.label14.Name = "label14";
  486. this.label14.Size = new System.Drawing.Size(103, 20);
  487. this.label14.TabIndex = 11;
  488. this.label14.Visible = false;
  489. //
  490. // tboecheck
  491. //
  492. this.tboecheck.Location = new System.Drawing.Point(498, 31);
  493. this.tboecheck.Name = "tboecheck";
  494. this.tboecheck.Size = new System.Drawing.Size(103, 21);
  495. this.tboecheck.TabIndex = 10;
  496. this.tboecheck.Visible = false;
  497. //
  498. // label13
  499. //
  500. this.label13.Location = new System.Drawing.Point(221, 34);
  501. this.label13.Name = "label13";
  502. this.label13.Size = new System.Drawing.Size(62, 18);
  503. this.label13.TabIndex = 9;
  504. this.label13.Text = "波特率:";
  505. //
  506. // tbbps
  507. //
  508. this.tbbps.Location = new System.Drawing.Point(289, 31);
  509. this.tbbps.Name = "tbbps";
  510. this.tbbps.Size = new System.Drawing.Size(75, 21);
  511. this.tbbps.TabIndex = 8;
  512. this.tbbps.Text = "9600";
  513. this.tbbps.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbbps_KeyPress);
  514. //
  515. // label12
  516. //
  517. this.label12.Location = new System.Drawing.Point(6, 34);
  518. this.label12.Name = "label12";
  519. this.label12.Size = new System.Drawing.Size(78, 24);
  520. this.label12.TabIndex = 7;
  521. this.label12.Text = "设备端口:";
  522. //
  523. // groupBox4
  524. //
  525. this.groupBox4.Controls.Add(this.btnGetVersion);
  526. this.groupBox4.Controls.Add(this.lblVersion);
  527. this.groupBox4.Controls.Add(this.label15);
  528. this.groupBox4.Location = new System.Drawing.Point(12, 273);
  529. this.groupBox4.Name = "groupBox4";
  530. this.groupBox4.Size = new System.Drawing.Size(625, 65);
  531. this.groupBox4.TabIndex = 4;
  532. this.groupBox4.TabStop = false;
  533. this.groupBox4.Text = "型号";
  534. //
  535. // btnGetVersion
  536. //
  537. this.btnGetVersion.Location = new System.Drawing.Point(532, 24);
  538. this.btnGetVersion.Name = "btnGetVersion";
  539. this.btnGetVersion.Size = new System.Drawing.Size(75, 23);
  540. this.btnGetVersion.TabIndex = 10;
  541. this.btnGetVersion.Text = "读取";
  542. this.btnGetVersion.UseVisualStyleBackColor = true;
  543. this.btnGetVersion.Click += new System.EventHandler(this.btnGetVersion_Click);
  544. //
  545. // lblVersion
  546. //
  547. this.lblVersion.Location = new System.Drawing.Point(136, 28);
  548. this.lblVersion.Name = "lblVersion";
  549. this.lblVersion.Size = new System.Drawing.Size(98, 19);
  550. this.lblVersion.TabIndex = 9;
  551. this.lblVersion.Text = "XXX";
  552. //
  553. // label15
  554. //
  555. this.label15.Location = new System.Drawing.Point(6, 28);
  556. this.label15.Name = "label15";
  557. this.label15.Size = new System.Drawing.Size(133, 19);
  558. this.label15.TabIndex = 8;
  559. this.label15.Text = "当前载物台型号:";
  560. //
  561. // groupBox5
  562. //
  563. this.groupBox5.Controls.Add(this.label16);
  564. this.groupBox5.Controls.Add(this.label10);
  565. this.groupBox5.Controls.Add(this.panel1);
  566. this.groupBox5.Controls.Add(this.btnadd);
  567. this.groupBox5.Controls.Add(this.tbz);
  568. this.groupBox5.Controls.Add(this.label19);
  569. this.groupBox5.Controls.Add(this.tbxy);
  570. this.groupBox5.Controls.Add(this.label18);
  571. this.groupBox5.Controls.Add(this.label17);
  572. this.groupBox5.Location = new System.Drawing.Point(12, 344);
  573. this.groupBox5.Name = "groupBox5";
  574. this.groupBox5.Size = new System.Drawing.Size(625, 361);
  575. this.groupBox5.TabIndex = 5;
  576. this.groupBox5.TabStop = false;
  577. //
  578. // label16
  579. //
  580. this.label16.AutoSize = true;
  581. this.label16.Location = new System.Drawing.Point(419, 33);
  582. this.label16.Name = "label16";
  583. this.label16.Size = new System.Drawing.Size(29, 12);
  584. this.label16.TabIndex = 18;
  585. this.label16.Text = "um/s";
  586. //
  587. // label10
  588. //
  589. this.label10.AutoSize = true;
  590. this.label10.Location = new System.Drawing.Point(386, 33);
  591. this.label10.Name = "label10";
  592. this.label10.Size = new System.Drawing.Size(35, 12);
  593. this.label10.TabIndex = 17;
  594. this.label10.Text = "Unit:";
  595. //
  596. // panel1
  597. //
  598. this.panel1.AutoScroll = true;
  599. this.panel1.Controls.Add(this.dgvSpeed);
  600. this.panel1.Location = new System.Drawing.Point(9, 62);
  601. this.panel1.Name = "panel1";
  602. this.panel1.Size = new System.Drawing.Size(610, 294);
  603. this.panel1.TabIndex = 16;
  604. //
  605. // dgvSpeed
  606. //
  607. this.dgvSpeed.AllowUserToAddRows = false;
  608. this.dgvSpeed.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  609. this.dgvSpeed.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  610. this.dgvSpeed.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  611. this.isShow,
  612. this.name,
  613. this.lSpeed,
  614. this.zSpeed,
  615. this.btnDel});
  616. this.dgvSpeed.Location = new System.Drawing.Point(4, 3);
  617. this.dgvSpeed.Name = "dgvSpeed";
  618. this.dgvSpeed.RowHeadersVisible = false;
  619. this.dgvSpeed.RowHeadersWidth = 51;
  620. this.dgvSpeed.RowTemplate.Height = 27;
  621. this.dgvSpeed.Size = new System.Drawing.Size(594, 282);
  622. this.dgvSpeed.TabIndex = 0;
  623. this.dgvSpeed.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSpeed_CellContentClick);
  624. //
  625. // isShow
  626. //
  627. this.isShow.MinimumWidth = 6;
  628. this.isShow.Name = "isShow";
  629. this.isShow.Resizable = System.Windows.Forms.DataGridViewTriState.True;
  630. this.isShow.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
  631. //
  632. // name
  633. //
  634. this.name.MinimumWidth = 6;
  635. this.name.Name = "name";
  636. this.name.ReadOnly = true;
  637. //
  638. // lSpeed
  639. //
  640. this.lSpeed.MinimumWidth = 6;
  641. this.lSpeed.Name = "lSpeed";
  642. this.lSpeed.ReadOnly = true;
  643. //
  644. // zSpeed
  645. //
  646. this.zSpeed.MinimumWidth = 6;
  647. this.zSpeed.Name = "zSpeed";
  648. this.zSpeed.ReadOnly = true;
  649. //
  650. // btnDel
  651. //
  652. this.btnDel.MinimumWidth = 6;
  653. this.btnDel.Name = "btnDel";
  654. this.btnDel.Resizable = System.Windows.Forms.DataGridViewTriState.True;
  655. this.btnDel.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
  656. //
  657. // btnadd
  658. //
  659. this.btnadd.Location = new System.Drawing.Point(531, 32);
  660. this.btnadd.Name = "btnadd";
  661. this.btnadd.Size = new System.Drawing.Size(75, 23);
  662. this.btnadd.TabIndex = 14;
  663. this.btnadd.Text = "添加";
  664. this.btnadd.UseVisualStyleBackColor = true;
  665. this.btnadd.Click += new System.EventHandler(this.btnadd_Click);
  666. //
  667. // tbz
  668. //
  669. this.tbz.Location = new System.Drawing.Point(279, 30);
  670. this.tbz.MaxLength = 3;
  671. this.tbz.Name = "tbz";
  672. this.tbz.Size = new System.Drawing.Size(80, 21);
  673. this.tbz.TabIndex = 13;
  674. this.tbz.Text = "100";
  675. this.tbz.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbz_KeyPress);
  676. //
  677. // label19
  678. //
  679. this.label19.Location = new System.Drawing.Point(246, 33);
  680. this.label19.Name = "label19";
  681. this.label19.Size = new System.Drawing.Size(36, 19);
  682. this.label19.TabIndex = 12;
  683. this.label19.Text = "Z轴";
  684. //
  685. // tbxy
  686. //
  687. this.tbxy.Location = new System.Drawing.Point(134, 30);
  688. this.tbxy.MaxLength = 3;
  689. this.tbxy.Name = "tbxy";
  690. this.tbxy.Size = new System.Drawing.Size(88, 21);
  691. this.tbxy.TabIndex = 11;
  692. this.tbxy.Text = "100";
  693. this.tbxy.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbxy_KeyPress);
  694. //
  695. // label18
  696. //
  697. this.label18.Location = new System.Drawing.Point(74, 33);
  698. this.label18.Name = "label18";
  699. this.label18.Size = new System.Drawing.Size(65, 19);
  700. this.label18.TabIndex = 10;
  701. this.label18.Text = "载物台";
  702. //
  703. // label17
  704. //
  705. this.label17.Location = new System.Drawing.Point(6, 33);
  706. this.label17.Name = "label17";
  707. this.label17.Size = new System.Drawing.Size(62, 19);
  708. this.label17.TabIndex = 9;
  709. this.label17.Text = "运行速度:";
  710. //
  711. // groupBox6
  712. //
  713. this.groupBox6.Controls.Add(this.label11);
  714. this.groupBox6.Controls.Add(this.label8);
  715. this.groupBox6.Controls.Add(this.label6);
  716. this.groupBox6.Controls.Add(this.label9);
  717. this.groupBox6.Controls.Add(this.label7);
  718. this.groupBox6.Controls.Add(this.tbnav);
  719. this.groupBox6.Controls.Add(this.tbtripy);
  720. this.groupBox6.Controls.Add(this.label5);
  721. this.groupBox6.Controls.Add(this.label4);
  722. this.groupBox6.Controls.Add(this.tbtripx);
  723. this.groupBox6.Location = new System.Drawing.Point(255, 74);
  724. this.groupBox6.Name = "groupBox6";
  725. this.groupBox6.Size = new System.Drawing.Size(382, 111);
  726. this.groupBox6.TabIndex = 3;
  727. this.groupBox6.TabStop = false;
  728. this.groupBox6.Text = "行程";
  729. //
  730. // label11
  731. //
  732. this.label11.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  733. this.label11.Location = new System.Drawing.Point(143, 20);
  734. this.label11.Name = "label11";
  735. this.label11.Size = new System.Drawing.Size(2, 81);
  736. this.label11.TabIndex = 18;
  737. //
  738. // label8
  739. //
  740. this.label8.AutoSize = true;
  741. this.label8.Location = new System.Drawing.Point(331, 79);
  742. this.label8.Name = "label8";
  743. this.label8.Size = new System.Drawing.Size(0, 12);
  744. this.label8.TabIndex = 12;
  745. this.label8.Visible = false;
  746. //
  747. // label6
  748. //
  749. this.label6.AutoSize = true;
  750. this.label6.Location = new System.Drawing.Point(108, 61);
  751. this.label6.Name = "label6";
  752. this.label6.Size = new System.Drawing.Size(29, 12);
  753. this.label6.TabIndex = 9;
  754. this.label6.Text = "微米";
  755. //
  756. // label9
  757. //
  758. this.label9.Location = new System.Drawing.Point(162, 79);
  759. this.label9.Name = "label9";
  760. this.label9.Size = new System.Drawing.Size(86, 22);
  761. this.label9.TabIndex = 11;
  762. this.label9.Visible = false;
  763. //
  764. // label7
  765. //
  766. this.label7.AutoSize = true;
  767. this.label7.Location = new System.Drawing.Point(4, 61);
  768. this.label7.Name = "label7";
  769. this.label7.Size = new System.Drawing.Size(17, 12);
  770. this.label7.TabIndex = 8;
  771. this.label7.Text = "Y:";
  772. //
  773. // tbnav
  774. //
  775. this.tbnav.Location = new System.Drawing.Point(250, 76);
  776. this.tbnav.Name = "tbnav";
  777. this.tbnav.Size = new System.Drawing.Size(75, 21);
  778. this.tbnav.TabIndex = 10;
  779. this.tbnav.Visible = false;
  780. this.tbnav.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  781. //
  782. // tbtripy
  783. //
  784. this.tbtripy.Location = new System.Drawing.Point(27, 58);
  785. this.tbtripy.Name = "tbtripy";
  786. this.tbtripy.Size = new System.Drawing.Size(75, 21);
  787. this.tbtripy.TabIndex = 7;
  788. this.tbtripy.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  789. //
  790. // label5
  791. //
  792. this.label5.AutoSize = true;
  793. this.label5.Location = new System.Drawing.Point(108, 23);
  794. this.label5.Name = "label5";
  795. this.label5.Size = new System.Drawing.Size(29, 12);
  796. this.label5.TabIndex = 6;
  797. this.label5.Text = "微米";
  798. //
  799. // label4
  800. //
  801. this.label4.AutoSize = true;
  802. this.label4.Location = new System.Drawing.Point(4, 23);
  803. this.label4.Name = "label4";
  804. this.label4.Size = new System.Drawing.Size(17, 12);
  805. this.label4.TabIndex = 5;
  806. this.label4.Text = "X:";
  807. //
  808. // tbtripx
  809. //
  810. this.tbtripx.Location = new System.Drawing.Point(27, 20);
  811. this.tbtripx.Name = "tbtripx";
  812. this.tbtripx.Size = new System.Drawing.Size(75, 21);
  813. this.tbtripx.TabIndex = 4;
  814. this.tbtripx.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckKeyPress);
  815. //
  816. // groupBox3_HDS
  817. //
  818. this.groupBox3_HDS.Controls.Add(this.textBoxIP);
  819. this.groupBox3_HDS.Controls.Add(this.label23);
  820. this.groupBox3_HDS.Location = new System.Drawing.Point(12, 191);
  821. this.groupBox3_HDS.Name = "groupBox3_HDS";
  822. this.groupBox3_HDS.Size = new System.Drawing.Size(625, 76);
  823. this.groupBox3_HDS.TabIndex = 13;
  824. this.groupBox3_HDS.TabStop = false;
  825. this.groupBox3_HDS.Text = "基础设置";
  826. //
  827. // textBoxIP
  828. //
  829. this.textBoxIP.Location = new System.Drawing.Point(76, 31);
  830. this.textBoxIP.Name = "textBoxIP";
  831. this.textBoxIP.Size = new System.Drawing.Size(161, 21);
  832. this.textBoxIP.TabIndex = 10;
  833. this.textBoxIP.Text = "10.0.0.100";
  834. //
  835. // label23
  836. //
  837. this.label23.Location = new System.Drawing.Point(6, 34);
  838. this.label23.Name = "label23";
  839. this.label23.Size = new System.Drawing.Size(78, 24);
  840. this.label23.TabIndex = 7;
  841. this.label23.Text = "设备IP:";
  842. //
  843. // ParamSetingDialog
  844. //
  845. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  846. this.ClientSize = new System.Drawing.Size(653, 711);
  847. this.Controls.Add(this.groupBox3_HDS);
  848. this.Controls.Add(this.groupBox6);
  849. this.Controls.Add(this.groupBox5);
  850. this.Controls.Add(this.groupBox4);
  851. this.Controls.Add(this.groupBox3);
  852. this.Controls.Add(this.groupBox2);
  853. this.Controls.Add(this.groupBox1);
  854. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  855. this.MaximizeBox = false;
  856. this.MinimizeBox = false;
  857. this.Name = "ParamSetingDialog";
  858. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  859. this.Text = "位置导航参数设置";
  860. this.Load += new System.EventHandler(this.ParamSetingDialog_Load);
  861. this.Controls.SetChildIndex(this.groupBox1, 0);
  862. this.Controls.SetChildIndex(this.groupBox2, 0);
  863. this.Controls.SetChildIndex(this.groupBox3, 0);
  864. this.Controls.SetChildIndex(this.groupBox4, 0);
  865. this.Controls.SetChildIndex(this.groupBox5, 0);
  866. this.Controls.SetChildIndex(this.groupBox6, 0);
  867. this.Controls.SetChildIndex(this.groupBox3_HDS, 0);
  868. this.groupBox1.ResumeLayout(false);
  869. this.groupBox2.ResumeLayout(false);
  870. this.groupBox2.PerformLayout();
  871. this.groupBox3.ResumeLayout(false);
  872. this.groupBox3.PerformLayout();
  873. this.groupBox4.ResumeLayout(false);
  874. this.groupBox5.ResumeLayout(false);
  875. this.groupBox5.PerformLayout();
  876. this.panel1.ResumeLayout(false);
  877. ((System.ComponentModel.ISupportInitialize)(this.dgvSpeed)).EndInit();
  878. this.groupBox6.ResumeLayout(false);
  879. this.groupBox6.PerformLayout();
  880. this.groupBox3_HDS.ResumeLayout(false);
  881. this.groupBox3_HDS.PerformLayout();
  882. this.ResumeLayout(false);
  883. }
  884. //参数设置点击了确定按钮
  885. private void btnSave_Click(object sender, EventArgs e)
  886. {
  887. //取得界面中输入的值
  888. string navvalue = this.tbnav.Text.Trim();
  889. string tripxvalue = this.tbtripx.Text.Trim();
  890. string tripyvalue = this.tbtripy.Text.Trim();
  891. string oddevencheckvalue = this.tboecheck.Text.Trim();
  892. string stepxvalue = this.tbxspeed.Text.Trim();
  893. string stepyvalue = this.tbyspeed.Text.Trim();
  894. string stepzvalue = this.tbzspeed.Text.Trim();
  895. if (string.IsNullOrEmpty(stepxvalue) || string.IsNullOrEmpty(stepyvalue) || string.IsNullOrEmpty(stepzvalue))
  896. {
  897. MessageBox.Show(PdnResources.GetString("Menu.Stepaccuracyannotbeempty.Text"));
  898. return;
  899. }
  900. if (string.IsNullOrEmpty(tripxvalue) || string.IsNullOrEmpty(tripyvalue))
  901. {
  902. MessageBox.Show(PdnResources.GetString("Menu.Theitinerarycannotbeempty.Text"));
  903. return;
  904. }
  905. if (string.IsNullOrEmpty(navvalue))
  906. {
  907. MessageBox.Show(PdnResources.GetString("Menu.henavigationwindowcannotbeempty.Text"));
  908. return;
  909. }
  910. if (AxisController.ControllerType.Equals("HDS"))
  911. {
  912. string addr = this.textBoxIP.Text.Trim();
  913. if (string.IsNullOrEmpty(addr))
  914. {
  915. MessageBox.Show(PdnResources.GetString("Menu.Thedeviceportannotbeempty.Text"));
  916. return;
  917. }
  918. //if (string.IsNullOrEmpty(bpsvalue))
  919. //{
  920. // MessageBox.Show(PdnResources.GetString("Menu.Baudrempty.text"));
  921. // return;
  922. //}
  923. //设备值存储
  924. this.loadingStageModel.BaseSetAddr = addr;
  925. }
  926. else
  927. {
  928. string bpsvalue = this.tbbps.Text.Trim();
  929. string port = this.cmbPort.Text.Trim();
  930. if (string.IsNullOrEmpty(port))
  931. {
  932. MessageBox.Show(PdnResources.GetString("Menu.Thedeviceportannotbeempty.Text"));
  933. return;
  934. }
  935. if (string.IsNullOrEmpty(bpsvalue))
  936. {
  937. MessageBox.Show(PdnResources.GetString("Menu.Baudrempty.text"));
  938. return;
  939. }
  940. //设备值存储
  941. this.loadingStageModel.BaseSetPort = port;
  942. this.loadingStageModel.BaseSetBps = int.Parse(bpsvalue);
  943. }
  944. this.loadingStageModel.BaseSetOddEvenCheck = oddevencheckvalue;
  945. //基础值存储
  946. this.loadingStageModel.TripX = tripxvalue;
  947. this.loadingStageModel.TripY = tripyvalue;
  948. this.loadingStageModel.TripNavWin = navvalue;
  949. this.loadingStageModel.SteppingX = stepxvalue;
  950. this.loadingStageModel.SteppingY = stepyvalue;
  951. this.loadingStageModel.SteppingZ = stepzvalue;
  952. string stageModelXml = XmlSerializeHelper.XmlSerialize<LoadingStageModel>(loadingStageModel);
  953. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\LoadingStage.xml";
  954. if (FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create))
  955. {
  956. if (Setted != null)
  957. {
  958. Setted(loadingStageModel);
  959. }
  960. //((LocationNavigationDialog)parentForm).ReloadingStageModel(loadingStageModel);
  961. MessageBox.Show(PdnResources.GetString("Menu.Thestagsuccessfully.text"));
  962. this.Close();
  963. }
  964. else
  965. {
  966. MessageBox.Show(PdnResources.GetString("Menu.Failedtosaveplatforminformation.Text"));
  967. }
  968. m_axisController.LoadingStageModel = loadingStageModel;
  969. }
  970. //关闭按钮点击
  971. private void btnClose_Click(object sender, EventArgs e)
  972. {
  973. this.Close();
  974. }
  975. //点击添加按钮
  976. private void btnadd_Click(object sender, EventArgs e)
  977. {
  978. loadingStageModel.items = lists;
  979. string xyvalue = this.tbxy.Text;
  980. string zvalue = this.tbz.Text;
  981. LoadingStageModel.Item it = new LoadingStageModel.Item();
  982. it.SChecked = 0;
  983. it.LSpeed = Int32.Parse(xyvalue);
  984. it.ZSpeed = Int32.Parse(zvalue);
  985. lists.Add(it);
  986. int index = this.dgvSpeed.Rows.Add();//获取新的一行
  987. string lspeed = ("00" + it.LSpeed);
  988. lspeed = lspeed.Substring(lspeed.Length - 3);
  989. string zspeed = ("00" + it.ZSpeed);
  990. zspeed = zspeed.Substring(zspeed.Length - 3);
  991. this.dgvSpeed.Rows[index].Cells[1].Value = (index + 1).ToString();
  992. this.dgvSpeed.Rows[index].Cells[2].Value = lspeed;
  993. this.dgvSpeed.Rows[index].Cells[3].Value = zspeed;
  994. }
  995. private void tbxy_KeyPress(object sender, KeyPressEventArgs e)
  996. {
  997. if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
  998. {
  999. e.Handled = true;
  1000. return;
  1001. }
  1002. }
  1003. private void tbz_KeyPress(object sender, KeyPressEventArgs e)
  1004. {
  1005. if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
  1006. {
  1007. e.Handled = true;
  1008. return;
  1009. }
  1010. }
  1011. private void tbbps_KeyPress(object sender, KeyPressEventArgs e)
  1012. {
  1013. if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
  1014. {
  1015. e.Handled = true;
  1016. return;
  1017. }
  1018. }
  1019. private void CheckKeyPress(object sender, KeyPressEventArgs e)
  1020. {
  1021. TextBox textBox = (TextBox)sender;
  1022. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
  1023. e.Handled = true;
  1024. //小数点的处理。
  1025. if ((int)e.KeyChar == 46) //小数点
  1026. {
  1027. if (textBox.Text.Length <= 0)
  1028. e.Handled = true; //小数点不能在第一位
  1029. else
  1030. {
  1031. float f, oldf;
  1032. var b1 = float.TryParse(textBox.Text, out oldf);
  1033. var b2 = float.TryParse(textBox.Text + e.KeyChar.ToString(), out f);
  1034. if (b2 == false)
  1035. {
  1036. if (b1 == true)
  1037. e.Handled = true;
  1038. else
  1039. e.Handled = false;
  1040. }
  1041. }
  1042. }
  1043. }
  1044. private void btnGetVersion_Click(object sender, EventArgs e)
  1045. {
  1046. try
  1047. {
  1048. m_axisController = AxisController.GetInstance();
  1049. if (AxisController.ControllerType.Equals("HDS"))
  1050. {
  1051. string m_ipName = this.textBoxIP.Text.Trim();//groupBox3
  1052. ((StageController.HDS.HDSController)m_axisController).Adrr = m_ipName;
  1053. m_axisController.Close();
  1054. m_axisController.Open();
  1055. if (!m_axisController.IsOpen)
  1056. {
  1057. lblVersion.Text = "";
  1058. MessageBox.Show("连接失败");
  1059. }
  1060. else
  1061. {
  1062. new Task(() =>
  1063. {
  1064. Thread.Sleep(300);
  1065. this.Invoke(new Action(() =>
  1066. {
  1067. lblVersion.Text = m_axisController.Version;
  1068. }));
  1069. }).Start();
  1070. }
  1071. }
  1072. else
  1073. {
  1074. string m_portName = this.cmbPort.Text.Trim();
  1075. int m_baudRate = int.Parse(this.tbbps.Text.Trim());
  1076. m_axisController.Open(m_portName, m_baudRate, Parity.None, 8, StopBits.One);
  1077. new Task(() =>
  1078. {
  1079. Thread.Sleep(300);
  1080. this.Invoke(new Action(() =>
  1081. {
  1082. lblVersion.Text = m_axisController.Version;
  1083. }));
  1084. }).Start();
  1085. }
  1086. }
  1087. catch (Exception ex)
  1088. {
  1089. // 串口无法打开时,打开参数设置界面
  1090. MessageBox.Show(ex.Message);
  1091. }
  1092. }
  1093. public void OnUpdatePosition()
  1094. {
  1095. // throw new NotImplementedException();
  1096. }
  1097. public void OnTimeoutConnect()
  1098. {
  1099. MessageBox.Show(PdnResources.GetString("Menu.Theconsoleresponsetimeout.Text"));
  1100. }
  1101. public void OnErrorSend()
  1102. {
  1103. MessageBox.Show(PdnResources.GetString("Menu.Replydataarsingerror.Text"));
  1104. }
  1105. private void ParamSetingDialog_Load(object sender, EventArgs e)
  1106. {
  1107. m_axisController = AxisController.GetInstance();
  1108. }
  1109. }
  1110. }