# Architecting an Agent-Based Fault Diagnosis Engine for IEC 61499 Industrial Cyber-Physical Systems
## 3 Architecting the Engine
### Diagnostic Points and Telemetry  
_Telemetry_ is defined as the in situ collection of measurements or other types of data at remote points and the transmission of that data back to receiving equipment [79]. The agents treat FBs as black-boxes whose behavior or misbehavior can be inferred from the data they exchange with each other. In most practical instances, the engine is deployed on its own hardware, separate from the platform the FB application is executing on. The rational for creating stand-alone fault management engines is discussed in depth in [PERSON]'s description of the NASA Curiosity Mars Rover [36]. [PERSON] et al. present a similar rational for the Airbus fault engine [80]. These engines have to keep functioning even when the applications they are managing are failing. Hence, the DPs in our engine need to provide remote data capture and interaction points that can operate as software-in-the-loop entry points within the FB application, exchanging telemetry via managed network connections to the platform that the agents are operating on. Figure 7 shows the construction of the DP function block DP. This is a Composite Function Block (CFB) that contains an instance of the AGENT_GATE Service Interface Function Block (SIFB). The DP block is used to break and re-connect the data and event lines that connect FBs together. CFBs expose a single input and output interface that encapsulates a more complex internal configuration. The configuration parameters include a _POLL_TIME_ parameter that allows the performance of the DPs to be fine-tuned by the agent during the configuration of the diagnostic test harness. DPs initially pass all data and events through transparently after the agent has instructed them to operate in their _PASTHROUGH_ENABLEED_ mode. Each data value is also sent back to the agent as it passes through the DP. The AGENT_GATE block implements a TCP client connection to a single named non-blocking I/O gateway component called _NIOserver_ that is hosted on the engine. A TCP server listener socket  
Figure 7: Diagnostic point composite function block. handover then assigns a unique socket to maintain the connection between the agent and the client DP. The agent communicates with the DP wired into the FB application via an in-memory object interface, also referred to as a _DiagnosticPoint_, established within the engine. The agents exchange telemetry with the DP using First-In-First Out (FIFO) data queues and the packet structure detailed in Figure 8.  
The start and end of packet characters are used to ensure that the packet has not been malformed and to allow multiple variable-length packets to be unpacked from the input buffer reliably in a single read from a TCP port. The data type is inferred by the agent since it was established during the set up of the DP. The input DATA_TYPE is used by the block to determine the format conversion needed into and out of the string format that is carried in the data packet. TCP addresses and the Host listener port are also specified on input parameters. Table 2 details the packet commands supported by the DP and the agents. The DP provides input and output data ports for each defined IEC 61499 data type. These range from Boolean types through to long and short Integers, Real Numbers and Strings. An efficient type conversion in C++ with rounding to a specified number of decimal places was implemented in the blocks to ensure that data were processed rapidly and packed efficiently into the data packets. The \(gate()\) functionality allows the agent to dynamically isolate either a single FB or a set of related blocks to exercise them. Data and events are blocked from passing into or out of a ring-fenced area to allow the blocks to be tested in isolation, unaffected by other parts of the FB application. The agent can then restore the pass-through mode of those blocks and move on to investigate other blocks of interest. In this way, the agent can walk