UniPRT SDK  v1.0.0.0
UniPRT.Sdk.Monitor.OdvMonitor 類別 參考文件

提供與 ODV 相關服務的支援。模組用於促進監聽/檢索與 ODV 相關的印表機未經請求的訊息。 更多...

類別UniPRT.Sdk.Monitor.OdvMonitor的繼承圖:
UniPRT.Sdk.Monitor.IOdvMonitor

公開方法(Public Methods)

 OdvMonitor (string commDescriptor)
 當創建由 SDK 管理的連接時呼叫的構造函數。 更多...
 
void Dispose ()
 

保護方法(Protected Methods)

virtual void Dispose (bool disposing)
 

屬性(properties)

OdvReportNotice OdvReportCallback [get, set]
 繼承自 IOdvMonitor.OdvReportCallback。
 
bool OdvReportListening [get, set]
 繼承自 IOdvMonitor.OdvReportListening。
 

詳細描述

提供與 ODV 相關服務的支援。模組用於促進監聽/檢索與 ODV 相關的印表機未經請求的訊息。

未經請求的訊息,如果在印表機上啟用,可以隨時發送。 此模組需要持續的 "狀態" 連接到印表機的管理端口,以便監聽印表機發送的任何訊息。

備註
  • 要讓 ODV 報告由印表機發送,必須存在以下設定:
    • 在印表機 OVD 選單中:"Validator Active = Enable"、"Telemetry Path = Network Port"、"Telemetry Data = Full Report"

Examples

using System;
using System.Collections.Generic;
namespace Snippets
{
public class MyOdvMonitoring
{
private static OdvMonitor _odvReportListener = null;
public static void MainOdvMonitor(string[] args)
{
Console.WriteLine("Listening for ODV barcode reports.");
try
{
_odvReportListener = new OdvMonitor("127.0.0.1");
_odvReportListener.OdvReportListening = true; // enable parsing of unsolicited barcode report msgs from printer
_odvReportListener.OdvReportCallback = myOdvReportProcessing; // set the callback/delegate to call when reports received
while (true) // wait for something to happen
{
// pretend to be busy doing some other work here...
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
// release any resources associated with object
_odvReportListener?.Dispose();
}
}
public static void myOdvReportProcessing(OdvReport odvReport)
{
// Could also customize into CSV format based on needs
string userFriendlyResult = odvReport.Failed ? "failed" : "passed"; // failure output as "failed"/"passed" to make more user friendly
Console.WriteLine("\r\nShort CSV Format (customized ordered list): pass/fail, Grade, Data");
Console.WriteLine($" {userFriendlyResult}, {odvReport.OverallGrade}, {odvReport.Data}");
}
}
}

建構子與解構子說明文件

◆ OdvMonitor()

UniPRT.Sdk.Monitor.OdvMonitor.OdvMonitor ( string  commDescriptor)

當創建由 SDK 管理的連接時呼叫的構造函數。

commDescriptor 是用於與印表機連接的通訊描述符。
TCP 描述符格式:"ip" 或 "ip:port"
例如:"127.0.0.1" 或 "127.0.0.1:3007"
如果未提供端口,則使用預設值。

UniPRT.Sdk.Reports
Definition: OdvReport.cs:5
UniPRT
提供對不同通訊介面/端口的支援
Definition: Communication.cs:9
UniPRT.Sdk
Definition: Communication.cs:9
UniPRT.Sdk.Monitor
Definition: OdvMonitor.cs:14