Skip to content

Profinity V2 IS NOW IN EARLY ADOPTER RELEASE

Profinity V2 is available now in Early Adopter Release. To support this release we are making the product available to our Early Adopter Community. If you have any issues or feedback please report it via our support portal or via the Feedback form in the Profinity Admin menu.

Script Types in Profinity

Profinity supports three basic types of scripts, each with specific use cases and execution contexts. This document explains the differences between these script types and when to use each one. Understanding these script types is crucial for developing effective automation and monitoring solutions in Profinity.

Script Type Description Best For Not Recommended For
Run A Run Script, can simply be run by the operator, or scheduled to be run on a regular basis. They are typically used do jobs that are short, sharp and don't require a lot of state management - One-time operations
- Manual tasks
- Testing
- Troubleshooting
- Scheduled tasks
- Continuous monitoring
- Real-time responses
Receive Receive Scripts are scripts that can be setup to run each time a particular CAN Packet is received. They are generally used to respond to the receipt of a packet with a reply message - CAN message processing
- Real-time data handling
- Protocol implementation
- Long-running operations
- System configuration
- Manual tasks
Service Service Scripts implement full lifecycle management and generally are designed for tasks that need to run for a long time - Continuous monitoring
- Long-running tasks
- Critical services
- System-level operations
- Quick responses
- One-time operations
- Manual tasks

Best Practices

Important Please Remember that

When you are using Profinity scripting you are adding functionality to the core of Profinity itself. If you write inefficient code, leak memory or resources or just do some thing silly, that code is running inside Profinity. Think about your code and if you see negative impacts on Profinity when your scripts are run, review your code.

Best Practice for Profinity Scripting, include:

Choose the Right Type of Script Execution

  • Use Run scripts for manual or scheduled operations
  • Use Receive scripts for CAN message processing
  • Use service scripts for critical, long-running operations

Be Efficient with Resource Management

  • Keep scripts efficient
  • Monitor resource usage
  • Clean up resources when scripts end
  • Consider system load when scheduling tasks
  • Implement proper service recovery mechanisms

Use Error Handling

  • Implement proper error handling
  • Log errors appropriately to the Profinity Logs
  • Handle timeouts and resource limits
  • Consider retry mechanisms for scheduled tasks
  • Implement service health monitoring

Use State Management With Required

  • Use appropriate state scope (State vs GlobalState)
  • Clean up state when no longer needed
  • Handle state conflicts in service scripts
  • Consider state persistence for scheduled tasks
  • Implement proper service state management