Example Data Discriminator
The following example displays a minimalist discriminator for the standard Modbus Compatible Device. This code would typically be in a file in the application directory, and referenced in the SERVICES section of the application's AppRoot.src root file.
[
Discriminator Module;
Connect Module;
Root;
Name;
Port;
]
Init [ { This module registers as the discriminator for tag MB01 }
If \ModemManager\Started Main;
[
Name = "MB01";
Port = Scope(\Code, Name)\Port;
Root = Self;
\ModemManager.Register(Root, Name, 10);
]
]
Main [
]
<
{================ ModiconDriver\Discriminator ====================}
{ This module pass in a buffer, return a Station ID if accept the }
{ call. The station address in the incoming message is inspected. }
{ Return invalid if reject the call. }
{=================================================================}
Discriminator
(
Buffer;
)
Main [
If watch(1);
[
IfElse(PickValid(GetByte(Buffer, 0) == Scope(\Code, Name)\Station, 0),
Return(Name),
{ Else }
Return(Invalid)
);
]
]
{ End of ModiconDriver\Discriminator }
>
<
{===================== ModiconDriver\Connect ====================== }
{ Returns the Workstation name of the driver server. Called by the }
{ Modem Manager to determine the machine name of the current server }
{ for this driver. }
{================================================================== }
Connect
(
Station;
Stream;
)
Main [
If watch(1);
[
Return(WkStaInfo(0)) ;
]
]
{ End of ModiconDriver\Connect }
>