CSoft.Protocol.HJ212_Server 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSoft.Protocol.HJ212_Server --version 1.0.5                
NuGet\Install-Package CSoft.Protocol.HJ212_Server -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSoft.Protocol.HJ212_Server" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSoft.Protocol.HJ212_Server --version 1.0.5                
#r "nuget: CSoft.Protocol.HJ212_Server, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CSoft.Protocol.HJ212_Server as a Cake Addin
#addin nuget:?package=CSoft.Protocol.HJ212_Server&version=1.0.5

// Install CSoft.Protocol.HJ212_Server as a Cake Tool
#tool nuget:?package=CSoft.Protocol.HJ212_Server&version=1.0.5                

HJ212国标服务端协议:

IGB_Server gb = new GB_Server(new TcpServer("0.0.0.0", 2756));
gb.OnClientConnect += Gb_OnClientConnect;

gb.OnAskSetSystemTime += Gb_OnAskSetSystemTime;
async Task Gb_OnAskSetSystemTime(int clientId, (string PolId, HJ212_Server.Model.RspInfo RspInfo) objects)
{
    await Task.CompletedTask;
}

await gb.StartAsync();

async Task Gb_OnClientConnect(int clientId)
{
    try
    {
        #region c1
        await gb.SetTimeoutAndRetryAsync(clientId, "1234567890123456", "123456", ST.大气环境污染源, 10, 3); 
        #endregion
    }
    catch (TimeoutException ex)
    {
        Console.WriteLine(ex.Message);
    }
}

更多详见Test例子,例子中附带测试命令

实现HJ212-2017《污染源在线自动监控(监测)系统数据传输标准》中 附 录 C(资料性附录)通讯命令示例和拆分包及应答机制示例 中所有(表1-表50)详细接口如下,若有错误和建议请及时联系我改正:

/// <summary>C1设置超时时间及重发次数</summary>
Task SetTimeoutAndRetryAsync(Guid clientId, string mn, string pw, ST st, int overTime, int reCount, int timeOut = 5000);

/// <summary>C2提取现场机时间</summary>
Task<DateTime> GetSystemTimeAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C3设置现场机时间</summary>
Task SetSystemTimeAsync(Guid clientId, string mn, string pw, ST st, string polId, DateTime systemTime, int timeOut = 5000);

/// <summary>C4现场机时间校准请求</summary>
event ActivelyPushDataServerEventHandler<(string PolId, RspInfo RspInfo)> OnAskSetSystemTime;

/// <summary>C5提取实时数据间隔</summary>
Task<int> GetRealTimeDataIntervalAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C6设置实时数据间隔</summary>
Task SetRealTimeDataIntervalAsync(Guid clientId, string mn, string pw, ST st, int interval, int timeOut = 5000);

/// <summary>C7提取分钟数据间隔</summary>
Task<int> GetMinuteDataIntervalAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C8设置分钟数据间隔</summary>
Task SetMinuteDataIntervalAsync(Guid clientId, string mn, string pw, ST st, int interval, int timeOut = 5000);

/// <summary>C9设置现场机访问密码</summary>
Task SetNewPWAsync(Guid clientId, string mn, string pw, ST st, string newPW, int timeOut = 5000);

/// <summary>C10取污染物实时数据</summary>
Task StartRealTimeDataAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C11停止察看污染物实时数据</summary>
Task StopRealTimeDataAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C12取设备运行状态数据</summary>
Task StartRunningStateDataAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C13停止察看设备运行状态</summary>
Task StopRunningStateDataAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>
/// C14上传污染物实时数据
/// (C25上传噪声声级实时数据 同)
/// (C29上传工况实时数据 同)
/// </summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<RealTimeData> Data, RspInfo RspInfo)> OnUploadRealTimeData;

/// <summary>C15上传设备运行状态数据</summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<RunningStateData> Data, RspInfo RspInfo)> OnUploadRunningStateData;

/// <summary>
/// C16上传污染物分钟数据
/// (C26上传噪声声级分钟数据 同)
/// </summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<StatisticsData> Data, RspInfo RspInfo)> OnUploadMinuteData;

/// <summary>
/// C17上传污染物小时数据
/// (C27上传噪声声级小时数据 同)
/// </summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<StatisticsData> Data, RspInfo RspInfo)> OnUploadHourData;

/// <summary>
/// C18上传污染物日历史数据
/// (C28上传噪声声级日历史数据 同)
/// </summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<StatisticsData> Data, RspInfo RspInfo)> OnUploadDayData;

/// <summary>C19上传设备运行时间日历史数据</summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, List<RunningTimeData> Data, RspInfo RspInfo)> OnUploadRunningTimeData;

/// <summary>
/// C20取污染物分钟历史数据
/// 遵循C47-C50的规则
/// </summary>
Task<List<HistoryData>> GetMinuteDataAsync(Guid clientId, string mn, string pw, ST st, DateTime beginTime, DateTime endTime, int timeOut = 5000);

/// <summary>
/// C21取污染物小时历史数据
/// 遵循C47-C50的规则
/// </summary>
Task<List<HistoryData>> GetHourDataAsync(Guid clientId, string mn, string pw, ST st, DateTime beginTime, DateTime endTime, int timeOut = 5000);

/// <summary>
/// C22取污染物日历史数据
/// 遵循C47-C50的规则
/// </summary>
Task<List<HistoryData>> GetDayDataAsync(Guid clientId, string mn, string pw, ST st, DateTime beginTime, DateTime endTime, int timeOut = 5000);

/// <summary>
/// C23取设备运行时间日历史数据
/// 遵循C47-C50的规则
/// </summary>
Task<List<RunningTimeHistory>> GetRunningTimeDataAsync(Guid clientId, string mn, string pw, ST st, DateTime beginTime, DateTime endTime, int timeOut = 5000);

/// <summary>C24上传数采仪开机时间</summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, DateTime RestartTime, RspInfo RspInfo)> OnUploadAcquisitionDeviceRestartTime;

/// <summary>C30零点校准量程校准</summary>
Task CalibrateAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C31即时采样</summary>
Task RealTimeSamplingAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C32启动清洗/反吹</summary>
Task StartCleaningOrBlowbackAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C33比对采样</summary>
Task ComparisonSamplingAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C34超标留样</summary>
Task<(DateTime DataTime, string VaseNo)> OutOfStandardRetentionSampleAsync(Guid clientId, string mn, string pw, ST st, int timeOut = 5000);

/// <summary>C35设置采样时间周期(单位:小时)</summary>
Task SetSamplingPeriodAsync(Guid clientId, string mn, string pw, ST st, string polId, TimeOnly cstartTime, int ctime, int timeOut = 5000);

/// <summary>C36提取采样时间周期(单位:小时)</summary>
Task<(TimeOnly CstartTime, int CTime)> GetSamplingPeriodAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C37提取出样时间(单位:分钟)</summary>
Task<int> GetSampleExtractionTimeAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C38提取设备唯一标识</summary>
Task<string> GetSNAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C39上传设备唯一标识</summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, string PolId, string SN, RspInfo RspInfo)> OnUploadSN;

/// <summary>C40上传现场机信息(日志)</summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, string? PolId, string Log, RspInfo RspInfo)> OnUploadLog;

/// <summary>C41提取现场机信息(日志)</summary>
Task<List<LogInfo>> GetLogInfosAsync(Guid clientId, string mn, string pw, ST st, string? polId, DateTime beginTime, DateTime endTime, int timeOut = 5000);

/// <summary>
/// C42上传现场机信息(状态)
/// (C44上传现场机信息(参数) 同)
/// </summary>
event ActivelyPushDataServerEventHandler<(DateTime DataTime, string PolId, List<DeviceInfo> DeviceInfos, RspInfo RspInfo)> OnUploadInfo;

/// <summary>C43提取现场机信息(状态)</summary>
Task<string> GetStateInfoAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C45提取现场机信息(参数)</summary>
Task<string> GetArgumentInfoAsync(Guid clientId, string mn, string pw, ST st, string polId, int timeOut = 5000);

/// <summary>C46设置现场机参数</summary>
Task SetInfoAsync(Guid clientId, string mn, string pw, ST st, string polId, string infoId, string info, int timeOut = 5000);
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Server改ClientId为Guid类型