Represents a Loconet packet of an unknown type.
Namespace:
RRAutoLib.LoconetAssembly: RRAutoLib (in RRAutoLib.dll) Version: 1.3.3371.40749 (1.3.0.0)
Syntax
| Visual Basic (Declaration) |
|---|
<ComVisibleAttribute(False)> _ Public Class PkUnknown _ Inherits Packet |
Remarks
Incoming Loconet packets that are either not natively supported by this API or are corrupt will return this type. To create you own packet classes you must inherit from this class.
Examples
The following is an example of a custom packet class:
CopyVB.NET
Imports RRAutoLib.Loconet Public Class PkCustom Inherits PkUnknown Public Sub New() 'initialize an n byte packet; 'in this example it is a 4 byte OPS_LOCO_ADR _bytaPacket = New Byte(3) {&HBF, 0, 0, 0} End Sub Public Sub New(ByVal srtAddress As Short) 'simplify class construction Me.New() Me.Address = srtAddress End Sub Public Property Address() As Short Get 'decode parameter from packet bytes Return (CType(_bytaPacket(1), Short) << 7) Or _bytaPacket(2) End Get Set(ByVal Value As Short) 'encode parameter to packet bytes _bytaPacket(1) = (Value >> 7) And 127 _bytaPacket(2) = Value And 127 End Set End Property Public Overrides ReadOnly Property NeedsPacketResponse() As Boolean Get 'indicates that this packet expects a response Return True End Get End Property Public Overrides Function ValidPacketResponse(ByVal objResponsePacket As RRAutoLib.Loconet.Packet) As Boolean 'indicates that this packet expects either a slot read or a long aknoledge as a response packet Return objResponsePacket.OpCode = OpCodes.SL_RD_DATA Or _ objResponsePacket.OpCode = OpCodes.LONG_ACK End Function Public Overrides ReadOnly Property Description() As String Get 'brief description of packet Return "My custom packet" End Get End Property Public Overrides ReadOnly Property ParmsDesc() As String Get 'description of decoded packet parameters Return "Adr=" & Me.Address End Get End Property End Class