Updates the LJ-1200 message with updated function code break outs and site id parsing with site aliasing.

This commit is contained in:
dennis.sheirer
2014-12-14 23:09:14 +00:00
parent d6306a5e85
commit 8b5e9c3f36

View File

@@ -37,14 +37,19 @@ public class LJ1200Message extends Message
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int[] VRC = { 23,22,21,20,19,18,17,16 };
public static int[] VRC = { 16,17,18,19,20,21,22,23 };
public static int[] LRC = { 31,30,29,28,27,26,25,24 };
public static int[] LRC = { 24,25,26,27,28,29,30,31 };
public static int[] FUNCTION = { 35,34,33,32 };
public static int[] FUNCTION = { 32,33,34,35 };
/* Message 8 Site ID */
public static int[] SITE_ID_PREFIX = { 36,37,38,39,40,41,42,43,44,45,46,47 };
public static int[] NETWORK_ID = { 48,49,50,51,52,53,54,55 };
public static int[] SITE_ID = { 56,57,58,59,60,61,62,63 };
public static int[] ADDRESS = { 63,62,61,60,59,58,57,56,55,54,53,52,51,50,
49,48,47,46,45,44,43,42,41,40,39,38,37,36 };
public static int[] ADDRESS = { 36,37,38,39,40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,60,61,62,63 };
public static int[] MESSAGE_CRC = { 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 };
@@ -101,9 +106,9 @@ public class LJ1200Message extends Message
return mMessage.getHex( MESSAGE_CRC, 4 );
}
public String getFunction()
public Function getFunction()
{
return mMessage.getHex( FUNCTION, 1 );
return Function.fromValue( mMessage.getInt( FUNCTION ) );
}
public String getAddress()
@@ -111,13 +116,59 @@ public class LJ1200Message extends Message
return mMessage.getHex( ADDRESS, 7 );
}
public String getNetwork()
{
return mMessage.getHex( NETWORK_ID, 2 );
}
public String getSite()
{
return mMessage.getHex( SITE_ID, 2 );
}
public String getSiteID()
{
return getNetwork() + "-" + getSite();
}
public Alias getSiteIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getSiteID( getSiteID() );
}
return null;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( "FUNCTION [" + getFunction() );
sb.append( "] ADDRESS [" + getAddress() );
Function function = getFunction();
sb.append( "FUNCTION: " );
sb.append( function.toString() );
if( function == Function.F8_SITE_ID )
{
sb.append( " SITE [" );
sb.append( getSiteID() );
Alias site = getSiteIDAlias();
if( site != null )
{
sb.append( "/" );
sb.append( site.getName() );
}
sb.append( "]" );
}
sb.append( " ADDRESS [" );
sb.append( getAddress() );
sb.append( "] VRC [" + getVRC() );
sb.append( "] LRC [" + getLRC() );
sb.append( "] CRC [" + getCRC() );
@@ -221,4 +272,59 @@ public class LJ1200Message extends Message
{
return null;
}
public enum Function
{
F0( 0x0, "0-UNKNOWN" ),
F1( 0x1, "1-UNKNOWN" ),
F2_ACTIVATION( 0x2, "2-ACTIVATION" ),
F3_SPEED_UP( 0x3, "3-SPEED-UP" ),
F4_TEST( 0x4, "4-TEST" ),
F5( 0x5, "5-UNKNOWN" ),
F6_SET_RATE( 0x6, "6-SET RATE" ),
F7( 0x7, "7-UNKNOWN" ),
F8_SITE_ID( 0x8, "8-SITE ID" ),
F9( 0x9, "9-UNKNOWN" ),
FA( 0xA, "A-UNKNOWN" ),
FB( 0xB, "B-UNKNOWN" ),
FC_DEACTIVATE( 0xC, "C-DEACTIVATE" ),
FD( 0xD, "D-UNKNOWN" ),
FE( 0xE, "E-UNKNOWN" ),
FF_TRACK_PULSE( 0xF, "F-TRACK PULSE" ),
UNKNOWN( -1, "UNKNOWN" );
private int mValue;
private String mLabel;
private Function( int value, String label )
{
mValue = value;
mLabel = label;
}
public int getValue()
{
return mValue;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return getLabel();
}
public static Function fromValue( int value )
{
if( 0 <= value && value <= 15 )
{
return Function.values()[ value ];
}
return UNKNOWN;
}
}
}