add files

This commit is contained in:
2025-11-13 21:07:47 +01:00
parent f065cf7d0f
commit 77d5454629
19 changed files with 1795 additions and 0 deletions
Generated
+14
View File
@@ -0,0 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "connect_demo"
version = "0.0.0"
dependencies = [
"open_wrapper",
]
[[package]]
name = "open_wrapper"
version = "0.1.0"
+16
View File
@@ -0,0 +1,16 @@
[workspace]
members = [
".", # keep the Tauri app in the workspace
"open_wrapper"
]
[package]
name = "connect_demo"
edition = "2021"
build = "build.rs"
[workspace.package]
edition = "2021"
[dependencies]
open_wrapper = { path = "open_wrapper" }
+815
View File
@@ -0,0 +1,815 @@
// =================================================================
// \brief This class provide API for open.dll
// \copyright Copyright (C) Siemens AG 2024 All Rights Reserved.
// Confidential
// =================================================================
using System;
using System.Runtime.InteropServices;
namespace Siemens.SinumerikOne.OpenClientSample
{
public class OpenApiWrapper
{
public enum OpenReturnCodes : int
{
/// <summary>
/// Call was successful
/// </summary>
Ok = 0,
// --------- Application control and Connection ---------
/// <summary>
/// An internal error occurred.
/// </summary>
ErrorInternal = -1001,
/// <summary>
/// SINUMERIK ONE install path not found in registry.
/// </summary>
ErrorVcNotFound = -1002,
/// <summary>
/// CreateProcess of SINUMERIK ONE instance failed.
/// </summary>
ErrorCreateProcess = -1003,
/// <summary>
/// An SINUMERIK ONE instance is already running.
/// </summary>
ErrorAlreadyRunning = -1004,
/// <summary>
/// SINUMERIK ONE close failed.
/// </summary>
ErrorCloseFailed = -1005,
/// <summary>
/// SINUMERIK ONE instance not found.
/// </summary>
ErrorInstanceNotFound = -1006,
/// <summary>
/// The connection to SINUMERIK ONE is occupied.
/// </summary>
ErrorInstanceBusy = -1007,
/// <summary>
/// No connection to SINUMERIK ONE.
/// </summary>
ErrorNoConnection = -1008,
/// <summary>
/// SINUMERIK ONE is not ready for communication.
/// </summary>
ErrorVcNotReady = -1009,
/// <summary>
/// Invalid parameter.
/// </summary>
ErrorInvalidParameter = -1010,
/// <summary>
/// No valid license found. This code is deprecated !
/// </summary>
ErrorNoLicenseDeprecated = -1011,
/// <summary>
/// Connection to SINUMERIK ONE has been closed.
/// </summary>
ErrorConnectionClosed = -1012,
/// <summary>
/// S7DOS simulation mode is active.
/// </summary>
ErrorS7DosSimulationActive = -1013,
/// <summary>
/// Version incompatible.
/// </summary>
ErrorVersionIncompatible = -1014,
/// <summary>
/// The called feature is not supported by the currently used backend.
/// </summary>
ErrorNotSupportedByBackend = -1015,
/// <summary>
/// At least one Window could not be embedded (blackbox mode).
/// </summary>
WarningWindowEmbedding = 1002,
/// <summary>
/// The Client has a lower(,but comnpatible) version than the Middleware.
/// </summary>
WarningVersionClientOld = 1003,
/// <summary>
/// The Middleware has a lower(but comnpatible) version than the Client.
/// </summary>
WarningVersionMiddlewareOld = 1004,
/// <summary>
/// Detected a lost client connection. Client has to reconnect.
/// </summary>
WarningConnectionCorrupted = 1005,
// --------- File handling (VCPs, startprofiles, etc.) ---------
/// <summary>
/// The file could not be found.
/// </summary>
ErrorFileNotFound = -2001,
/// <summary>
/// There is a project already open.
/// </summary>
ErrorProjectOpen = -2002,
/// <summary>
/// Loading the vcp file failed.
/// </summary>
ErrorLoadFailed = -2003,
/// <summary>
/// No project open.
/// </summary>
ErrorNoProjectOpen = -2004,
/// <summary>
/// File is write protected.
/// </summary>
ErrorWriteProtected = -2005,
/// <summary>
/// Simulation is running.
/// </summary>
ErrorSimRunning = -2006,
/// <summary>
/// Saving the file failed.
/// </summary>
ErrorWriteFailed = -2007,
/// <summary>
/// Closing the project failed.
/// </summary>
ErrorVcpCloseFailed = -2008,
/// <summary>
/// The file is invalid.
/// </summary>
ErrorInvalidFile = -2009,
/// <summary>
/// The selected cnc software is not available.
/// </summary>
ErrorCncSwUnavailable = -2010,
/// <summary>
/// The file could not be created.
/// </summary>
ErrorFileCreationFailed = -2011,
/// <summary>
/// The frontend not installed.
/// </summary>
ErrorFrontendNotInstalled = -2012,
/// <summary>
/// The no license for the frontend. This code is deprecated !
/// </summary>
ErrorFrontendNotLicensedDeprecated = -2013,
/// <summary>
/// The path to the project file is too long.
/// </summary>
ErrorFilePathTooLong = -2014,
/// <summary>
/// The selected nck scaling is invalid.
/// </summary>
ErrorInvalidNckscaling = -2015,
/// <summary>
/// The selected ncu number is invalid.
/// </summary>
ErrorInvalidNcunumber = -2016,
// --------- Simulation Control ---------
/// <summary>
/// Starting the simulation failed.
/// </summary>
ErrorStartSimFailed = -3001,
/// <summary>
/// Stopping the simulation failed.
/// </summary>
ErrorStopSimFailed = -3002,
/// <summary>
/// Reseting the simulation failed.
/// </summary>
ErrorResetSimFailed = -3004,
/// <summary>
/// Reseting the simulation failed.
/// </summary>
ErrorSimSpeedInvalid = -3005,
/// <summary>
/// Simulation is not available.
/// </summary>
ErrorSimNotAvailable = -3006,
/// <summary>
/// Simulation is not running.
/// </summary>
ErrorSimNotRunning = -3007,
/// <summary>
/// Simulation is running.
/// </summary>
SimRunning = 3001,
/// <summary>
/// Simulation is not running.
/// </summary>
SimNotRunning = 3002,
// --------- Synchronized Operation ---------
/// <summary>
/// The event is unknown.
/// </summary>
ErrorEventUnknown = -4001,
/// <summary>
/// No events are registered.
/// </summary>
ErrorNoEventsRegistered = -4002,
/// <summary>
/// The simulation got interrupted.
/// </summary>
ErrorSimInterrupted = -4003,
// --------- Data Access ---------
/// <summary>
/// Unknown dictionary entry.
/// </summary>
ErrorUnknownElement = -5001,
/// <summary>
/// The dictionary id is invalid.
/// </summary>
ErrorInvalidDictId = -5002,
/// <summary>
/// Not enough memory for the data.
/// </summary>
ErrorInsufficientMemory = -5003,
/// <summary>
/// Elemente is not an array.
/// </summary>
ErrorNoarray = -5004,
/// <summary>
/// Wrong type for the data.
/// </summary>
ErrorWrongType = -5005,
/// <summary>
/// Wrong accesrights for the data.
/// </summary>
ErrorInsufficientRights = -5006,
/// <summary>
/// The application is not in the wait state
/// </summary>
ErrorNotInWait = -5007,
/// <summary>
/// No further data available.
/// </summary>
NoMoreData = 5001,
// --------- File Operations ---------
/// <summary>
/// The domain for file system operation is invalid.
/// </summary>
ErrorFileOpInvalidDomain = -6001,
/// <summary>
/// The source path for file system operation is not absolute.
/// </summary>
ErrorFileOpSourcePathNotAbsolute = -6002,
/// <summary>
/// The source file for file system operation does not exist.
/// </summary>
ErrorFileOpSourceFileNotExists = -6003,
/// <summary>
/// The destination path for file system operation is not absolute.
/// </summary>
ErrorFileOpDestinationPathNotAbsolute = -6004,
/// <summary>
/// The destination file or directory for file system operation already exsists.
/// </summary>
ErrorFileOpDestinationAlreadyExists = -6005,
/// <summary>
/// The destination directory for file system operation does not exists.
/// </summary>
ErrorFileOpDestinationDirectoryNotExists = -6006,
/// <summary>
/// The directory for file system operation does not exists.
/// </summary>
ErrorFileOpDirectoryNotExists = -6007,
/// <summary>
/// The directory for file system operation is not empty.
/// </summary>
ErrorFileOpDirectoryNotEmpty = -6008,
/// <summary>
/// A file or a part program can't select.
/// </summary>
ErrorFileSelectNotPossible = -6009,
/// <summary>
/// The channel does not exists.
/// </summary>
ErrorChannelNotExists = -6010,
/// <summary>
/// The file is in edit mode.
/// </summary>
ErrorFileUsed = -6011,
// --------- License handling ---------
/// <summary>
/// General error, licensing failed.
/// </summary>
ErrorLicenseNoLicense = -7001,
/// <summary>
/// The application mentioned in the license file, does not match any known application in the xMVM context.
/// </summary>
ErrorLicenseUnknownApplication = -7002,
/// <summary>
/// The frontend is not CMVM or RMVM.
/// </summary>
ErrorLicenseUnknownFrontend = -7003,
/// <summary>
/// The connection to the license server could not be established.
/// </summary>
ErrorLicenseNoConnection = -7004,
/// <summary>
/// The license handler could not be instantiated.
/// </summary>
ErrorLicenseNoLicenseHandler = -7005,
/// <summary>
/// The Server is busy, cant read, cant write.
/// </summary>
ErrorLicenseErrorAtServerSite = -7006,
/// <summary>
/// The license for a particular feature is not available.
/// </summary>
ErrorLicenseOptionalLicenseKeyNotAvailable = -7007,
/// <summary>
/// The license for a particular feature could not be granted.
/// </summary>
ErrorLicenseOptionalLicenseKeyNotGranted = -7008,
/// <summary>
/// The license for a particular feature could not be locked at the license server.
/// </summary>
ErrorLicenseOptionalLicenseNotAqcuired = -7009,
/// <summary>
/// The validation of the license file failed.
/// </summary>
ErrorLicenseOptionalLicenseCheckFailed = -7010,
/// <summary>
/// The acquistion of a license was not successfull.
/// </summary>
ErrorLicenseKeyNotAvailable = -7011,
/// <summary>
/// The main license key could not be granted.
/// </summary>
ErrorLicenseKeyGrantFailed = -7012,
/// <summary>
/// The main license key could not be released.
/// </summary>
ErrorLicenseKeyReleaseFailed = -7013,
/// <summary>
/// The main license key is invalid.
/// </summary>
ErrorLicenseInvalid = -7014,
/// <summary>
/// The license key is already in use.
/// </summary>
ErrorLicenseAlreadyInUse = -7015,
/// <summary>
/// The validation of the license key failed.
/// </summary>
ErrorLicenseCheckFailed = -7016,
/// <summary>
/// All licenses from the license pool are currently in use.
/// </summary>
ErrorLicenseAllLicensesInUse = -7017,
/// <summary>
/// The type of the used license is unknown.
/// </summary>
ErrorLicenseUnknownLicense = -7018,
}
public enum OpenDictionaryElementType
{
Bool = 1,
Integer8Bit = 2,
UInteger8Bit = 3,
Integer16Bit = 4,
UInteger16Bit = 5,
Integer32Bit = 6,
UInteger32Bit = 7,
Integer64Bit = 8,
UInteger64Bit = 9,
Double = 10,
String = 11,
IntegerArray32Bit = 12,
UIntegerArray64Bit = 13,
BoolArray = 14,
DoubleArray = 15,
StringArray = 16,
UIntegerArray32Bit = 17,
UIntegerArray16Bit = 18,
UIntegerArray8Bit = 19,
}
public enum OpenEventMaskDefinition : ulong
{
Unknown = 0x0000000000000000,
NckFirstIpo = 0x0000000000000008,
NckBootReady = 0x0000000000000004,
NckIpo = 0x0000000000000001,
NckChannelNewMotion = 0x0000000000000100,
NckChannelNewBlock = 0x0000000000000200,
NckChannelConfigChanged = 0x0000000000000400,
NckChannelStartPositioningMotion = 0x0000000000000800,
NckChannelEndPositioningMotion = 0x0000000000001000,
NckChannelLengthSlicePath = 0x0000000000001001,
NckChannelLengthSlicePositioning = 0x0000000000001002,
NckChannelAngleSlicePositioning = 0x0000000000001003,
NckChannelAngleSliceOrientation = 0x0000000000001004,
NckChannelStateChanged = 0x0000000000001005,
NckChannelProgramFinished = 0x0000000000001006,
PlcOb1 = 0x0000000000010000,
PlcHwConfigChanged = 0x0000000000020000,
PlcAcyclicCommunication = 0x0000000000040000,
ContentChanged = 0x0001000000000000,
ResetStarted = 0x0002000000000000,
ResetFinished = 0x0004000000000000,
}
public enum OpenAxisMode
{
/// <summary>
/// axisMode undefined
/// </summary>
None = 0,
/// <summary>
/// interpolation mode
/// </summary>
Interpolation = 1,
/// <summary>
/// positioning mode
/// </summary>
Positioning = 2,
/// <summary>
/// speed mode turning left
/// </summary>
SpeedLeft = 3,
/// <summary>
/// speed mode turning right
/// </summary>
SpeedRight = 4,
/// <summary>
/// speed mode stopped
/// </summary>
SpeedStop = 5,
/// <summary>
/// following axis - no specified type
/// </summary>
Following = 6,
}
public enum OpenAxisReferenceState
{
/// <summary>
/// reference state undefined
/// </summary>
None = 0,
/// <summary>
/// not referenced
/// </summary>
NotReferenced = 1,
/// <summary>
/// referenced
/// </summary>
Referenced = 2,
/// <summary>
/// referencing not required
/// </summary>
ReferenceNotRequired = 3,
}
public enum OpenMotionType
{
/// <summary>
/// value undefined / OEMIPO1 / OEMIPO2 / Involute
/// </summary>
None = 0,
/// <summary>
/// rapid motion independent from $AC_G0MODE
/// </summary>
Rapid = 1,
/// <summary>
/// linear motion
/// </summary>
Linear = 2,
/// <summary>
/// circle motion G2 / G3 / CIP / CT
/// </summary>
Circle = 3,
/// <summary>
/// A/B/C-Spline / Poly
/// </summary>
Spline = 4,
/// <summary>
/// G33 / G331 / G332 / G34 / G35
/// </summary>
Thread = 5,
/// <summary>
/// involute INVCW / INVCCW
/// </summary>
Involute = 6,
}
public enum OpenCircleDirection
{
/// <summary>
/// value undefined
/// </summary>
None = 0,
/// <summary>
/// clockwise
/// </summary>
Cw = 1,
/// <summary>
/// counter clockwise
/// </summary>
Ccw = 2,
}
public enum OpenOperatingMode
{
/// <summary>
/// no operating mode
/// </summary>
None = 0,
/// <summary>
/// operating mode auto
/// </summary>
Auto = 1,
/// <summary>
/// operating jog
/// </summary>
Jog = 2,
/// <summary>
/// operating mode mda
/// </summary>
Mda = 3,
}
public enum OpenChannelState
{
/// <summary>
/// no channel state
/// </summary>
None = 0,
/// <summary>
/// channel state activated
/// </summary>
Activated = 1,
/// <summary>
/// channel state stopped
/// </summary>
Stopped = 2,
/// <summary>
/// channel state reseted
/// </summary>
Reseted = 3,
}
public enum OpenAxisType
{
/// <summary>
/// axisType undefined
/// </summary>
None = 0,
/// <summary>
/// linear axis
/// </summary>
Linear = 1,
/// <summary>
/// round axis
/// </summary>
Rotatory = 2,
/// <summary>
/// modulo axis
/// </summary>
Modulo = 3,
/// <summary>
/// spindle axis
/// </summary>
Spindle = 4,
}
public enum OpenProjectStates
{
Closed = 1,
Opening = 2,
Open = 3,
Booting = 4,
RunningOrPaused = 5,
ShuttingDown = 6,
Closing = 7,
Resetting = 8,
Saving = 9,
Error = 10,
}
[DllImport("open.dll", EntryPoint = "startApplication", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes StartApplication(string strProfileFileName);
[DllImport("open.dll", EntryPoint = "stopApplication", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes StopApplication();
[DllImport("open.dll", EntryPoint = "connect", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes Connect();
[DllImport("open.dll", EntryPoint = "disconnect", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes Disconnect();
[DllImport("open.dll", EntryPoint = "openProject", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes OpenProject(string strFileName);
[DllImport("open.dll", EntryPoint = "createProject", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes CreateProject(string strFileName, string strVersion);
[DllImport("open.dll", EntryPoint = "createProjectWithScaling", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes CreateProjectWithScaling(string strFileName, string strVersion, string strNckScaling);
[DllImport("open.dll", EntryPoint = "createProjectWithScalingNCUNumber", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes CreateProjectWithScalingNCUNumber(string strFileName, string strVersion, string strNckScaling, UInt32 ncuNumber);
[DllImport("open.dll", EntryPoint = "saveProject", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes SaveProject();
[DllImport("open.dll", EntryPoint = "closeProject", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes CloseProject();
[DllImport("open.dll", EntryPoint = "bootController", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes BootController();
[DllImport("open.dll", EntryPoint = "shutdownController", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ShutdownController();
[DllImport("open.dll", EntryPoint = "resetController", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ResetController();
[DllImport("open.dll", EntryPoint = "registerForEvents", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes RegisterForEvents(UInt32 nEventListLength, IntPtr pEventList);
[DllImport("open.dll", EntryPoint = "unregisterEvents", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes UnregisterEvents();
[DllImport("open.dll", EntryPoint = "waitForEvents", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WaitForEvents();
[DllImport("open.dll", EntryPoint = "continueSimulation", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ContinueSimulation();
[DllImport("open.dll", EntryPoint = "getDictionaryId", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetDictionaryId(string strDictionaryElement, ref UInt32 pDictionaryId);
[DllImport("open.dll", EntryPoint = "registerWatch", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes RegisterWatch(UInt32 nWatchListLength, IntPtr pDictionaryIdList);
[DllImport("open.dll", EntryPoint = "unregisterWatch", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes UnregisterWatch();
[DllImport("open.dll", EntryPoint = "getDictionaryElementType", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetDictionaryElementType(UInt32 nDictionaryId, ref byte pValue);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger64BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger64BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, UInt64[] pValueList);
[DllImport("open.dll", EntryPoint = "readSignedInteger32BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadSignedInteger32BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, Int32[] pValueList);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger32BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger32BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, UInt32[] pValueList);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger16BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger16BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, UInt16[] pValueList);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger8BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger8BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, byte[] pValueList);
[DllImport("open.dll", EntryPoint = "readBoolArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadBoolArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] bool[] pValueList);
[DllImport("open.dll", EntryPoint = "readDoubleArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadDoubleArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, double[] pValueList);
[DllImport("open.dll", EntryPoint = "readString", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadString(UInt32 nDictionaryId, UInt32 nStringMaxLength, IntPtr pString);
[DllImport("open.dll", EntryPoint = "readStringArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadStringArray(UInt32 nDictionaryId, UInt32 nStringArrayMaxLength, UInt32 nStringMaxLength, IntPtr ppStringArray);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger16Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger16Bit(UInt32 nDictionaryId, ref UInt16 pValue);
[DllImport("open.dll", EntryPoint = "readSignedInteger16Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadSignedInteger16Bit(UInt32 nDictionaryId, ref Int16 pValue);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger32Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger32Bit(UInt32 nDictionaryId, ref UInt32 pValue);
[DllImport("open.dll", EntryPoint = "readSignedInteger32Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadSignedInteger32Bit(UInt32 nDictionaryId, ref Int32 pValue);
[DllImport("open.dll", EntryPoint = "readUnsignedInteger64Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadUnsignedInteger64Bit(UInt32 nDictionaryId, ref UInt64 pValue);
[DllImport("open.dll", EntryPoint = "readSignedInteger64Bit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadSignedInteger64Bit(UInt32 nDictionaryId, ref Int64 pValue);
[DllImport("open.dll", EntryPoint = "getNumArrayElements", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetNumArrayElements(UInt32 nDictionaryId, ref UInt32 pNumArrayElements);
[DllImport("open.dll", EntryPoint = "readBit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadBit(UInt32 nDictionaryId, ref bool pValue);
[DllImport("open.dll", EntryPoint = "readBool", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadBool(UInt32 nDictionaryId, ref bool pValue);
[DllImport("open.dll", EntryPoint = "readByte", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadByte(UInt32 nDictionaryId, ref byte pValue);
[DllImport("open.dll", EntryPoint = "readDouble", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadDouble(UInt32 nDictionaryId, ref double pValue);
[DllImport("open.dll", EntryPoint = "readWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadWord(UInt32 nDictionaryId, ref UInt16 pValue);
[DllImport("open.dll", EntryPoint = "readDoubleWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadDoubleWord(UInt32 nDictionaryId, ref UInt32 pValue);
[DllImport("open.dll", EntryPoint = "readLongWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadLongWord(UInt32 nDictionaryId, ref UInt64 pValue);
[DllImport("open.dll", EntryPoint = "readNextEvent", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadNextEvent(ref UInt64 pEvent);
[DllImport("open.dll", EntryPoint = "readNextEventWithNcuIndex", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ReadNextEventWithNcuIndex(ref UInt64 pEvent, ref Int32 pNcuIndex);
[DllImport("open.dll", EntryPoint = "writeBit", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteBit(UInt32 nDictionaryId, bool bValue);
[DllImport("open.dll", EntryPoint = "writeBool", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteBool(UInt32 nDictionaryId, bool bValue);
[DllImport("open.dll", EntryPoint = "writeByte", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteByte(UInt32 nDictionaryId, byte nValue);
[DllImport("open.dll", EntryPoint = "writeDouble", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteDouble(UInt32 nDictionaryId, double dValue);
[DllImport("open.dll", EntryPoint = "writeWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteWord(UInt32 nDictionaryId, UInt16 nValue);
[DllImport("open.dll", EntryPoint = "writeDoubleWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteDoubleWord(UInt32 nDictionaryId, UInt32 nValue);
[DllImport("open.dll", EntryPoint = "writeLongWord", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteLongWord(UInt32 nDictionaryId, UInt64 nValue);
[DllImport("open.dll", EntryPoint = "writeBoolArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteBoolArray(UInt32 nDictionaryId, UInt32 nValueListLength, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] bool[] pValueList);
[DllImport("open.dll", EntryPoint = "getSimulationSpeed", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetSimulationSpeed(ref UInt32 pnPercent);
[DllImport("open.dll", EntryPoint = "setSimulationSpeed", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes SetSimulationSpeed(UInt32 pnPercent);
[DllImport("open.dll", EntryPoint = "getCardPath", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetCardPath(UInt32 nCardPathMaxLength, IntPtr pCardPath);
[DllImport("open.dll", EntryPoint = "getCardPaths", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetCardPaths(UInt32 nCardPathsArrayMaxLength, UInt32 nCardPathMaxLength, IntPtr pCardPaths);
[DllImport("open.dll", EntryPoint = "getFile", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetFile(string strSourceFilePath, string strDestinationFilePath);
[DllImport("open.dll", EntryPoint = "putFile", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes PutFile(string strSourceFilePath, string strDestinationFilePath);
[DllImport("open.dll", EntryPoint = "selectFile", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes SelectFile(string strSourceFilePath, string strChannelName);
[DllImport("open.dll", EntryPoint = "deleteFile", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes DeleteFile(string strFilePath);
[DllImport("open.dll", EntryPoint = "deleteDirectory", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes DeleteDirectory(string strDirectoryPath);
[DllImport("open.dll", EntryPoint = "createDirectory", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes CreateDirectory(string strDirectoryPath);
[DllImport("open.dll", EntryPoint = "listDirectory", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ListDirectory(string strDirectoryPath, string strResultFilePath);
[DllImport("open.dll", EntryPoint = "getVersionInformation", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetVersionInformation(string strDestinationFilePath);
[DllImport("open.dll", EntryPoint = "getProjectInformation", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetProjectInformation(string strVcpFilePath, string strDestinationFilePath);
[DllImport("open.dll", EntryPoint = "getCurrentProjectInformation", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetCurrentProjectInformation(string strDestinationFilePath);
[DllImport("open.dll", EntryPoint = "getCurrentProjectState", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetCurrentProjectState(ref Int32 pProjectState);
[DllImport("open.dll", EntryPoint = "importProjectSettings", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ImportProjectSettings(string strFileName, string strImportContentFileName);
[DllImport("open.dll", EntryPoint = "exportProjectSettings", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes ExportProjectSettings(string strFileName);
[DllImport("open.dll", EntryPoint = "writeUnsignedInteger8BitArray", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes WriteUnsignedInteger8BitArray(UInt32 nDictionaryId, UInt32 nValueListMaxLength, byte[] pValueList);
[DllImport("open.dll", EntryPoint = "getNumberOfNCUs", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern OpenReturnCodes GetNumberOfNCUs(ref UInt32 pNumberOfNCUs);
}
}
+43
View File
@@ -0,0 +1,43 @@
use std::{
env,
fs,
io,
path::{Path, PathBuf},
};
fn main() -> io::Result<()> {
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"));
let dll_source_dir = manifest_dir.join("open_wrapper").join("lib");
if !dll_source_dir.exists() {
println!(
"cargo:warning=DLL source directory '{}' not found. Skipping copy.",
dll_source_dir.display()
);
return Ok(());
}
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
// OUT_DIR = target/{profile}/build/<pkg>/out
let profile_dir = out_dir
.ancestors()
.nth(3)
.expect("Unable to compute profile dir from OUT_DIR");
let dest_dir = Path::new(profile_dir);
fs::create_dir_all(&dest_dir)?;
for entry in fs::read_dir(&dll_source_dir)? {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |ext| ext.eq_ignore_ascii_case("dll")) {
let file_name = entry.file_name();
let dest_path = dest_dir.join(&file_name);
fs::copy(&path, &dest_path)?;
}
println!("cargo:rerun-if-changed={}", path.display());
}
Ok(())
}
+5
View File
@@ -0,0 +1,5 @@
[package]
name = "open_wrapper"
version = "0.1.0"
edition.workspace = true
build = "build.rs"
+20
View File
@@ -0,0 +1,20 @@
use std::{env, path::PathBuf};
fn main() {
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR must be set"));
let lib_dir = manifest_dir.join("lib");
println!("cargo:rustc-link-search=native={}", lib_dir.display());
println!("cargo:rerun-if-changed=build.rs");
let open_lib = lib_dir.join("open.lib");
if open_lib.exists() {
println!("cargo:rerun-if-changed={}", open_lib.display());
} else {
println!(
"cargo:warning=Expected to find open.lib in '{}'. Copy the vendor import library there.",
lib_dir.display()
);
}
}
Binary file not shown.
+75
View File
@@ -0,0 +1,75 @@
LIBRARY open
EXPORTS
bootController
closeProject
connect
continueSimulation
createDirectory
createProject
createProjectWithScaling
createProjectWithScalingNCUNumber
deleteDirectory
deleteFile
disconnect
exportProjectSettings
getCardPath
getCardPaths
getCurrentProjectInformation
getCurrentProjectState
getDictionaryElementType
getDictionaryId
getFile
getNumArrayElements
getNumberOfNCUs
getProjectInformation
getSimulationSpeed
getVersionInformation
importProjectSettings
listDirectory
openProject
putFile
readBit
readBool
readBoolArray
readByte
readDouble
readDoubleArray
readDoubleWord
readLongWord
readNextEvent
readNextEventWithNcuIndex
readSignedInteger16Bit
readSignedInteger32Bit
readSignedInteger32BitArray
readSignedInteger64Bit
readString
readStringArray
readUnsignedInteger16Bit
readUnsignedInteger16BitArray
readUnsignedInteger32Bit
readUnsignedInteger32BitArray
readUnsignedInteger64Bit
readUnsignedInteger64BitArray
readUnsignedInteger8BitArray
readWord
registerForEvents
registerWatch
resetController
saveProject
selectFile
setSimulationSpeed
shutdownController
startApplication
stopApplication
unregisterEvents
unregisterWatch
waitForEvents
writeBit
writeBool
writeBoolArray
writeByte
writeDouble
writeDoubleWord
writeLongWord
writeUnsignedInteger8BitArray
writeWord
Binary file not shown.
Binary file not shown.
+99
View File
@@ -0,0 +1,99 @@
Dump of file C:\Users\chris\Downloads\vmx_open_api_examples_V1.5.1\11_Rust\rust_wrapper\open_wrapper\lib\open.dll
File Type: DLL
Section contains the following exports for open.dll
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
73 number of functions
73 number of names
ordinal hint RVA name
1 0 00002990 bootController
2 1 00002720 closeProject
72 2 000015A0 connect
3 3 00003850 continueSimulation
4 4 0000CCA0 createDirectory
5 5 00001CF0 createProject
6 6 00001F80 createProjectWithScaling
7 7 00002210 createProjectWithScalingNCUNumber
8 8 0000CA30 deleteDirectory
9 9 0000C7C0 deleteFile
10 A 00001810 disconnect
11 B 0000DE30 exportProjectSettings
12 C 0000BAF0 getCardPath
13 D 0000BD80 getCardPaths
14 E 0000D6C0 getCurrentProjectInformation
15 F 0000D930 getCurrentProjectState
16 10 00004250 getDictionaryElementType
17 11 00003AC0 getDictionaryId
18 12 0000C010 getFile
19 13 00007FE0 getNumArrayElements
20 14 0000E430 getNumberOfNCUs
21 15 0000D430 getProjectInformation
22 16 0000B610 getSimulationSpeed
23 17 0000D1A0 getVersionInformation
24 18 0000DBA0 importProjectSettings
25 19 0000CF10 listDirectory
26 1A 00001A80 openProject
27 1B 0000C2A0 putFile
28 1C 00008270 readBit
29 1D 000085E0 readBool
30 1E 000057A0 readBoolArray
31 1F 00008950 readByte
32 20 00008D70 readDouble
33 21 00005B60 readDoubleArray
34 22 00009410 readDoubleWord
35 23 000096A0 readLongWord
36 24 00009930 readNextEvent
37 25 00009BA0 readNextEventWithNcuIndex
38 26 00006B40 readSignedInteger16Bit
39 27 00007380 readSignedInteger32Bit
40 28 000048A0 readSignedInteger32BitArray
41 29 00007BC0 readSignedInteger64Bit
73 2A 00005F20 readString
42 2B 000062B0 readStringArray
43 2C 00006720 readUnsignedInteger16Bit
44 2D 00005020 readUnsignedInteger16BitArray
45 2E 00006F60 readUnsignedInteger32Bit
46 2F 00004C60 readUnsignedInteger32BitArray
47 30 000077A0 readUnsignedInteger64Bit
48 31 000044E0 readUnsignedInteger64BitArray
49 32 000053E0 readUnsignedInteger8BitArray
50 33 00009180 readWord
51 34 000030E0 registerForEvents
52 35 00003D50 registerWatch
53 36 00002E70 resetController
54 37 000024B0 saveProject
55 38 0000C530 selectFile
56 39 0000B880 setSimulationSpeed
57 3A 00002C00 shutdownController
58 3B 000010C0 startApplication
59 3C 00001330 stopApplication
60 3D 00003370 unregisterEvents
61 3E 00003FE0 unregisterWatch
62 3F 000035E0 waitForEvents
63 40 00009E30 writeBit
64 41 0000A0C0 writeBool
65 42 0000B250 writeBoolArray
66 43 0000A350 writeByte
67 44 0000A6F0 writeDouble
68 45 0000AD30 writeDoubleWord
69 46 0000AFC0 writeLongWord
70 47 0000E0A0 writeUnsignedInteger8BitArray
71 48 0000AAA0 writeWord
Summary
1000 .btc
11000 .data
3000 .pdata
32000 .rdata
2000 .reloc
1000 .rsrc
52000 .text
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+545
View File
@@ -0,0 +1,545 @@
#![allow(non_snake_case)]
/// Pointer to a UTF-16 string (wide char) terminated with `0`.
pub type PCWSTR = *const u16;
/// Mutable pointer to a UTF-16 buffer.
pub type PWSTR = *mut u16;
/// Pointer to an array of UTF-16 string pointers.
pub type PPWSTR = *mut PWSTR;
/// 32-bit boolean, mirrors the Win32 `BOOL` layout used by the C API.
pub type Bool32 = i32;
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenReturnCodes {
Ok = 0,
// --------- Application control and Connection ---------
ErrorInternal = -1001,
ErrorVcNotFound = -1002,
ErrorCreateProcess = -1003,
ErrorAlreadyRunning = -1004,
ErrorCloseFailed = -1005,
ErrorInstanceNotFound = -1006,
ErrorInstanceBusy = -1007,
ErrorNoConnection = -1008,
ErrorVcNotReady = -1009,
ErrorInvalidParameter = -1010,
ErrorNoLicenseDeprecated = -1011,
ErrorConnectionClosed = -1012,
ErrorS7DosSimulationActive = -1013,
ErrorVersionIncompatible = -1014,
ErrorNotSupportedByBackend = -1015,
WarningWindowEmbedding = 1002,
WarningVersionClientOld = 1003,
WarningVersionMiddlewareOld = 1004,
WarningConnectionCorrupted = 1005,
// --------- File handling (VCPs, startprofiles, etc.) ---------
ErrorFileNotFound = -2001,
ErrorProjectOpen = -2002,
ErrorLoadFailed = -2003,
ErrorNoProjectOpen = -2004,
ErrorWriteProtected = -2005,
ErrorSimRunning = -2006,
ErrorWriteFailed = -2007,
ErrorVcpCloseFailed = -2008,
ErrorInvalidFile = -2009,
ErrorCncSwUnavailable = -2010,
ErrorFileCreationFailed = -2011,
ErrorFrontendNotInstalled = -2012,
ErrorFrontendNotLicensedDeprecated = -2013,
ErrorFilePathTooLong = -2014,
ErrorInvalidNckscaling = -2015,
ErrorInvalidNcunumber = -2016,
// --------- Simulation Control ---------
ErrorStartSimFailed = -3001,
ErrorStopSimFailed = -3002,
ErrorResetSimFailed = -3004,
ErrorSimSpeedInvalid = -3005,
ErrorSimNotAvailable = -3006,
ErrorSimNotRunning = -3007,
SimRunning = 3001,
SimNotRunning = 3002,
// --------- Synchronized Operation ---------
ErrorEventUnknown = -4001,
ErrorNoEventsRegistered = -4002,
ErrorSimInterrupted = -4003,
// --------- Data Access ---------
ErrorUnknownElement = -5001,
ErrorInvalidDictId = -5002,
ErrorInsufficientMemory = -5003,
ErrorNoarray = -5004,
ErrorWrongType = -5005,
ErrorInsufficientRights = -5006,
ErrorNotInWait = -5007,
NoMoreData = 5001,
// --------- File Operations ---------
ErrorFileOpInvalidDomain = -6001,
ErrorFileOpSourcePathNotAbsolute = -6002,
ErrorFileOpSourceFileNotExists = -6003,
ErrorFileOpDestinationPathNotAbsolute = -6004,
ErrorFileOpDestinationAlreadyExists = -6005,
ErrorFileOpDestinationDirectoryNotExists = -6006,
ErrorFileOpDirectoryNotExists = -6007,
ErrorFileOpDirectoryNotEmpty = -6008,
ErrorFileSelectNotPossible = -6009,
ErrorChannelNotExists = -6010,
ErrorFileUsed = -6011,
// --------- License handling ---------
ErrorLicenseNoLicense = -7001,
ErrorLicenseUnknownApplication = -7002,
ErrorLicenseUnknownFrontend = -7003,
ErrorLicenseNoConnection = -7004,
ErrorLicenseNoLicenseHandler = -7005,
ErrorLicenseErrorAtServerSite = -7006,
ErrorLicenseOptionalLicenseKeyNotAvailable = -7007,
ErrorLicenseOptionalLicenseKeyNotGranted = -7008,
ErrorLicenseOptionalLicenseNotAqcuired = -7009,
ErrorLicenseOptionalLicenseCheckFailed = -7010,
ErrorLicenseKeyNotAvailable = -7011,
ErrorLicenseKeyGrantFailed = -7012,
ErrorLicenseKeyReleaseFailed = -7013,
ErrorLicenseInvalid = -7014,
ErrorLicenseAlreadyInUse = -7015,
ErrorLicenseCheckFailed = -7016,
ErrorLicenseAllLicensesInUse = -7017,
ErrorLicenseUnknownLicense = -7018,
}
impl OpenReturnCodes {
/// Convenience helper that mirrors the old `Ok` check in the C# wrapper.
pub fn is_ok(self) -> bool {
matches!(self, OpenReturnCodes::Ok)
}
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenDictionaryElementType {
Bool = 1,
Integer8Bit = 2,
UInteger8Bit = 3,
Integer16Bit = 4,
UInteger16Bit = 5,
Integer32Bit = 6,
UInteger32Bit = 7,
Integer64Bit = 8,
UInteger64Bit = 9,
Double = 10,
String = 11,
IntegerArray32Bit = 12,
UIntegerArray64Bit = 13,
BoolArray = 14,
DoubleArray = 15,
StringArray = 16,
UIntegerArray32Bit = 17,
UIntegerArray16Bit = 18,
UIntegerArray8Bit = 19,
}
#[repr(u64)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenEventMaskDefinition {
Unknown = 0x0000000000000000,
NckFirstIpo = 0x0000000000000008,
NckBootReady = 0x0000000000000004,
NckIpo = 0x0000000000000001,
NckChannelNewMotion = 0x0000000000000100,
NckChannelNewBlock = 0x0000000000000200,
NckChannelConfigChanged = 0x0000000000000400,
NckChannelStartPositioningMotion = 0x0000000000000800,
NckChannelEndPositioningMotion = 0x0000000000001000,
NckChannelLengthSlicePath = 0x0000000000001001,
NckChannelLengthSlicePositioning = 0x0000000000001002,
NckChannelAngleSlicePositioning = 0x0000000000001003,
NckChannelAngleSliceOrientation = 0x0000000000001004,
NckChannelStateChanged = 0x0000000000001005,
NckChannelProgramFinished = 0x0000000000001006,
PlcOb1 = 0x0000000000010000,
PlcHwConfigChanged = 0x0000000000020000,
PlcAcyclicCommunication = 0x0000000000040000,
ContentChanged = 0x0001000000000000,
ResetStarted = 0x0002000000000000,
ResetFinished = 0x0004000000000000,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenAxisMode {
None = 0,
Interpolation = 1,
Positioning = 2,
SpeedLeft = 3,
SpeedRight = 4,
SpeedStop = 5,
Following = 6,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenAxisReferenceState {
None = 0,
NotReferenced = 1,
Referenced = 2,
ReferenceNotRequired = 3,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenMotionType {
None = 0,
Rapid = 1,
Linear = 2,
Circle = 3,
Spline = 4,
Thread = 5,
Involute = 6,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenCircleDirection {
None = 0,
Cw = 1,
Ccw = 2,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenOperatingMode {
None = 0,
Auto = 1,
Jog = 2,
Mda = 3,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenChannelState {
None = 0,
Activated = 1,
Stopped = 2,
Reseted = 3,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenAxisType {
None = 0,
Linear = 1,
Rotatory = 2,
Modulo = 3,
Spindle = 4,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpenProjectStates {
Closed = 1,
Opening = 2,
Open = 3,
Booting = 4,
RunningOrPaused = 5,
ShuttingDown = 6,
Closing = 7,
Resetting = 8,
Saving = 9,
Error = 10,
}
#[link(name = "open")]
extern "C" {
#[link_name = "startApplication"]
pub fn start_application(str_profile_file_name: PCWSTR) -> OpenReturnCodes;
#[link_name = "stopApplication"]
pub fn stop_application() -> OpenReturnCodes;
#[link_name = "connect"]
pub fn connect() -> OpenReturnCodes;
#[link_name = "disconnect"]
pub fn disconnect() -> OpenReturnCodes;
#[link_name = "openProject"]
pub fn open_project(str_file_name: PCWSTR) -> OpenReturnCodes;
#[link_name = "createProject"]
pub fn create_project(str_file_name: PCWSTR, str_version: PCWSTR) -> OpenReturnCodes;
#[link_name = "createProjectWithScaling"]
pub fn create_project_with_scaling(
str_file_name: PCWSTR,
str_version: PCWSTR,
str_nck_scaling: PCWSTR
) -> OpenReturnCodes;
#[link_name = "createProjectWithScalingNCUNumber"]
pub fn create_project_with_scaling_ncu_number(
str_file_name: PCWSTR,
str_version: PCWSTR,
str_nck_scaling: PCWSTR,
ncu_number: u32
) -> OpenReturnCodes;
#[link_name = "saveProject"]
pub fn save_project() -> OpenReturnCodes;
#[link_name = "closeProject"]
pub fn close_project() -> OpenReturnCodes;
#[link_name = "bootController"]
pub fn boot_controller() -> OpenReturnCodes;
#[link_name = "shutdownController"]
pub fn shutdown_controller() -> OpenReturnCodes;
#[link_name = "resetController"]
pub fn reset_controller() -> OpenReturnCodes;
#[link_name = "registerForEvents"]
pub fn register_for_events(
event_list_length: u32,
event_list: *const OpenEventMaskDefinition
) -> OpenReturnCodes;
#[link_name = "unregisterEvents"]
pub fn unregister_events() -> OpenReturnCodes;
#[link_name = "waitForEvents"]
pub fn wait_for_events() -> OpenReturnCodes;
#[link_name = "continueSimulation"]
pub fn continue_simulation() -> OpenReturnCodes;
#[link_name = "getDictionaryId"]
pub fn get_dictionary_id(
dictionary_element: PCWSTR,
dictionary_id: *mut u32
) -> OpenReturnCodes;
#[link_name = "registerWatch"]
pub fn register_watch(
watch_list_length: u32,
dictionary_id_list: *const u32
) -> OpenReturnCodes;
#[link_name = "unregisterWatch"]
pub fn unregister_watch() -> OpenReturnCodes;
#[link_name = "getDictionaryElementType"]
pub fn get_dictionary_element_type(dictionary_id: u32, value: *mut u8) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger64BitArray"]
pub fn read_unsigned_integer_64_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut u64
) -> OpenReturnCodes;
#[link_name = "readSignedInteger32BitArray"]
pub fn read_signed_integer_32_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut i32
) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger32BitArray"]
pub fn read_unsigned_integer_32_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut u32
) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger16BitArray"]
pub fn read_unsigned_integer_16_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut u16
) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger8BitArray"]
pub fn read_unsigned_integer_8_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut u8
) -> OpenReturnCodes;
#[link_name = "readBoolArray"]
pub fn read_bool_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut bool
) -> OpenReturnCodes;
#[link_name = "readDoubleArray"]
pub fn read_double_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *mut f64
) -> OpenReturnCodes;
#[link_name = "readString"]
pub fn read_string(
dictionary_id: u32,
string_max_length: u32,
string_buffer: PWSTR
) -> OpenReturnCodes;
#[link_name = "readStringArray"]
pub fn read_string_array(
dictionary_id: u32,
string_array_max_length: u32,
string_max_length: u32,
string_array: PPWSTR
) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger16Bit"]
pub fn read_unsigned_integer_16_bit(dictionary_id: u32, value: *mut u16) -> OpenReturnCodes;
#[link_name = "readSignedInteger16Bit"]
pub fn read_signed_integer_16_bit(dictionary_id: u32, value: *mut i16) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger32Bit"]
pub fn read_unsigned_integer_32_bit(dictionary_id: u32, value: *mut u32) -> OpenReturnCodes;
#[link_name = "readSignedInteger32Bit"]
pub fn read_signed_integer_32_bit(dictionary_id: u32, value: *mut i32) -> OpenReturnCodes;
#[link_name = "readUnsignedInteger64Bit"]
pub fn read_unsigned_integer_64_bit(dictionary_id: u32, value: *mut u64) -> OpenReturnCodes;
#[link_name = "readSignedInteger64Bit"]
pub fn read_signed_integer_64_bit(dictionary_id: u32, value: *mut i64) -> OpenReturnCodes;
#[link_name = "getNumArrayElements"]
pub fn get_num_array_elements(
dictionary_id: u32,
num_array_elements: *mut u32
) -> OpenReturnCodes;
#[link_name = "readBit"]
pub fn read_bit(dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes;
#[link_name = "readBool"]
pub fn read_bool(dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes;
#[link_name = "readByte"]
pub fn read_byte(dictionary_id: u32, value: *mut u8) -> OpenReturnCodes;
#[link_name = "readDouble"]
pub fn read_double(dictionary_id: u32, value: *mut f64) -> OpenReturnCodes;
#[link_name = "readWord"]
pub fn read_word(dictionary_id: u32, value: *mut u16) -> OpenReturnCodes;
#[link_name = "readDoubleWord"]
pub fn read_double_word(dictionary_id: u32, value: *mut u32) -> OpenReturnCodes;
#[link_name = "readLongWord"]
pub fn read_long_word(dictionary_id: u32, value: *mut u64) -> OpenReturnCodes;
#[link_name = "readNextEvent"]
pub fn read_next_event(event: *mut u64) -> OpenReturnCodes;
#[link_name = "readNextEventWithNcuIndex"]
pub fn read_next_event_with_ncu_index(event: *mut u64, ncu_index: *mut i32) -> OpenReturnCodes;
#[link_name = "writeBit"]
pub fn write_bit(dictionary_id: u32, value: Bool32) -> OpenReturnCodes;
#[link_name = "writeBool"]
pub fn write_bool(dictionary_id: u32, value: Bool32) -> OpenReturnCodes;
#[link_name = "writeByte"]
pub fn write_byte(dictionary_id: u32, value: u8) -> OpenReturnCodes;
#[link_name = "writeDouble"]
pub fn write_double(dictionary_id: u32, value: f64) -> OpenReturnCodes;
#[link_name = "writeWord"]
pub fn write_word(dictionary_id: u32, value: u16) -> OpenReturnCodes;
#[link_name = "writeDoubleWord"]
pub fn write_double_word(dictionary_id: u32, value: u32) -> OpenReturnCodes;
#[link_name = "writeLongWord"]
pub fn write_long_word(dictionary_id: u32, value: u64) -> OpenReturnCodes;
#[link_name = "writeBoolArray"]
pub fn write_bool_array(
dictionary_id: u32,
value_list_length: u32,
value_list: *const bool
) -> OpenReturnCodes;
#[link_name = "getSimulationSpeed"]
pub fn get_simulation_speed(percent: *mut u32) -> OpenReturnCodes;
#[link_name = "setSimulationSpeed"]
pub fn set_simulation_speed(percent: u32) -> OpenReturnCodes;
#[link_name = "getCardPath"]
pub fn get_card_path(card_path_max_length: u32, card_path: PWSTR) -> OpenReturnCodes;
#[link_name = "getCardPaths"]
pub fn get_card_paths(
card_paths_array_max_length: u32,
card_path_max_length: u32,
card_paths: PPWSTR
) -> OpenReturnCodes;
#[link_name = "getFile"]
pub fn get_file(source_file_path: PCWSTR, destination_file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "putFile"]
pub fn put_file(source_file_path: PCWSTR, destination_file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "selectFile"]
pub fn select_file(source_file_path: PCWSTR, channel_name: PCWSTR) -> OpenReturnCodes;
#[link_name = "deleteFile"]
pub fn delete_file(file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "deleteDirectory"]
pub fn delete_directory(directory_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "createDirectory"]
pub fn create_directory(directory_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "listDirectory"]
pub fn list_directory(directory_path: PCWSTR, result_file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "getVersionInformation"]
pub fn get_version_information(destination_file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "getProjectInformation"]
pub fn get_project_information(
vcp_file_path: PCWSTR,
destination_file_path: PCWSTR
) -> OpenReturnCodes;
#[link_name = "getCurrentProjectInformation"]
pub fn get_current_project_information(destination_file_path: PCWSTR) -> OpenReturnCodes;
#[link_name = "getCurrentProjectState"]
pub fn get_current_project_state(project_state: *mut OpenProjectStates) -> OpenReturnCodes;
#[link_name = "importProjectSettings"]
pub fn import_project_settings(
file_name: PCWSTR,
import_content_file_name: PCWSTR
) -> OpenReturnCodes;
#[link_name = "exportProjectSettings"]
pub fn export_project_settings(file_name: PCWSTR) -> OpenReturnCodes;
#[link_name = "writeUnsignedInteger8BitArray"]
pub fn write_unsigned_integer_8_bit_array(
dictionary_id: u32,
value_list_max_length: u32,
value_list: *const u8
) -> OpenReturnCodes;
#[link_name = "getNumberOfNCUs"]
pub fn get_number_of_ncus(number_of_ncus: *mut u32) -> OpenReturnCodes;
}
+55
View File
@@ -0,0 +1,55 @@
param(
[string]$DllPath = "open_wrapper/lib/open.dll",
[string]$OutputLibPath = "",
[ValidateSet("x64", "x86")]
[string]$Machine = "x64"
)
$errorActionPreference = "Stop"
function Resolve-Tool($name) {
$cmd = Get-Command $name -ErrorAction SilentlyContinue
if (-not $cmd) {
throw "Could not find '$name' on PATH. Run this script from the Visual Studio Developer Command Prompt or add $name.exe to PATH."
}
return $cmd.Path
}
$dumpbin = Resolve-Tool "dumpbin.exe"
$libExe = Resolve-Tool "lib.exe"
if (-not (Test-Path $DllPath)) {
throw "DLL not found: $DllPath"
}
$dllFullPath = (Get-Item $DllPath).FullName
$workDir = Split-Path $dllFullPath -Parent
if ([string]::IsNullOrWhiteSpace($OutputLibPath)) {
$dllBase = [System.IO.Path]::GetFileNameWithoutExtension($dllFullPath)
$OutputLibPath = [System.IO.Path]::Combine($workDir, "$dllBase.lib")
}
$libName = [System.IO.Path]::GetFileNameWithoutExtension($OutputLibPath)
$exportsFile = Join-Path $workDir "$libName.exports"
$defFile = Join-Path $workDir "$libName.def"
Write-Host "Generating exports list from $dllFullPath ..."
& $dumpbin /nologo /exports $dllFullPath | Set-Content -Encoding UTF8 $exportsFile
$lines = Get-Content $exportsFile | Where-Object { $_ -match '^\s+\d+\s+[0-9A-F]+\s+[0-9A-F]+\s+\S+' }
$symbols = $lines | ForEach-Object {
($_.Trim() -split '\s+')[3]
}
if (-not $symbols) {
throw "Failed to parse exports from $dllFullPath. Inspect $exportsFile for details."
}
$defContent = @("LIBRARY $libName", "EXPORTS") + $symbols
$defContent | Set-Content -Encoding ASCII $defFile
Write-Host "Creating import library $OutputLibPath ..."
& $libExe /nologo /def:$defFile /machine:$Machine /out:$OutputLibPath
Write-Host "Done."
+108
View File
@@ -0,0 +1,108 @@
use std::io::{ self, Write };
use open_wrapper::{ self, OpenReturnCodes };
fn main() {
println!("Rust connect demo for open.dll");
println!("(make sure open.dll is discoverable and open.lib is linked)\n");
print_menu();
let stdin = io::stdin();
let mut state = ConnectionState::default();
loop {
print!("> ");
if io::stdout().flush().is_err() {
eprintln!("Failed to flush stdout.");
break;
}
let mut line = String::new();
if stdin.read_line(&mut line).is_err() {
eprintln!("Failed to read input, exiting.");
break;
}
let cmd = line.trim().to_lowercase();
if cmd.is_empty() {
continue;
}
match cmd.as_str() {
"1" | "c" | "connect" => handle_connect(&mut state),
"2" | "d" | "disconnect" => handle_disconnect(&mut state),
// "3" | "g" | "get-speed" => handle_get_speed(),
// "4" | "r" | "realtime" => handle_set_speed(100, "SetSimulationSpeed (100%)"),
// "5" | "m" | "max" => handle_set_speed(u32::MAX, "SetSimulationSpeed (u32::MAX)"),
"h" | "help" | "?" => print_menu(),
"q" | "quit" | "exit" => {
println!("Bye!");
break;
}
_ => println!("Unknown command. Type `help` to see the list of commands."),
}
}
}
#[derive(Default)]
struct ConnectionState {
connected: bool,
}
fn handle_connect(state: &mut ConnectionState) {
if state.connected {
println!("Already connected. Run `disconnect` first if you need a fresh session.");
return;
}
let rc = call_and_report("Connect", || unsafe { open_wrapper::connect() });
if rc.is_ok() {
state.connected = true;
}
}
fn handle_disconnect(state: &mut ConnectionState) {
if !state.connected {
println!("Not connected yet. Use `connect` first.");
return;
}
let rc = call_and_report("Disconnect", || unsafe { open_wrapper::disconnect() });
if rc.is_ok() {
state.connected = false;
}
}
// fn handle_get_speed() {
// println!("GetSimulationSpeed called ...");
// let mut sim_speed = 0u32;
// let rc = unsafe { open_wrapper::get_simulation_speed(&mut sim_speed) };
// if rc.is_ok() {
// println!("Current simulation speed: {sim_speed}%");
// }
// println!("GetSimulationSpeed returned: {rc:?}");
// }
// fn handle_set_speed(value: u32, label: &str) {
// println!("{label} called ...");
// let rc = unsafe { open_wrapper::set_simulation_speed(value) };
// println!("{label} returned: {rc:?}");
// }
fn call_and_report(action: &str, mut op: impl FnMut() -> OpenReturnCodes) -> OpenReturnCodes {
println!("{action} called ...");
let rc = op();
println!("{action} returned: {rc:?}");
rc
}
fn print_menu() {
println!("Commands:");
println!(" (1) connect - connect to the running controller");
println!(" (2) disconnect - disconnect the session");
println!(" (3) get-speed - read the current simulation speed");
println!(" (4) realtime - set speed to 100%");
println!(" (5) max - set speed to u32::MAX");
println!(" (h) help - show this list");
println!(" (q) quit - exit the demo");
}