Let’s look at an example of a logistics control system.
Each module is loaded through an INCLUDE that specializes in a specific responsibility.
A JSON containing data for several cities will be the starting point to create the sets of resources in a way analogous to what we have already seen.
Packages are generated at each punto_distribucion and stored in a RESTROOM specific to that point.
A van travels through the distribution points, loading packages into its BACKPACK from the corresponding RESTROOM. BACKPACKs and RESTROOMs are compatible with each other; it is not possible to place entities from any other resource into a backpack.
The van unloads all entities at the safe GENERATE point called hub_distribucion, which is responsible for classifying the packages into different RESTROOMs. After that, the van loads each already-classified sack and makes the route again, delivering the packages to their destination.
In the end, this is a small example—about 150 lines of code—to implement something that appears complex.
Example
SYSTEM {TYPE:OPTIONS, SPEED:5}
SYSTEM {TYPE:VISUAL, WIDTH:900,HEIGHT:600}
SYSTEM {TYPE:PRE_RUN,TRIGGER:PRE_RUN}
START 1
include ./logistica/namespace.mod
include ./logistica/punto_distribucion.mod
include ./logistica/hub_distribucion.mod
include ./logistica/transportes.mod
PROCEDURE PRE_RUN
CALL crear_puntos_de_distribucion
CALL hub_distribucion.init
TERMINATE_VE
ENDPROCEDURE
;------------------------------------------------------
procedure crear_puntos_de_distribucion
FOREACH ciudad, IN_OBJECT, V$(aCiudades)
assign datosCiudad, V$(aCiudades.P$ciudad)
assign config,{
title:"P$(ciudad)"
,x:P$(datosCiudad.x)
,y:P$(datosCiudad.y)
}
call P$ciudad.punto_distribucion.init,V$config
ENDFOREACH
endprocedure