Distributed Programmable Protocol
PAI-CODE is the language of the bots, it allows bots to understand commands for better control, to communicate with other bots in order to exchange data, share workload and distribute tasks. In other words realtime programmable protocol for distributed network systems.
PAI-CODE is a programming language and real-time protocol that was built to support 3 major tasks:
PAI-CODE is embedded in all PAI-BOTS natively and therefore is used as the main programming language to program PAI-BOTS.
Every PAI-BOT has a PAI-CODE port that is connected to the standard bot I/O module which enables the sending and receiving of PAI-CODE commands.
Since PAI-CODE is a real-time programming language it enables the ability to program the PAI-BOT while it is still running.
PAI-CODE can wrap external code and algorithms together using this as a container and invocation system.
PAI-CODE uses the main protocol for bot-to-bot communication. The reason that bots needs to communicate is for remote service operations and task splitting.
Controlling a single bot is an easy task, but when it comes to a group of bots (swarm) PAI-CODE enables one to define rules and commands that can be sent to a group of bots. In addition, all API-Bots report to the PAI-NET operating system to send critical information and wait for new commands. This method of asynchronous reporting enables the support of complex flow management of bots’ operations.
PAI-CODE can run on a variety of operating systems and platforms.
PAI-CODE is a distributed computing language. PAI-CODE enables the ability to distribute, as well as run tasks on foreign systems and reduce the total running time for segregated tasks.
PAI-CODE is a “What You See Is What You Get” (WYSIWYG) environment. With PAI-CODE developers can see their app running while they are working on it. PAI-CODE offers hot swapping of modules in real-time to prevent a system shutdown.
PAI-CODE is connected to a classified, huge repository of code and data, which provides the developer a wide range of features that can easily be applied to his own application.
PAI-CODE is equipped with the most advanced security elements like intelligent encryption and real-time decryption.
PAI-CODE allows the developer to decide the price of the algorithm (code, software) and the billing formula. PAI-CODE ensures that every execution of code that has been wrapped with PAI-CODE will be billed (if needed) and the developer will be compensated for the usage.
* more data about PAI-CODE can be found on Appendix I
PAI-CODE uses a framework for the following programming languages and turns it into a cross platform ecosystem that supports the principles above:
PAI-CODE Interpreter is the main module of PAI-CODE. The main process of the interpreter is to receive a PAI-CODE Command and sends it to the right module for execution.
for example for the command “pai-code show version” is being parsed to “module: pai-code op: show param-1:version”.
PAI-CODE module is the main object that executes the command. PAI-CODE Module should inherit the basic module as well as a set of methods to execute on command when given a command op.
PAI-CODE Module holds a reference table in its memory to gain fast access to methods by holding the op name and a pointer to the method.
For example, the module pai-code holds the op “show” and the reference table looks like:
|OP Name||Method Pointer|
PAI-CODE-Module can invoke methods on different process via REST api.
PAI-CODE can load PAI-CODE-Modules on the fly (“pai-code load module <module-name>”).
PAI-CODE Parameter is a key value object that presents parameters and can be either numeric or textual.
This object is used for every command, function and program that requires parameters.
This object represents the commands that need to be executed.
PAI-CODE Command can receive clean text CLI and JSON formatted command.
After the command parsing, the PAI-CODE Command object will hold a list of parameters along with which module should run it.
After the execution of the command, the object will hold a response object.
PAI-CODE Function is list of PAI-CODE Commands with a basic flow. The function receives parameters and can respond.
PAI-CODE program holds a set of PAI-CODE Functions with a main function entry point, a shared memory between the functions and the ability to run in the background.
PAI-CODE is an event driven system which means that any object or command can be triggered by an event and any module can trigger an event.
Registering to PAI-CODE Event
PAI-CODE Command/Function/Program can register for invocation on an event by adding the “on” parameter. For example, to trigger the command on an event name: “STOP”, use the following command: “pai-bot stop on:STOP cmd-name:command1”.
Unregistering to PAI-CODE Event
To unregister an item from an event (stop listening) use the PAI-Event module with the unregister keyword. For example to trigger command on event name “STOP” use the following command: “pai-bot stop on:STOP”.
Triggering PAI-CODE Event
A PAI-CODE Event can be triggered using “pai-event fire” command. For example, to trigger a STOP event use the command: “pai-event fire:STOP”