Test.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Runtime.InteropServices;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using System.Xml;
  15. using System.Xml.Linq;
  16. using EntityDataSet;
  17. using IntelligentControlForsx.ChildForms;
  18. using IntelligentControlForsx.MyControls;
  19. using IntelligentControlForsx.MyControls.windturbine;
  20. using IntelligentControlForsx.Service.HomeFormInfo;
  21. using IntelligentControlForsx.Service.HomeFormInfo.Domain;
  22. using IntelligentControlForsx.Service.ParameterFormInfo;
  23. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  24. using IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc;
  25. using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
  26. using IntelligentControlForsx.Service.WindturbineInfo;
  27. using Golden.DotNetSDK.Common;
  28. using Gyee_Control.Svc.Cache;
  29. using Gyee_Control.View;
  30. using WisdomClient;
  31. using WisdomClient.data;
  32. namespace IntelligentControlForsx.Test
  33. {
  34. public partial class Test : Form
  35. {
  36. public Test()
  37. {
  38. InitializeComponent();
  39. }
  40. private void btnMySql_Click(object sender, EventArgs e)
  41. {
  42. wisdom_cs_entity entity = new wisdom_cs_entity();
  43. IQueryable result = entity.project.Select(s => s);
  44. foreach (project item in result)
  45. {
  46. Console.WriteLine(item.NAME);
  47. }
  48. }
  49. private void btnDateToLong_Click(object sender, EventArgs e)
  50. {
  51. DateTime time = DateTime.Now;
  52. DateTime FirstTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
  53. long timeStamp = (long)(DateTime.Now - FirstTime).TotalMilliseconds;
  54. MessageBox.Show(timeStamp.ToString());
  55. }
  56. private void btnGetHomeInfo_Click(object sender, EventArgs e)
  57. {
  58. HomeFormInfoSvc svc = HomeFormInfoSvc.Instance;
  59. LeftInfo leftInfo = svc.GetLeftInfo();
  60. CenterInfo centerInfo = svc.GetCenterInfo();
  61. RightInfo rightInfo = svc.GetRightInfo();
  62. }
  63. private void btnConvert_Click(object sender, EventArgs e)
  64. {
  65. string s = "6.68229675292969";
  66. double ss = Double.Parse(s);
  67. MessageBox.Show(ss.ToString());
  68. }
  69. private void btnRef_Click(object sender, EventArgs e)
  70. {
  71. IList<string> list1 = new List<string>();
  72. RefTest(ref list1);
  73. for (int i = 0; i < list1.Count; i++)
  74. {
  75. MessageBox.Show(list1[i]);
  76. }
  77. }
  78. private void RefTest(ref IList<string> list)
  79. {
  80. list.Add("123");
  81. list.Add("456");
  82. }
  83. private void btnForeach_Click(object sender, EventArgs e)
  84. {
  85. IList<MyClass> list = new List<MyClass>();
  86. MyClass c1 = new MyClass() { id = 1, name = "name1" };
  87. MyClass c2 = new MyClass() { id = 2, name = "name2" };
  88. list.Add(c1);
  89. list.Add(c1);
  90. for (int i = 1; i < 3; i++)
  91. {
  92. var data = list.Where(s => s.id == i).FirstOrDefault();
  93. if (data != null)
  94. data.name = "wanghs";
  95. }
  96. Console.WriteLine(list[0].name);
  97. }
  98. public class MyClass
  99. {
  100. public int id { set; get; }
  101. public string name { set; get; }
  102. }
  103. private void btnGetSnap_Click(object sender, EventArgs e)
  104. {
  105. DateTime FirstTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
  106. DateTime startDateTime = DateTime.Now.AddHours(-12);
  107. long startTimeStamp = (long)(startDateTime - FirstTime).TotalMilliseconds;
  108. long endTimeStamp = (long)(DateTime.Now - FirstTime).TotalMilliseconds;
  109. List<TsData> powerList = RestfulClient.findHistorySnapByThingCodes("station", "0", Point.SSZGL, startTimeStamp, endTimeStamp, 3600);
  110. List<TsData> speedList = RestfulClient.findHistorySnapByThingCodes("station", "-1", "SSFS", startTimeStamp, endTimeStamp, 3600);
  111. MessageBox.Show(powerList.Count.ToString());
  112. MessageBox.Show(speedList.Count.ToString());
  113. }
  114. private void btnParameter_Click(object sender, EventArgs e)
  115. {
  116. ParameterFormInfoSvc svc = ParameterFormInfoSvc.Instance;
  117. //svc.BuilDicUnifromCodeList();
  118. svc.RefreshDataList("XS_FDC");
  119. }
  120. private void btnGolden_Click(object sender, EventArgs e)
  121. {
  122. string goldenConfig = ConfigurationManager.AppSettings["GoldenConnectPath"];
  123. RTDBConnection conData = new RTDBConnection(goldenConfig);
  124. conData.Open();
  125. }
  126. private void btnWindturbine_TagName_Click(object sender, EventArgs e)
  127. {
  128. }
  129. private void btnThread_Click(object sender, EventArgs e)
  130. {
  131. Thread t = new Thread(Th);
  132. t.Start();
  133. Console.WriteLine("方法执行完成");
  134. }
  135. public void Th()
  136. {
  137. for (int i = 0; i < 100; i++)
  138. {
  139. Thread.Sleep(100);
  140. Console.WriteLine(i);
  141. }
  142. }
  143. private void btnSubString_Click(object sender, EventArgs e)
  144. {
  145. IList<WindturbinePointData> list = new List<WindturbinePointData>();
  146. WindturbinePointData data1 = new WindturbinePointData();
  147. data1.WindturbineName = "SG01-01";
  148. data1.Power = 23.22;
  149. WindturbinePointData data2 = new WindturbinePointData();
  150. data2.WindturbineName = "SG01-02";
  151. data2.Power = 23.22;
  152. WindturbinePointData data3 = new WindturbinePointData();
  153. data3.WindturbineName = "SG01-110";
  154. data3.Power = 23.22;
  155. WindturbinePointData data4 = new WindturbinePointData();
  156. data4.WindturbineName = "SG01-111";
  157. data4.Power = 23.22;
  158. WindturbinePointData data5 = new WindturbinePointData();
  159. data5.WindturbineName = "SG01-09";
  160. data5.Power = 23.22;
  161. WindturbinePointData data6 = new WindturbinePointData();
  162. data6.WindturbineName = "SG01-10";
  163. data6.Power = 23.22;
  164. list.Add(data2);
  165. list.Add(data1);
  166. list.Add(data4);
  167. list.Add(data3);
  168. list.Add(data5);
  169. list.Add(data6);
  170. MessageBox.Show(list[3].WindturbineName.Substring(5, list[3].WindturbineName.Length - 5));
  171. MessageBox.Show(list[2].WindturbineName.Substring(5, list[2].WindturbineName.Length - 5));
  172. MessageBox.Show(list[0].WindturbineName.Substring(5, list[0].WindturbineName.Length - 5));
  173. MessageBox.Show(list[0].WindturbineName.Split('-').ToList()[1].ToString());
  174. MessageBox.Show(list[3].WindturbineName.Split('-').ToList()[1].ToString());
  175. for (int i = 0; i < list.Count; i++)
  176. {
  177. Console.WriteLine(list[i].WindturbineName);
  178. }
  179. Console.WriteLine("=========================================================");
  180. IList<WindturbinePointData> list2 =
  181. list.OrderBy(s => s.WindturbineName.Split('-').ToList()[1]).ToList();
  182. for (int i = 0; i < list2.Count; i++)
  183. {
  184. Console.WriteLine(list2[i].WindturbineName);
  185. }
  186. }
  187. private void btnOutMethod_Click(object sender, EventArgs e)
  188. {
  189. IList<int> numList = new List<int>();
  190. for (int i = 0; i < 30; i++)
  191. {
  192. numList.Add(i);
  193. }
  194. IList<int> list = new List<int>();
  195. bool t = OutMethodTest(numList, out list);
  196. }
  197. public bool OutMethodTest(IList<int> numList, out IList<int> oList)
  198. {
  199. oList = new List<int>();
  200. bool b = OutMetodTest2(numList, out oList);
  201. return b;
  202. }
  203. public bool OutMetodTest2(IList<int> numList, out IList<int> oddList)
  204. {
  205. oddList = new List<int>();
  206. for (int i = 0; i < numList.Count; i++)
  207. {
  208. if (numList[i] % 3 == 0)
  209. oddList.Add(numList[i]);
  210. }
  211. if (oddList.Count > 9)
  212. return true;
  213. else
  214. return false;
  215. }
  216. private void btnConnect_Click(object sender, EventArgs e)
  217. {
  218. ControlIntPtr svc = ControlIntPtr.GetControlIntPtr();
  219. svc.init();
  220. MessageBox.Show("通道建立成功");
  221. }
  222. private void btnSendCmd_Click(object sender, EventArgs e)
  223. {
  224. IntPtr ptr = ControlIntPtr.dic[""];
  225. byte[] types = new byte[] { CmdSendService.GYCP_TYPE_YT, CmdSendService.GYCP_TYPE_YT, CmdSendService.GYCP_TYPE_YK, CmdSendService.GYCP_TYPE_YK };
  226. uint[] addrs = new uint[] { 1999, 2001, 2002, 2003, 998 };
  227. float[] values = new float[] { 1, 1, 1, 1, 1 };
  228. uint length = 5;
  229. int count = CmdSendService.gycp_control(ptr, types, addrs, values, length);
  230. }
  231. private void btnForeachBreak_Click(object sender, EventArgs e)
  232. {
  233. IList<int> list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  234. foreach (int i in list)
  235. {
  236. if (i == 5)
  237. break;
  238. Console.WriteLine(i);
  239. }
  240. }
  241. private void btnPic_Click(object sender, EventArgs e)
  242. {
  243. }
  244. private void btnGroupBy_Click(object sender, EventArgs e)
  245. {
  246. IList<MyTest> list = new List<MyTest>();
  247. list.Add(new MyTest() { Name = "wanghs0", Id = 1 });
  248. list.Add(new MyTest() { Name = "wanghs1", Id = 1 });
  249. list.Add(new MyTest() { Name = "wanghs2", Id = 2 });
  250. list.Add(new MyTest() { Name = "wanghs3", Id = 2 });
  251. list.Add(new MyTest() { Name = "wanghs4", Id = 3 });
  252. var result = list.GroupBy(s => s.Id);
  253. foreach (IGrouping<int, MyTest> info in result)
  254. {
  255. List<MyTest> sl = info.ToList();
  256. for (int i = 0; i < sl.Count; i++)
  257. {
  258. Console.WriteLine(sl[i].Name);
  259. }
  260. Console.WriteLine("----------");
  261. }
  262. }
  263. private void btnUniformCodeTest_Click(object sender, EventArgs e)
  264. {
  265. DateTime t1 = DateTime.Now;
  266. CacheInfo.StationChange("SBQ_FDC");
  267. DateTime t2 = DateTime.Now;
  268. TimeSpan ts = t2 - t1;
  269. MessageBox.Show(ts.Minutes.ToString() + "分" + ts.Seconds.ToString() + "秒");
  270. }
  271. private void btnFingerCheck_Click(object sender, EventArgs e)
  272. {
  273. user u = null;
  274. FingerCheck check = new FingerCheck();
  275. check.ShowDialog();
  276. u = FingerCheck.checkSuccessUser;
  277. if (u != null)
  278. Console.WriteLine("获取到用户");
  279. else
  280. Console.WriteLine("未获取到用户");
  281. // MessageBox.Show(u.name);
  282. }
  283. private void btnGetPath_Click(object sender, EventArgs e)
  284. {
  285. DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
  286. long tt = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  287. WindturbineInfoSvc svc = WindturbineInfoSvc.Instance;
  288. svc.RefreshPointValue("SBQ_FDC", "SG01_01", "UP82_2", "BasicInfo");
  289. IList<UniformCodeInfo> list = svc.GetPointData();
  290. long ee = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  291. long re = ee - tt;
  292. MessageBox.Show("时间差:" + re);
  293. foreach (var item in list)
  294. {
  295. Console.WriteLine(item.Index + "_" + item.Name + ":" + item.PointValue);
  296. }
  297. }
  298. private void btnRegister_Click(object sender, EventArgs e)
  299. {
  300. FingerCheck check = new FingerCheck();
  301. check.ShowDialog();
  302. user adminUser = FingerCheck.checkSuccessUser;
  303. if (adminUser != null && adminUser.user_name == "admin")
  304. {
  305. // Register register = new Register();
  306. // register.ShowDialog();
  307. }
  308. else
  309. {
  310. MessageBox.Show("管理员验证失败");
  311. }
  312. }
  313. private void btnGetWindturbine_Click(object sender, EventArgs e)
  314. {
  315. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  316. {
  317. IList<windturbine> list = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == "SBQ_FDC" && s.PROJECTID == "SBQ02_GC").ToList();
  318. string str = "";
  319. for (int i = 0; i < list.Count; i++)
  320. {
  321. str = str + "'" + list[i].ID + "'" + ",";
  322. }
  323. Console.WriteLine(str);
  324. }
  325. }
  326. private void btnDic_Click(object sender, EventArgs e)
  327. {
  328. ParameterFormInfoSvc svc = ParameterFormInfoSvc.Instance;
  329. Console.WriteLine("获取成功");
  330. }
  331. private void btnArrSub_Click(object sender, EventArgs e)
  332. {
  333. int[] arr = new int[22];
  334. for (int i = 0; i < 22; i++)
  335. {
  336. arr[i] = i;
  337. }
  338. int selectCount = arr.Length / 5;
  339. int remainder = arr.Length % 5;
  340. if (remainder == 0)//如果被整除
  341. {
  342. for (int i = 0; i < selectCount; i++)
  343. {
  344. int[] subTagName = arr.Skip(5 * i).Take(5 * (i + 1)).ToArray();
  345. for (int j = 0; j < subTagName.Length; j++)
  346. {
  347. Console.WriteLine(subTagName[j]);
  348. }
  349. }
  350. }
  351. else//tagNames长度无法被1000整除
  352. {
  353. for (int i = 0; i < selectCount; i++)
  354. {
  355. int[] subTagName = arr.Skip(5 * i).Take(5 * (i + 1)).ToArray();
  356. for (int j = 0; j < subTagName.Length; j++)
  357. {
  358. Console.WriteLine(subTagName[j]);
  359. }
  360. }
  361. //将数组剩余元素进行查询
  362. int[] lastTagName = arr.Skip(5 * selectCount).Take(remainder).ToArray(); ;
  363. for (int j = 0; j < lastTagName.Length; j++)
  364. {
  365. Console.WriteLine(lastTagName[j]);
  366. }
  367. }
  368. }
  369. private void btnControlFull_Click(object sender, EventArgs e)
  370. {
  371. this.plInfo.Controls.Clear();
  372. for (int i = 0; i < 2; i++)
  373. {
  374. ControlLine line = new ControlLine();
  375. line.Name = "line" + i;
  376. line.WindturbineId = "SG01_0" + i;
  377. line.Dock = DockStyle.Top;
  378. this.plInfo.Controls.Add(line);
  379. }
  380. label1.BackColor = Color.OrangeRed;
  381. label1.ForeColor = Color.White;
  382. }
  383. private void btnChange_Click(object sender, EventArgs e)
  384. {
  385. Control[] lineArr = this.Controls.Find("line0", true);
  386. if (lineArr.Length > 0)
  387. {
  388. ControlLine controlLine = (ControlLine)lineArr[0];
  389. controlLine.WindturbineId = "SG01_111";
  390. }
  391. }
  392. private void btnToOtherPage_Click(object sender, EventArgs e)
  393. {
  394. MainTest t = new MainTest();
  395. t.Show();
  396. }
  397. private void btnIndexTest_Click(object sender, EventArgs e)
  398. {
  399. CacheInfo.StationChange("SBQ_FDC");
  400. }
  401. private void btnRestFul_Click(object sender, EventArgs e)
  402. {
  403. IList<WindturbinePointData> dataList = new List<WindturbinePointData>();
  404. System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
  405. long tt = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  406. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  407. {
  408. IList<windturbine_uniform_code> list =
  409. ctx.windturbine_uniform_code.Where(s => s.station_id == "SBQ_FDC").ToList();
  410. for (int i = 0; i < list.Count; i++)
  411. {
  412. WindturbinePointData data = new WindturbinePointData();
  413. data.WindturbineName = list[i].windturbine_id;
  414. data.StationId = list[i].station_id;
  415. Dictionary<string, TsData> dic = null;
  416. string[] arr = new[]
  417. {
  418. list[i].status_uniform_code,
  419. list[i].wind_speed_uniform_code,
  420. list[i].power_uniform_code,
  421. list[i].alternator_speed_uniform_code,
  422. list[i].lamina_speed_uniform_code,
  423. list[i].lamina_angle1_uniform_code,
  424. list[i].lamina_angle2_uniform_code,
  425. list[i].lamina_angle3_uniform_code,
  426. list[i].wind_angle_uniform_code,
  427. list[i].yaw_position_uniform_code,
  428. };
  429. dic = RestfulClient.findLatestByThingCodes("windturbine", list[i].windturbine_id, arr);
  430. foreach (var tsData in dic)
  431. {
  432. //int statusValue = Convert.ToInt32(tsData.Value.getValue());
  433. //switch (statusValue)
  434. //{
  435. // case 0:
  436. // data.Status = WindturbineStatus.Standby;
  437. // break;
  438. // case 1:
  439. // data.Status = WindturbineStatus.BuildPower;
  440. // break;
  441. // case 2:
  442. // data.Status = WindturbineStatus.FaultStop;
  443. // break;
  444. // case 3:
  445. // data.Status = WindturbineStatus.Offline;
  446. // break;
  447. // case 4:
  448. // data.Status = WindturbineStatus.Maintain;
  449. // break;
  450. //}
  451. data.WindSpeed = Convert.ToDouble(tsData.Value.getValue());
  452. dataList.Add(data);
  453. }
  454. }
  455. long ee = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  456. long re = ee - tt;
  457. MessageBox.Show("时间差:" + re);
  458. }
  459. }
  460. private void btnAdapter_Click(object sender, EventArgs e)
  461. {
  462. System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
  463. long tt = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  464. WindturbinePointDataSvc.UpdatePointData("SBQ_FDC");
  465. long ee = (DateTime.Now.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
  466. long re = ee - tt;
  467. MessageBox.Show("时间差:" + re);
  468. }
  469. private void btnAdapterSnap_Click(object sender, EventArgs e)
  470. {
  471. System.DateTime theTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
  472. DateTime startTime = new System.DateTime(2018, 10, 17);
  473. long startTimeLong = (startTime.Ticks - theTime.Ticks) / 10000; //除10000调整为13位
  474. DateTime endTime = new System.DateTime(2018, 10, 18);
  475. long endTimeLong = (endTime.Ticks - theTime.Ticks) / 10000; //除10000调整为13位
  476. IList<TsData> list = RestfulClient.findHistorySnapByTagName("SBQFJ.NX_GD_SBQF_FJ_P1_L1_001_AI0005", startTimeLong, endTimeLong, 3600);
  477. for (int i = 0; i < list.Count; i++)
  478. {
  479. string dataValue = list[i].getValue();
  480. DateTime dt = theTime.AddMilliseconds(list[i].ts);
  481. string dateTime = dt.ToString("yyyy/MM/dd HH:mm:ss:ffff");
  482. Console.WriteLine(dataValue + "=======" + dateTime);
  483. }
  484. for (int i = 0; i < list.Count; i++)
  485. {
  486. Console.WriteLine(list[i].getValue() + "+++" + list[i].ts);
  487. }
  488. }
  489. private void btnGoldenWirte_Click(object sender, EventArgs e)
  490. {
  491. }
  492. private void label1_Click(object sender, EventArgs e)
  493. {
  494. Label l = (Label)sender;
  495. MessageBox.Show(l.Name + l.Text);
  496. }
  497. private void btnControlTest_Click(object sender, EventArgs e)
  498. {
  499. UniformCodeInfo info1 = new UniformCodeInfo();
  500. info1.PointValue = "201811";
  501. info1.Unit = "Kw";
  502. info1.Name = "功率";
  503. pointValueAI1.BindData(info1);
  504. UniformCodeInfo info2 = new UniformCodeInfo();
  505. info2.PointValue = "1";
  506. info2.Unit = "";
  507. info2.Name = "故障";
  508. pointValueDI1.BindData(info2);
  509. }
  510. private void btnGetClassName_Click(object sender, EventArgs e)
  511. {
  512. MessageBox.Show(this.GetType().Name);
  513. }
  514. private void btnGetControl_Click(object sender, EventArgs e)
  515. {
  516. object obj = this.GetType().GetField("pointValueAI1", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance
  517. | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
  518. if (obj is Label)
  519. {
  520. Label l = (Label)obj;
  521. }
  522. else if (obj is PointValueAI)
  523. {
  524. PointValueAI p = (PointValueAI)obj;
  525. MessageBox.Show(obj.GetType().Name);
  526. MessageBox.Show(p.Name + p.NameString);
  527. }
  528. }
  529. private void btnNumConvert_Click(object sender, EventArgs e)
  530. {
  531. string s = "0.00";
  532. int n = Convert.ToInt32(s);
  533. MessageBox.Show(n.ToString());
  534. }
  535. private bool ConvertNum(string s)
  536. {
  537. double num = 0.0;
  538. try
  539. {
  540. num = Convert.ToDouble(s);
  541. return true;
  542. }
  543. catch (Exception)
  544. {
  545. return false;
  546. }
  547. }
  548. private void timer1_Tick(object sender, EventArgs e)
  549. {
  550. DateTime time = DateTime.Now;
  551. string timeString = time.ToString("yyyy-MM-dd hh:mm:ss");
  552. lblTime.Text = timeString;
  553. }
  554. private void button1_Click(object sender, EventArgs e)
  555. {
  556. for (int i = 0; i < 3; i++)
  557. {
  558. OutInLine ln = new OutInLine();
  559. ln.Name = "叶轮装置" + i;
  560. ln.PointName = "叶轮装置" + i;
  561. ln.Dock = DockStyle.Top;
  562. panel2.Controls.Add(ln);
  563. }
  564. }
  565. private void btnXmlRead_Click(object sender, EventArgs e)
  566. {
  567. OutInInfo info = new OutInInfo();
  568. }
  569. private void button2_Click(object sender, EventArgs e)
  570. {
  571. int num1 = Convert.ToInt32(textBox1.Text.Trim());
  572. int num2 = Convert.ToInt32(textBox2.Text.Trim());
  573. string mark = textBox3.Text.Trim();
  574. string markName = "";
  575. int result = 0;
  576. if (mark == "+")
  577. {
  578. result = num1 + num2;
  579. markName = "加法";
  580. }
  581. if (mark == "-")
  582. result = num1 - num2;
  583. if (mark == "*")
  584. result = num1 * num2;
  585. if (mark == "/")
  586. result = num1 / num2;
  587. for (int i = 0; i < 10; i++)
  588. {
  589. MessageBox.Show("做" + markName + "运算,运算数1:" + num1 + ",加数2:" + num2 + "计算结果为:" + result+"|||循环次数为第"+i);
  590. }
  591. }
  592. private void button3_Click(object sender, EventArgs e)
  593. {
  594. textBox1.Text = "测试";
  595. }
  596. private void textBox2_TextChanged(object sender, EventArgs e)
  597. {
  598. }
  599. /* public void Send()
  600. {
  601. ControlDao.GycpReceive receive = Back;
  602. IntPtr ptr = ControlDao.gycp_create("127.0.0.1", (ushort)9901, 30, 30, 20, Back, new IntPtr());
  603. byte[] types = new byte[] { ControlDao.GYCP_TYPE_YK };
  604. uint[] addrs = new uint[] { 2001 };
  605. float[] values = new float[] { 1 };
  606. uint length = 1;
  607. ControlDao.gycp_control(ptr, types, addrs, values, length);
  608. }
  609. public void Back(IntPtr types, IntPtr addrs, IntPtr errors, uint length, IntPtr arg)
  610. {
  611. Console.WriteLine("=============================");
  612. try
  613. {
  614. if (addrs != null && errors != null && length != 0)
  615. {
  616. byte[] tmp_types = new byte[length];
  617. int[] tmp_addrs = new int[length];
  618. int[] tmp_errs = new int[length];
  619. Marshal.Copy(types, tmp_types, 0, tmp_types.Length);
  620. Marshal.Copy(addrs, tmp_addrs, 0, tmp_addrs.Length);
  621. Marshal.Copy(errors, tmp_errs, 0, tmp_errs.Length);
  622. Console.WriteLine("回调成功" + tmp_addrs + "||" + tmp_errs + "||" + tmp_errs);
  623. }
  624. }
  625. catch (Exception e)
  626. {
  627. Console.WriteLine("回调异常");
  628. }
  629. }*/
  630. }
  631. public class MyTest
  632. {
  633. public string Name { set; get; }
  634. public int Id { set; get; }
  635. }
  636. }