Forecourt Extending
In this article
Extending the Implementation DLL
Extending the Forecourt Ribbon
Extending the Implementation DLL
To communicate with the implementation DLL, you can use the Hardware Station's DirectIO feature.
This article has code snippets describing how to send DirectIO from AL codeunit to the Forecourt Device and receive the message in the Implementation DLL.
DirectIO Implementation DLL
Here is a function that you can add to the Implementation DLL that receives the message from the codeunit that calls DirectIO.
This function just logs the data from the DirectIO call.
public override bool DirectIO(int command, ref int data, ref string dataString)
{
_logger.Debug("Forecourt Direct IO - PSS5000");
_logger.Debug($"{nameof(command)}: {command}, {nameof(data)}: {data}, {nameof(dataString)}: {dataString}");
dataString += " - return";
return true;
}
Codeunit sending DirectIO
Here is a codeunit that can be in an extension that subscribes to OnPOSCommand event and reacts to an external POS Command FRC_CHANGESERVICEMOD.
This is an example of the data that will end up being logged in the Hardware Station.
command: 1, data: 2, dataString: {"Command":"FRC_CHANGESERVICEMOD","Data":{"ServiceMode":"12"}}
You can send any data as a string in the dataString parameter, and in this case it is a stringified JSON (the content of MessageJson variable).
The Implementation DLL receives this MessageJson in the dataString parameter.
The DirectIO procedure also needs some information about the device it is sending to.
codeunit 50100 "Custom Codeunit AL"
{
Access = Internal;
SingleInstance = true;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"LSC POS Controller", 'OnPOSCommand', '', false, false)]
local procedure OnPOSCommand(var ActivePanel: Record "LSC POS Panel"; var PosMenuLine: Record "LSC POS Menu Line");
var
job: jsonobject;
begin
if PosMenuLine.Command = 'FRC_CHANGESERVICEMOD' then begin
PosMenuLine.Processed := true;
job.Add('ServiceMode', PosMenuLine.Parameter);
SendDirectIO('FRC_CHANGESERVICEMOD', job);
end;
end;
local procedure SendDirectIO(command: text; JObject: JsonObject): Boolean
var
HwstCtrl: Codeunit "LSC POS Hardware Interface";
PosSession: Codeunit "LSC POS Session";
POSHwProfileDevice: Record "LSC POS Hardware Profile Dev.";
ForecourtDevice: Record "LSC FRC Device";
MessageJson: Text;
job: JsonObject;
begin
job.Add('Command', command);
job.Add('Data', JObject);
POSHwProfileDevice.SetRange("Profile ID", PosSession.HardwareProfileID());
POSHwProfileDevice.SetRange("Device Type", POSHwProfileDevice."Device Type"::Forecourt);
if POSHwProfileDevice.Count = 0 then
exit(false);
job.WriteTo(MessageJson);
if POSHwProfileDevice.FindSet() then begin
repeat
if ForecourtDevice.Get(POSHwProfileDevice."Device ID") then begin
JObject.Add('DeviceID', ForecourtDevice.ID);
HwstCtrl.DirectIO(
ForecourtDevice."Server Host",
ForecourtDevice."Server HTTPS",
Enum::"LSC Hardware Profile Devices"::"FORECOURT",
ForecourtDevice.ID,
1,
2,
MessageJson,
''
);
end;
until POSHwProfileDevice.Next() = 0;
exit(true);
end;
exit(false);
end;
}
Extending the Forecourt Ribbon
From version 24.0
See Forecourt Ribbon Styles on how to enable and access the ribbon styles.
You can extend the General Operation menu and the Extended Menu.
Below is an example of how a Day shift button has been added to the Extended Menu.
A key (Dayshift) is needed in the Parameter field, and then the Post Command and Post Parameter, which are equivalent to a POS Buttons Command and Parameter, are used.
The result in the Forecourt Ribbon is a Day shift button at the end of the Global Operations slider, and when you click the button, it executes a FRC_CHANGESERVICEMOD with parameter 21.