终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

123 rindas
4.5 KiB

  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. }