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.
94 lines
2.6 KiB
C#
94 lines
2.6 KiB
C#
using CSZTM;
|
|
using GTN;
|
|
using Rs.Motion.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.Motion.GugaoEcat
|
|
{
|
|
public class ZtmCardManager : ICardManager
|
|
{
|
|
Dictionary<short, short> mcDic = new Dictionary<short, short>();
|
|
/// <summary>
|
|
/// 执行底层接口的返回值
|
|
/// </summary>
|
|
private short apiResult = 0;
|
|
private short mc0 = -1;
|
|
private short mc1 = -1;
|
|
/// <summary>
|
|
/// 保存一共有多少张卡
|
|
/// </summary>
|
|
Dictionary<ushort,ICard> cardDic= new Dictionary<ushort,ICard>();
|
|
private ZtmCardManager() {
|
|
|
|
}
|
|
|
|
private static ZtmCardManager instance;
|
|
public static ZtmCardManager Instance
|
|
{
|
|
get
|
|
{
|
|
if(instance==null)
|
|
{
|
|
instance = new ZtmCardManager();
|
|
}
|
|
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同一类卡统一初始化
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override ErrorCode Init()
|
|
{
|
|
//string ip1 = "192.168.100.2";
|
|
//string ip2 = "192.168.100.1";
|
|
//apiResult = ZTM.ZT_Open(ip1.ToCharArray(), ref mc0, 2000);
|
|
//if (apiResult != 0)
|
|
//{
|
|
// return ErrorCode.CardInitFail;
|
|
//}
|
|
|
|
//apiResult = ZTM.ZT_GetConnectionStatus(ip1.ToCharArray(), ref mc0);
|
|
//if (1 != apiResult)
|
|
//{
|
|
// return ErrorCode.CardInitFail;
|
|
//}
|
|
|
|
//mcDic.Add(0, mc0);
|
|
|
|
//apiResult = ZTM.ZT_Open(ip2.ToCharArray(), ref mc1, 2000);
|
|
//if (apiResult != 0)
|
|
//{
|
|
// return ErrorCode.CardInitFail;
|
|
//}
|
|
//apiResult = ZTM.ZT_GetConnectionStatus(ip2.ToCharArray(), ref mc0);
|
|
//if (1 != apiResult)
|
|
//{
|
|
// return ErrorCode.CardInitFail;
|
|
//}
|
|
//mcDic.Add(1, mc1);
|
|
IsInitialized = true;
|
|
return ErrorCode.Ok;
|
|
}
|
|
|
|
|
|
|
|
public ICard GetCard(short cardID)
|
|
{
|
|
if(cardDic.ContainsKey((ushort)cardID)) return cardDic[(ushort)cardID];
|
|
ICard card = new ZtmCard((ushort)cardID, (ushort)mcDic[cardID], 10, $"ztm{cardID}.xml");
|
|
card.Init();
|
|
cardDic.Add((ushort)cardID, card);
|
|
return card;
|
|
}
|
|
}
|
|
}
|