Class BabelMatrixDemo2
- All Implemented Interfaces:
BabelDemo
BabelMatrixDemo that steps
through a longer, fixed catalogue of frames added by ParadigmShift — coloured
letters, the full set of arrow glyphs (plain, inverted, mosaic), and the
standard symbols (forbidden / OK / wrong / mandatory direction signs), several
of them painted with explicit or randomised colours.
Like BabelMatrixDemo it drives the single I²C LED matrix through
I2COutputControlProtocol (id 2000), registering it with a
RegisterIoTDeviceRequest (no GPIO line — it is an I²C device) and
painting each frame as a raw 8×8 bitmap via ShowDisplayRequest, with
SetDisplayColorRequest used to clear the panel between cycles.
The Babel concept this variant illustrates is the fixed-rate periodic
timer: instead of re-arming a one-shot timer per frame, it advances one
sequencePosition step on every DemoTimer tick from a single
setupPeriodicTimer. (Compare BabelMatrixDemo's self-rescheduling
one-shot approach.)
The application never touches Pi4J or the I²C bus directly — it only sends
Babel requests; I2COutputControlProtocol does the hardware work.
Run with the LedMatrix2 command-line name (see Main).
-
Nested Class Summary
Nested classes/interfaces inherited from class pt.unl.fct.di.novasys.babel.core.GenericProtocol
pt.unl.fct.di.novasys.babel.core.GenericProtocol.ProtocolMetricsBabelMetrics -
Field Summary
Fields inherited from class pt.unl.fct.di.novasys.babel.core.GenericProtocol
babel, babelSecurityFields inherited from interface pt.unl.fct.di.tardis.babel.iot.demos.BabelDemo
PROTO_ID, PROTO_NAME -
Constructor Summary
ConstructorsConstructorDescriptionSets the protocol identity Babel uses to route events here. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Application bootstrap (the entry pointMaincalls for theLedMatrix2demo).voidhandleDemoTimer(DemoTimer t, long time) Periodic timer handler that paints one catalogue frame per tick.voidhandleRegisterIoTDeviceReply(pt.unl.fct.di.tardis.babel.iot.api.replies.RegisterIoTDeviceReply rep, short protocolId) Reply handler for the device registration: keeps the matrixDeviceHandleand starts the slideshow.voidinit(Properties props) Babel lifecycle hook: register the timer and reply handlers, then request the matrix.Methods inherited from class pt.unl.fct.di.novasys.babel.core.GenericProtocol
addSecret, addSecret, addSecret, addSecret, cancelTimer, closeConnection, closeConnection, closeConnection, closeConnection, closeConnection, closeConnection, createChannel, createSecureChannel, createSecureChannel, createSecureChannel, createSecureChannelWithAliases, createSecureChannelWithAliases, createSecureChannelWithIdentities, createSecureChannelWithIdentities, createSecureChannelWithProtoIdentities, enableGenericMetrics, generateIdentity, generateIdentity, generateIdentity, generateIdentity, generateIdentity, generateIdentity, generateIdentity, generateSecret, generateSecret, generateSecret, generateSecret, generateSecretFromPassword, generateSecretFromPassword, generateSecretFromPassword, generateSecretFromPassword, getChannelOrThrow, getDefaultChannel, getDefaultProtoIdentity, getDefaultProtoIdentityCrypt, getDefaultProtoSecret, getMillisSinceBabelStart, getOrGenerateDefaultProtoIdentity, getProtoId, getProtoName, hasProtocolThreadStarted, openConnection, openConnection, openConnection, openConnection, registerChannelEventHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageHandler, registerMessageSerializer, registerMetric, registerReplyHandler, registerRequestHandler, registerSharedChannel, registerTimerHandler, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendReply, sendRequest, setDefaultChannel, setDefaultProtoIdentity, setDefaultProtoIdentity, setDefaultProtoSecret, setupPeriodicTimer, setupTimer, startEventThread, subscribeNotification, triggerNotification, unsubscribeNotification
-
Constructor Details
-
BabelMatrixDemo2
public BabelMatrixDemo2()Sets the protocol identity Babel uses to route events here. No hardware is touched yet — registration happens ininit(java.util.Properties).
-
-
Method Details
-
init
public void init(Properties props) throws pt.unl.fct.di.novasys.babel.exceptions.HandlerRegistrationException, IOException Babel lifecycle hook: register the timer and reply handlers, then request the matrix. TheRegisterIoTDeviceReplyhandler is registered before theRegisterIoTDeviceRequestis sent so the reply always lands on a handler.- Specified by:
initin classpt.unl.fct.di.novasys.babel.core.GenericProtocol- Throws:
pt.unl.fct.di.novasys.babel.exceptions.HandlerRegistrationExceptionIOException
-
handleDemoTimer
Periodic timer handler that paints one catalogue frame per tick. It selects the frame bysequencePosition, encodes it into an 8×8 bitmap withLedMatrixUtils, and sends it as aShowDisplayRequest; when the sequence runs out it clears the panel and wraps back to the start. The tick cadence is owned by thesetupPeriodicTimerarmed in the reply handler, so this method just advances state and emits one display request. -
handleRegisterIoTDeviceReply
public void handleRegisterIoTDeviceReply(pt.unl.fct.di.tardis.babel.iot.api.replies.RegisterIoTDeviceReply rep, short protocolId) Reply handler for the device registration: keeps the matrixDeviceHandleand starts the slideshow. ChecksRegisterIoTDeviceReply.isSuccessful()and the alias before using the handle, paints an initial green fill, then arms a fixed-rate periodic timer that driveshandleDemoTimer(pt.unl.fct.di.tardis.babel.iot.demos.events.DemoTimer, long)every 2s. -
execute
Application bootstrap (the entry pointMaincalls for theLedMatrix2demo). Standard Babel start-up: get theBabelsingleton, load config, instantiate the one control protocol it needs (I2COutputControlProtocol), register both protocols,initthem in dependency order (controller before demo), thenb.start()to enter the event loop.
-