114 lines
3.3 KiB
C#
114 lines
3.3 KiB
C#
using HslCommunication;
|
|
using HslCommunication.Core;
|
|
using HslCommunication.Profinet.Omron;
|
|
using JY.Inspection.Common;
|
|
using JY.Model.Excel;
|
|
using JY.Utility;
|
|
using MetroFramework.Forms;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace JY.Inspection.Frm
|
|
{
|
|
public partial class FrmTest : MetroForm
|
|
{
|
|
public FrmTest()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btn_readCollectItemCfg_Click(object sender, EventArgs e)
|
|
{
|
|
string fileName = @"Config/采集项参照表.xlsx";
|
|
//string fileName = @"Config/Device.xlsx";
|
|
List<CollectItemCfg> list = ExcelImporter.Import<CollectItemCfg>(fileName);
|
|
}
|
|
|
|
private void btn_stationArrival_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void btn_stationArrival_Click_1(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private async void btn_sendMQTTClient_Click(object sender, EventArgs e)
|
|
{
|
|
await MqttSingleton.Instance.InitializeAsync(
|
|
brokerHost: "127.0.0.1",
|
|
clientId: "EVE",
|
|
username: string.Empty,
|
|
password: string.Empty
|
|
);
|
|
|
|
string topic = "EVE/工厂编码/EQP/设备编码";
|
|
string payload = "测试数据";
|
|
await MqttSingleton.Instance.SendAsync(topic, payload);
|
|
}
|
|
|
|
private void btn_logPLCData_Click(object sender, EventArgs e)
|
|
{
|
|
byte[] bytes = new byte[] { 0x01, 0x02, 0x03, 0x04 };
|
|
|
|
LogHelper.LogPLCData("电池出站数据", bytes);
|
|
|
|
LogHelper.WriteErrorLine("错误日志");
|
|
}
|
|
|
|
private void btn_testAlarm_Click(object sender, EventArgs e)
|
|
{
|
|
string address = "192.168.2.50";
|
|
|
|
OmronFinsNet omronFinsNet = new OmronFinsNet();
|
|
omronFinsNet.IpAddress = address.ToString();
|
|
omronFinsNet.Port = 9600;
|
|
omronFinsNet.DA2 = 0;
|
|
omronFinsNet.ByteTransform.DataFormat = DataFormat.CDAB;
|
|
omronFinsNet.ByteTransform.IsStringReverseByteWord = true;
|
|
omronFinsNet.ConnectTimeOut = 2000;
|
|
omronFinsNet.ReceiveTimeOut = 2000;
|
|
|
|
var result = omronFinsNet.ConnectServer();
|
|
|
|
if (result != null && result.IsSuccess)
|
|
{
|
|
Debug.WriteLine("FinsTcp连接成功");
|
|
}
|
|
else
|
|
{
|
|
Debug.WriteLine("FinsTcp连接失败");
|
|
}
|
|
|
|
string addr = "D10010";
|
|
ushort length = 150;
|
|
byte[] byteResult = omronFinsNet.Read(addr, length).Content;
|
|
OperateResult barray = omronFinsNet.ReadBool(addr, length);
|
|
}
|
|
}
|
|
}
|