• Articles
  • API reference
  • Previous Versions
Show / Hide Table of Contents
  • Introduction
  • How to
    • Implement recipe management
    • Connect to a influx database
    • Invoke C# from PLC
    • How to access TwinController
    • How to write documentation blocks
    • How to make Inxton compiler ignore unknown syntax
    • Cyclic, Synchronous and Batched access
    • How to generate UI
    • How to include TcOpen in your project 🔗
    • Video how tos 🔗
  • Core
    • Introduction
    • Compiler
      • Intro to compiler
      • Added Properties
      • Attributes
      • Documentation Block
      • Fake Comments
      • Ignoring Parts Of Code
      • Twin Controller
      • Twin Objects
      • Twins
    • Connector
      • About connector
      • Primitive Twins
  • Essentials
    • Introduction
    • Rendering engine
      • Generating user interface
      • How it works
      • Presentation types
    • Controls
      • Controls
    • Styling your app
      • Styling your application
      • Color system
      • How to apply styles
      • Override default colors
      • Buttons
    • Conmponents convetions 🔗
  • TcOpen 🔗
    • Messaging, Logging, sequences 🔗

How to invoke C# code from PLC

In your PLC project create an instance of fbRemoteExec

FUNCTION_BLOCK fbApp EXTENDS VortexBase.fbVortexApp 
VAR
	CSharp : VortexBase.fbRemoteExec;
	Counter : INT;
END_VAR 
-------
Counter := Counter +1;
IF Counter > 100 THEN
  CSharp.Invoke();
END_IF

Run the Inxton builder. In your C# Code

private static fbApp MAIN;

static void Main(string[] args)
{
    Entry.Plc.Connector.BuildAndStart();
    MAIN = Entry.Plc.MAIN.App;
    MAIN.CSharp.Initialize(MethodToExecuteWhenInvokeIsCalledInPlc);
    Console.ReadKey();
}

private static bool MethodToExecuteWhenInvokeIsCalledInPlc()
{
    Console.WriteLine("Invoked from PLC");
    MAIN.Counter.Cyclic = 0;
    return true;
}
}

Results

inxton breakpoint plc project

Breakpoint work too!

inxton breakpoint plc project

  • Improve this Doc
In This Article
Back to top

Generated by DocFX | Developed with ❤ at MTS - putting the heart into manufacturing.