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.

60 lines
1.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Charger.BatCharging.Manager
{
/// <summary>
/// 管理充电机信息
/// </summary>
public class ChargerEqmManager
{
public Channel<byte[]> messageQueue;
/// <summary>
/// 充电机通讯连接线程
/// </summary>
public void ChargerNetConnectThread()
{
Thread chrgConnectThread = new Thread(ChargerNetConnectFunc);
chrgConnectThread.IsBackground = true;
chrgConnectThread.Start();
}
/// <summary>
/// 充电机通讯连接
/// </summary>
private void ChargerNetConnectFunc()
{
UnboundedChannelOptions options = new UnboundedChannelOptions();
options.SingleReader = true;
messageQueue = Channel.CreateUnbounded<byte[]>(options);
ChargerConnect();
}
public void ChargerConnect()
{
Task.Run(() => ConsumeMessagesThread());
while (true)
{
//if(messageQueue.)
}
}
public async Task ConsumeMessagesThread()
{
while (await messageQueue.Reader.WaitToReadAsync())
{
while (messageQueue.Reader.TryRead(out var message))
{
//Client_DataReceived(message);
}
}
}
}
}