APIs, concepts, guides, and more
io-iopoint-user-buffer.cs
/* This sample demonstrates how to create simulated IOPoints using user buffer memory.
Shows how to create IOPoint objects from base memory addresses and test their functionality
without requiring actual network IO hardware.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 IO: IOPoint User Buffer");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
const int INPUT_INDEX = 0;
const int OUTPUT_INDEX = 1; // the PDO Index in the user buffer
// get user buffer address for simulated IO point storage
UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0);
// create simulated IOPoints based on memory address and index
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX);
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX);
// get & set an output
bool outVal = output0.Get();
output0.Set(outVal);
Console.WriteLine($"Output 0 value: {outVal}");
// test input operations by directly writing to memory
controller.MemorySet(input0.AddressGet(), 1);
bool inVal = input0.Get();
Console.WriteLine($"Input 0 memory set to 1, value: {inVal}");
controller.MemorySet(input0.AddressGet(), 0);
inVal = input0.Get();
Console.WriteLine($"Input 0 memory set to 0, value: {inVal}");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
uint64_t AddressGet()
Get the Host Address for the I/O point.
void Set(bool state)
Set the state of a Digital Output.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
static IOPoint * CreateDigitalOutput(Axis *axis, RSIMotorDedicatedOut motorDedicatedOutNumber)
Create a Digital Output from an Axis' Dedicated Output bits.
bool Get()
Get the state of Digital Input or Output.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
Definition rsi.h:11559
void MemorySet(uint64_t address, int32_t data)
Write a value to controller memory.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:405