终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Form1.cs 4.5 KiB

2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using BPASmartClient.AGV.Feedback;
  2. using BPA.Helper;
  3. using BPASmartClient.HubHelper;
  4. using Newtonsoft.Json;
  5. using BPASmartClient.S7Net;
  6. using BPASmartClient.Modbus;
  7. namespace TestDemo
  8. {
  9. public partial class Form1 : Form
  10. {
  11. ModbusTcp modbus;
  12. int count = 0;
  13. SiemensHelper siemensHelper = new SiemensHelper();
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. //ActionManage.GetInstance.Register(new Action(() =>
  18. //{
  19. // label1.Text = (count++).ToString();
  20. //}), \"ֵ\");
  21. //SiemensHelper siemensHelper = new SiemensHelper();
  22. //siemensHelper.Connect(S7.Net.CpuType.S71200, "192.168.101.11");
  23. //var res = siemensHelper.ReadClass<ReadClass>(1);
  24. //siemensHelper.WriteClass(new ReadClass() { temp1 = "", temp2 = "" }, 1);
  25. //ActionManage.GetInstance.Register(new Action(() =>
  26. //{
  27. // label1.Text = (count++).ToString();
  28. //}), "ֵ");
  29. //ActionManage.GetInstance.Register(new Action(() =>
  30. //{
  31. // Console.WriteLine(\"ʼִ\");
  32. // Thread.Sleep(20000);
  33. // Console.WriteLine(\"ִ\");
  34. //}), \"\");
  35. modbus = new ModbusTcp();
  36. modbus.ModbusTcpConnect("192.168.0.100", 8001);
  37. MessageBox.Show("ջӳɹ");
  38. }
  39. private void ReadData()
  40. {
  41. textBox1.Text= modbus.ReadCoils(4201).ToString(); //ʼλ
  42. //textBox1.Text = modbus.ReadInputs(0000).ToString();
  43. }
  44. private void button1_Click(object sender, EventArgs e)
  45. {
  46. //AGVToUpSystem aGVToUpSystem = new AGVToUpSystem();
  47. //string value = JsonConvert.SerializeObject(aGVToUpSystem);
  48. ////string url = $\"http://172.16.11.118:8089/apicallback/quicktron/robotjob/report?sign={value}\";
  49. //string url = \"http://172.16.11.118:8089/apicallback/quicktron/robotjob/report\";
  50. //var res = APIHelper.GetInstance.HttpRequest(url, \"\", aGVToUpSystem, RequestType.POST);
  51. }
  52. private void button2_Click(object sender, EventArgs e)
  53. {
  54. //Upstreamrequest aGVToUpSystem = new Upstreamrequest() { agvCode=\"ZT11\" };
  55. //string value = JsonConvert.SerializeObject(aGVToUpSystem);
  56. ////string url = $\"http://172.16.11.118:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}\";
  57. //string url = $\"http://172.16.11.118:8089/apicallback/quicktron/robotjob/upstreamrequest\";
  58. //var res = APIHelper.GetInstance.HttpRequest(url, \"\", aGVToUpSystem, RequestType.POST);
  59. Upstreamrequest aGVToUpSystem = new Upstreamrequest() {};
  60. // string value = JsonConvert.SerializeObject(aGVToUpSystem);
  61. // string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}";
  62. string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest";
  63. var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST);
  64. }
  65. private void button3_Click(object sender, EventArgs e)
  66. {
  67. //ActionManage.GetInstance.Send(\"ֵ\");
  68. }
  69. private void button4_Click(object sender, EventArgs e)
  70. {
  71. Task.Run(new Action(() =>
  72. {
  73. // ActionManage.GetInstance.Send(\"\");
  74. }));
  75. }
  76. private void button5_Click(object sender, EventArgs e)
  77. {
  78. //var res = siemensHelper.ReadClass<PlcToComputer>(3);
  79. PlcToComputer tt = new PlcToComputer();
  80. for (int i = 0; i < tt.LocationFeedback.Length; i++)
  81. {
  82. tt.LocationFeedback[i] = (short)i;
  83. }
  84. siemensHelper.WriteClass(tt, 3);
  85. }
  86. /// <summary>
  87. /// д
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. private void button6_Click(object sender, EventArgs e)
  92. {
  93. modbus.WriteSingleCoil(2000,true);
  94. //modbus.WriteSingleRegister(0000,1);
  95. }
  96. /// <summary>
  97. /// ն
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void button7_Click(object sender, EventArgs e)
  102. {
  103. ReadData();
  104. }
  105. }
  106. }