Auto: focas-f1e — operator messages + block text

Closes #261
This commit is contained in:
Joseph Doherty
2026-04-25 14:49:11 -04:00
parent 84913638b1
commit cc757855e6
5 changed files with 507 additions and 0 deletions

View File

@@ -141,6 +141,32 @@ internal static class FwlibNative
short length,
ref IODBZOFS buffer);
// ---- Operator messages ----
/// <summary>
/// <c>cnc_rdopmsg3</c> — read FANUC operator messages by class. <paramref name="type"/>:
/// 0 = OPMSG (op-msg ladder/macro), 1 = MACRO, 2 = EXTERN (external operator message),
/// 3 = REJ-EXT (rejected EXTERN). <paramref name="length"/>: per <c>fwlib32.h</c> the
/// buffer is <c>4 + 256 = 260</c> bytes per message slot — single-slot reads (length 260)
/// return the most-recent message in that class. Issue #261, plan PR F1-e.
/// </summary>
[DllImport(Library, EntryPoint = "cnc_rdopmsg3", CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern short RdOpMsg3(
ushort handle,
short type,
short length,
ref OPMSG3 buffer);
// ---- Currently-executing block ----
/// <summary>
/// <c>cnc_rdactpt</c> — read the currently-executing program block text. The
/// reply struct holds the program / sequence numbers + the active block as a
/// null-padded ASCII string. Issue #261, plan PR F1-e.
/// </summary>
[DllImport(Library, EntryPoint = "cnc_rdactpt", CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern short RdActPt(ushort handle, ref ODBACTPT buffer);
// ---- Structs ----
/// <summary>
@@ -241,6 +267,37 @@ internal static class FwlibNative
public byte[] Data;
}
/// <summary>
/// OPMSG3 — single-slot operator-message read buffer per <c>fwlib32.h</c>. Per Fanuc
/// reference: <c>short datano</c> + <c>short type</c> + <c>char data[256]</c>. The
/// text is null-terminated + space-padded; the managed side trims trailing nulls /
/// spaces before publishing. Length = 4 + 256 = 260 bytes; total 256 wide enough
/// for the longest documented operator message body (issue #261).
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct OPMSG3
{
public short Datano;
public short Type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public byte[] Data;
}
/// <summary>
/// ODBACTPT — current-block read buffer per <c>fwlib32.h</c>. Per Fanuc reference:
/// <c>long o_no</c> (currently active O-number) + <c>long n_no</c> (sequence) +
/// <c>char data[256]</c> (active block text). The text is null-terminated +
/// space-padded; trimmed before publishing for stable round-trip (issue #261).
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ODBACTPT
{
public int ONo;
public int NNo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public byte[] Data;
}
/// <summary>ODBST — CNC status info. Machine state, alarm flags, automatic / edit mode.</summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ODBST