All Plugins have the following two Interfaces for direct calls from the outside.
///<summary
/// Analysis interface for scripts and plugins.
///</summary
→ The Header from the first Interface.
public interface IPCBIAnalysis {
///<summary
/// The name of this analysis to identify it with the settings.
///</summary
string Name { get; }
///<summary
/// The readable name of this analysis
///</summary
string Title { get; }
///<summary
/// The path to the results directory of this analysis relative to the job path
///</summary
string ResultsFolderName { get; }
///<summary
/// The preview icon for this analysis
///</summary
Icon PreviewIcon { get; }
///<summary
/// Set if the file preview should show if results are available
///</summary
Set if the file preview should show if results are available
///<summary
/// Create a instance of rules to define the default standard rules.
///</summary
PCBI.Automation.Rules.RulesContainer GetStandardRules();
// void AddToUpdateProgress(PCB_Investigator.PCBIWindows.PCBIWorkingDialog working, int minValue, int maxValue);
// bool Execute(string ResultFilePath);
public interface IPluginAnalysis: IPlugin, IPCBIAnalysis{
///<summary
///
///</summary
///
void AddToUpdateProgress(PCB_Investigator.PCBIWindows.PCBIWorkingDialog working, int minValue, int maxValue);
bool Execute(IAnalysisParams analysisParams);
bool Execute(string resultFilePath); }
→
The script is allowed to increment
values between minValue and maxValue.
The Remote Control Server gives you options to create your own Routs, Instructions and scripts to control PCB-Investigator from outside.
In PCB-Investigator you have three buttons:
"Start Server" activate the remote control
"Stop Server" deactivate the remote control
"Server Settings" shows the settings dialog:
Here you can configurate the comunication port and timeout, you can also manage the available scripts.
Instructions are commands for PCB-Investigator that are queued and executed sequentially. This means they will be executed in the order that they were sent in.
Instructions can be used to automate tasks, such as loading a file, running a script, or exporting data. They are especially useful for automating long-running tasks, because you can queue them and check the status later.
To add an instruction using the PCBI_RemoteControlServer.PCBI_Connection.AddInstruction
method, follow these steps:
public void AddInstruction(string name, Func<Entities.RequestDto, Task<Entities.InstructionResult>> handler, string description = "")
name
: A string
representing the name of the instruction.handler
: A Func
delegate that takes an Entities.RequestDto
and returns a Task<Entities.InstructionResult>
. This is the function that will be executed when the instruction is called.description
: An optional string
providing a description of the instruction.The handler function should match the signature Func<Entities.RequestDto, Task<Entities.InstructionResult>>
. Here is an example of how to create such a function:
public async Task<Entities.InstructionResult> MyInstructionHandler(Entities.RequestDto request)
{
// Your logic here
var result = new Entities.InstructionResult();
// Populate result based on the request
return await Task.FromResult(result);
}
Use the AddInstruction
method to register your new instruction. Here is an example:
PCBI_RemoteControlServer.PCBI_Connection connection; // This is a placeholder. Get the currenly loaded Plugin instance.
connection.AddInstruction("MyInstruction", MyInstructionHandler, "This is a sample instruction.");
Here is a complete example that demonstrates how to add an instruction:
using System;
using System.Threading.Tasks;
using PCBI_RemoteControlServer;
public async Task<Entities.InstructionResult> MyInstructionHandler(Entities.RequestDto request)
{
var result = new Entities.InstructionResult();
// Implement your logic here
return await Task.FromResult(result);
}
public void RegisterInstruction()
{
PCBI_RemoteControlServer.PCBI_Connection connection; // This is a placeholder. Get the currenly loaded Plugin instance.
connection.AddInstruction("MyInstruction", MyInstructionHandler, "This is a sample instruction.");
}
Once an instruction is made available, it can be queued with the HTTP request POST /instructions
described on the homepage.
Scripts are sequences of instructions that automate tasks in PCB-Investigator. They can be used to perform complex operations, such as data analysis, file manipulation, and more.
Scripts can be added in PCB-Investigator in the `URI Editor` of this plugin.
There you will also find an example script.
Once a script is registered, it can be executed with the script
-instruction.