Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
La classe LineDisplayBase è un livello di astrazione relativamente sottile rispetto ad altre classi Service Object Base. Tra l'applicazione e il dispositivo fisico è necessario poco codice. L'oggetto servizio LineDisplay deve semplicemente annunciare le funzionalità supportate dal dispositivo fisico e modificarne l'output in base alle proprietà di visualizzazione impostate dall'applicazione.
Un oggetto servizio LineDisplay può anche monitorare il dispositivo e segnalare il risparmio di energia o altre modifiche di stato all'applicazione usando StatusUpdateEvent. A tale scopo, è possibile usare i metodi Queue o, ad esempio, le funzionalità di power reporting in PosCommon. Il monitoraggio del dispositivo in questo modo richiede in genere l'avvio di un nuovo thread per attendere gli eventi hardware e accodare l'evento StatusUpdateEvent appropriato. Un oggetto servizio LineDisplay può anche inviare DirectIOEvent all'applicazione.
Per implementare la classe e gli attributi LineDisplay
Aggiungere direttive using per gli spazi dei nomi Microsoft.PointOfService e Microsoft.PointOfService.BaseServiceObject.
Aggiungere l'attributo globale PosAssemblyAttribute in modo che PosExplorer lo riconosca come assembly Microsoft Point of Service per .NET (POS per .NET).
Creare una nuova classe derivata da LineDisplayBase.
Aggiungere l'attributo ServiceObjectAttribute a livello di classe alla nuova classe in modo che PosExplorer lo riconosca come oggetto servizio.
Per implementare membri LineDisplayBase astratti
Tutti gli oggetti servizio LineDisplay devono supportare almeno una modalità schermo. Per fornire all'applicazione specifiche sulle modalità dello schermo supportate, implementare la proprietà astratta LineDisplayScreenModes.
Come minimo, tutti gli oggetti servizio LineDisplay devono implementare DisplayData(Cell[]) per visualizzare i caratteri nel dispositivo di output.
Altre funzionalità
Impostare le proprietà delle funzionalità nell'oggetto servizio per annunciare il supporto per le funzionalità del dispositivo. Questo esempio illustra come implementare la funzionalità di lampeggiamento LineDisplay.
Per implementare la funzionalità di lampeggiamento
Nel costruttore impostare la proprietà CapBlink su DisplayBlink.All o DisplayBlink.Each per indicare la modalità lampeggiante supportata da questo oggetto servizio.
Impostare la proprietà CapBlink su true a indicare che la velocità di lampeggiamento può essere impostata dall'applicazione chiamando BlinkRate.
Prendere in considerazione queste e altre impostazioni quando si implementa DisplayData.
Esempio
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.PointOfService;
using Microsoft.PointOfService.BaseServiceObjects;
[assembly: PosAssembly("Service Object Contractors, Inc.")]
namespace SOSample.LineDisplay
{
[ServiceObject(
DeviceType.LineDisplay,
"SampleLineDisplay",
"Sample LineDisplay Service Object",
1,
9)]
public class SampleLineDisplay : LineDisplayBase
{
SampleLineDisplay()
{
// The CapBlink property is initially set to
// DisplayBlink.None in LineDisplayBase. This property
// will be set here to indicate what mode of blinking
// text our Service Object can support.
Properties.CapBlink = DisplayBlink.All;
// Set the CapBlinkRate property to true to indicate
// that this device has the ability to change the
// rate at which it blinks by setting the property
// BlinkRate.
Properties.CapBlinkRate = true;
}
#region Implement Abstract LineDisplayBase Members
// LineDisplayScreenMode must be implemented to
// allow the application to find out which screen modes
// are supported by this device.
protected override LineDisplayScreenMode[]
LineDisplayScreenModes
{
get
{
LineDisplayScreenMode[] SupportedModes;
// Create a LineDisplayScreenMode object; this SO
// has a screen mode 10 columns wide and 2 rows deep.
LineDisplayScreenMode mode =
new LineDisplayScreenMode(10, 2, 0, 0);
// Allocate space for our screen mode array and
// initialize it to hold our supported screen
// mode(s).
SupportedModes =
new LineDisplayScreenMode[] { mode };
return SupportedModes;
}
}
// DisplayData is the method called from the application
// specifying what data should be displayed on the
// device.
protected override void DisplayData(Cell[] cells)
{
// Your code here:
// Send the data to your device. Take settings such
// as blink and blink rate into account here.
return;
}
#endregion Implement Abstract LineDisplayBase Members
#region Implement Abstract PosCommon Members
private string MyHealthText = "";
// PosCommon.CheckHealthText.
public override string CheckHealthText
{
get
{
// VerifyState(mustBeClaimed,
// mustBeEnabled).
VerifyState(false, false);
return MyHealthText;
}
}
// PosCommon.CheckHealth.
public override string CheckHealth(
HealthCheckLevel level)
{
// Verify that the device is open, claimed and enabled.
VerifyState(true, true);
// Your code here:
// check the health of the device and return a
// descriptive string.
// Cache result in the CheckHealthText property.
MyHealthText = "Ok";
return MyHealthText;
}
// PosCommon.DirectIOData.
public override DirectIOData DirectIO(
int command,
int data,
object obj)
{
// Verify that the device is open.
VerifyState(false, false);
return new DirectIOData(data, obj);
}
#endregion Abstract PosCommon Members
}
}