Integration Philosophy: FrameworX provides true bidirectional integration between Python and .NET, not just Python scripting capability. This design leverages Python's extensive data science libraries while maintaining .NET's performance and reliability for industrial control.
The platform requires Python 3.7 or later, delivering significant performance improvements over Python 2. According to Python.org benchmarks, Python 3 runs approximately 10-30% faster than Python 2 in most scenarios, with some operations seeing 5x improvements.
Language | Best For | Performance | Key Features |
---|---|---|---|
C# | Complex logic, performance-critical operations | Excellent | Full .NET access, strongly typed, IntelliSense |
Python | Data analysis, ML integration | Good | Extensive libraries, NumPy/Pandas support |
Python code runs within FrameworX's Script Tasks and Classes, with full access to tags and namespaces:
# Python accessing FrameworX tags
@Tag.Temperature = @Tag.SetPoint + 5
result = ProcessData(@Tag.ProductionRate)
Execute external Python files while maintaining tag access:
result = TK.ExecutePythonShell("analytics.py", [@Tag.Input1, @Tag.Input2])
@Tag.Result = result
When the editor is used to edit Script Tasks, you can test the scripts directly, using the Play |
3. Cross-Language Calls
C# calling Python:
// C# code calling Python class
var result = @Script.Class.PythonAnalytics.ProcessML(data);
Python calling C#:
# Python code calling C# method
result = @Script.Class.CSharpLogic.Calculate(param1, param2)
Python code accesses FrameworX objects directly through the same '@' notation used in C#:
No marshaling, conversion, or intermediate layers, Python operates on the same objects as .NET code.
Each solution specifies its Python interpreter, enabling:
# Use scikit-learn for anomaly detection
from sklearn.ensemble import IsolationForest
model = IsolationForest()
data = GetHistorianData(@Tag.Equipment)
anomalies = model.fit_predict(data)
# Pandas for production analytics
import pandas as pd
df = pd.DataFrame(@Dataset.Query("SELECT * FROM Production"))
daily_avg = df.groupby('Day')['Output'].mean()
@Tag.DailyAverage = daily_avg.iloc[-1]
# Implement proprietary protocol
import struct
packet = struct.pack('>HH', @Tag.DeviceID, @Tag.Command)
response = SendCustomProtocol(packet)
@Tag.Response = struct.unpack('>H', response)[0]
Operation Type | Recommended | Reason |
---|---|---|
Real-time control loops | C# | Deterministic execution, minimal latency |
Statistical analysis | Python | NumPy/Pandas optimized C libraries |
Tag calculations | C# | Direct memory access, no interpreter |
Machine learning inference | Python | Scikit-learn, TensorFlow ecosystems |
Database operations | Either | Both have excellent SQL support |
Python and .NET Integration LinksExplanation - to understand concepts→ Platform / Technology Foundation / Python and .NET Integration Tutorials - to learn by doing→ Tutorials / Technology Learning / Python and .NET Integration Reference - technical details→ Technical Reference / Programming and APIs Reference / Python and .NET Integration |