You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.3 KiB
C#
187 lines
6.3 KiB
C#
using HighWayIot.Log4net;
|
|
using HighWayIot.Plc;
|
|
using HighWayIot.Plc.PlcHelper;
|
|
using HighWayIot.Repository.domain;
|
|
using HighWayIot.Repository.service;
|
|
using HighWayIot.Rfid;
|
|
using HighWayIot.TouchSocket;
|
|
using HighWayIot.Winform.Business;
|
|
using HighWayIot.Winform.Properties;
|
|
using HslCommunication;
|
|
using Models;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
|
namespace HighWayIot.Winform.UserControlPages
|
|
{
|
|
public partial class TestPage : UserControl
|
|
{
|
|
private static LogHelper logger = LogHelper.Instance;
|
|
|
|
/// <summary>
|
|
/// TCP客户端
|
|
/// </summary>
|
|
private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance;
|
|
|
|
/// <summary>
|
|
/// RFID数据分析
|
|
/// </summary>
|
|
private RfidDataAnalyse _RfidDataAnalyse = new RfidDataAnalyse();
|
|
|
|
XmlUtil xmlUtil = new XmlUtil();
|
|
|
|
public TestPage()
|
|
{
|
|
InitializeComponent();
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
ArrayList list = new ArrayList();
|
|
foreach (var kv in GeneralUtils.GetEnumKeyValuePairs<DataTypeEnum>().ToDictionary(i => i.Key, i => i.Value))
|
|
{
|
|
list.Add(kv);
|
|
}
|
|
PlcType.DataSource = list;
|
|
PlcType.DisplayMember = "Key";
|
|
PlcType.ValueMember = "Value";
|
|
//PlcType.DataSource =
|
|
//PlcType.DataSource = ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试按钮1
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
MonitorInsert(
|
|
ZxRecipeService.Instance.GetRecipeInfos().FirstOrDefault().RecipeCode,
|
|
10.ToString()
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// RFID测试
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
var a = _touchSocketTcpClient.Send($"192.168.0.{RFIDtext.Text}", _RfidDataAnalyse.Send02H(1000));
|
|
LogHelper.Instance.Info($"192.168.0.{RFIDtext.Text} 发送" + (a ? "成功" : "失败"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试按钮3
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
//MessageBox.Show(PlcConnect.ReadByte2("D200", 1).IsSuccess.ToString());
|
|
var res = PlcConnect.PlcWrite2("D310", 123, DataTypeEnum.UInt16);
|
|
MessageBox.Show(res.IsSuccess.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// PLC读取按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ReadButton_Click(object sender, EventArgs e)
|
|
{
|
|
//DataTypeEnum en = (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue);
|
|
|
|
//string res = string.Empty;
|
|
|
|
//switch (en)
|
|
//{
|
|
// case DataTypeEnum.Bool:
|
|
// res = PlcConnect.ReadBool1(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.Int16:
|
|
// res = PlcConnect.ReadInt161(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.UInt16:
|
|
// res = PlcConnect.ReadUInt161(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.Int32:
|
|
// res = PlcConnect.ReadInt321(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.UInt32:
|
|
// res = PlcConnect.ReadUInt321(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.Int64:
|
|
// res = PlcConnect.ReadInt641(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.UInt64:
|
|
// res = PlcConnect.ReadUInt641(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.Float:
|
|
// res = PlcConnect.ReadFloat1(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.Double:
|
|
// res = PlcConnect.ReadDouble1(PlcAddress.Text).ToString();
|
|
// break;
|
|
// case DataTypeEnum.String:
|
|
// res = PlcConnect.ReadString1(PlcAddress.Text, (ushort)(GeneralUtils.StringNullOrToInt(LengthTextBox.Text) ?? 0)).ToString();
|
|
// break;
|
|
// default:
|
|
// res = "不对劲儿奥";
|
|
// break;
|
|
//}
|
|
|
|
//PlcShowValue.Text = res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 监控画面信息插入
|
|
/// </summary>
|
|
public void MonitorInsert(string recipeCode, string deviceNo)
|
|
{
|
|
ZxRecipeEntity recipeEntity = ZxRecipeService.Instance.GetRecipeInfosByRecipeCode(recipeCode).FirstOrDefault();
|
|
if (recipeEntity == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ZxDailyReportEntity entity = new ZxDailyReportEntity()
|
|
{
|
|
Uuid = Guid.NewGuid().ToString("N"),
|
|
VulcanizationNo = deviceNo,
|
|
StartTime = DateTime.Now,
|
|
RecipeName = recipeEntity.RecipeName,
|
|
RecipeCode = recipeEntity.RecipeCode,
|
|
SpecCode = recipeEntity.RecipeSpecCode,
|
|
DeviceNo = RecipeSendBusiness.RecipeNeededVehicleNo,
|
|
RawTireWeight = (int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight,
|
|
IsDone = 0
|
|
};
|
|
|
|
ZxDailyReportService.Instance.InsertDailyReportInfo(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// PLC写入按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void WriteButton_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|