Click or drag to resize

SGD Class

A utility class used to wrap and send SGD commands to a connection.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.PrinterSGD

Namespace:  Zebra.Sdk.Printer
Assembly:  SdkApi_Core (in SdkApi_Core.dll) Version: 2.14.1989
Syntax
public class SGD

The SGD type exposes the following members.

Constructors
  NameDescription
Public methodSGD
Initializes a new instance of the SGD class
Top
Methods
  NameDescription
Public methodStatic memberDO(String, String, Connection)
Constructs an SGD DO command and sends it to the printer.
Public methodStatic memberDO(Stream, String, String, Connection)
Constructs an SGD DO command and sends it to the printer.
Public methodStatic memberDO(String, String, Connection, Int32, Int32)
Constructs an SGD DO command and sends it to the printer.
Public methodStatic memberDO(Stream, String, String, Connection, Int32, Int32)
Constructs an SGD DO command and sends it to the printer.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberGET(String, Connection)
Constructs an SGD GET command and sends it to the printer.
Public methodStatic memberGET(String, Connection, Int32, Int32)
Constructs an SGD GET command and sends it to the printer.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberSET(String, Int32, Connection)
Constructs an SGD SET command and sends it to the printer.
Public methodStatic memberSET(String, String, Connection)
Constructs an SGD SET command and sends it to the printer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
using System;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;

public class SGDExample {

    public static void Main(string[] args) {
        try {
            string ipAddress = "192.168.1.2";
            SgdOverTcp(ipAddress);
            SgdOverMultiChannelNetworkConnection(ipAddress);
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        }
    }

    public static void SgdOverTcp(string ipAddress) {
        int port = 9100;
        Connection printerConnection = new TcpConnection(ipAddress, port);
        try {
            printerConnection.Open();
            SGD.SET("print.tone", "15", printerConnection);
            string printTone = SGD.GET("print.tone", printerConnection);
            Console.WriteLine($"SGD print.tone is {printTone}");
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        } finally {
            printerConnection.Close();
        }
    }

    private static void SgdOverMultiChannelNetworkConnection(string ipAddress) {
        // Create and open a connection to a Link-OS printer using both the printing and the status channel
        MultichannelTcpConnection printerConnection = new MultichannelTcpConnection(ipAddress, MultichannelTcpConnection.DEFAULT_MULTICHANNEL_PRINTING_PORT, MultichannelTcpConnection.DEFAULT_MULTICHANNEL_STATUS_PORT);
        try {
            printerConnection.Open();

            // Get an SGD, using the status channel
            string modelName = SGD.GET("device.product_name", printerConnection);
            Console.WriteLine($"SGD device.product_name is {modelName}");

            // Close the connection, and re-open it using only the status channel
            printerConnection.Close();
            printerConnection.OpenStatusChannel();

            // Get an SGD, again using the status channel
            string printSpeed = SGD.GET("media.speed", printerConnection);
            Console.WriteLine($"The print speed is {printSpeed}");

            // Close the connection, and re-open it using only the printing channel
            printerConnection.Close();
            printerConnection.OpenPrintingChannel();

            // Get an SGD, using the printing channel
            string mirrorFrequency = SGD.GET("ip.mirror.freq", printerConnection);
            Console.WriteLine($"The mirror frequency is {mirrorFrequency}");
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        } finally {
            printerConnection.Close();
        }
    }
}
See Also