|
|
|
@ -1,25 +1,69 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using NewLife.Log;
|
|
|
|
|
using NewLife.Threading;
|
|
|
|
|
|
|
|
|
|
namespace ProductionSystem.Untils
|
|
|
|
|
{
|
|
|
|
|
public class MFSerialInfo: IDisposable
|
|
|
|
|
public class MfSerialInfo: IDisposable
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimerX _timer;
|
|
|
|
|
private MFSerial _mfser;
|
|
|
|
|
|
|
|
|
|
public byte Entrance { get; set; }
|
|
|
|
|
|
|
|
|
|
public byte Export { get; set; }
|
|
|
|
|
|
|
|
|
|
public Action<MfSerialEntity> MsgFunc { get; set; }
|
|
|
|
|
|
|
|
|
|
public MFSerialInfo(MFSerial mfser)
|
|
|
|
|
public MfSerialInfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_mfser = mfser;
|
|
|
|
|
_timer = new TimerX(DoBackup, mfser, 200, 500) { Async = true };
|
|
|
|
|
_mfser =new MFSerial();
|
|
|
|
|
_timer = new TimerX(DoBackup, _mfser, 200, 500) { Async = true };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _data;
|
|
|
|
|
|
|
|
|
|
public MfSerialInfo (byte entrance, byte export):this()
|
|
|
|
|
{
|
|
|
|
|
this.Entrance = entrance;
|
|
|
|
|
this.Export = export;
|
|
|
|
|
|
|
|
|
|
_mfser.SetLinSet();
|
|
|
|
|
//
|
|
|
|
|
_mfser.SetId(new List<byte>()
|
|
|
|
|
{
|
|
|
|
|
entrance,
|
|
|
|
|
export
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送几次数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
/// <param name="num"></param>
|
|
|
|
|
public void SendMsg(string data,int num=3)
|
|
|
|
|
{
|
|
|
|
|
_mfser.SendMsg(Entrance,data);
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
|
{
|
|
|
|
|
_mfser.SendLinMasterSend(Export);
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|