终端一体化运控平台
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.
 
 
 

123 lines
4.5 KiB

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