Разработка интерпретаторов
  • Разработка интерпретаторов
v3.0.3
Search Results for

    Show / Hide Table of Contents

    Inspect NC programs

    When to use

    Whenever the task depends on what the programs actually say: before adding or changing a word, when a program behaves differently from another one, when programs from another postprocessor or CAM system arrive. An interpreter is written for the programs the machine really runs, not for the manual's examples alone.

    Workflow

    1. Collect every program and keep the originals (below).
    2. Read the machine: axis addresses, channels, machine M codes.
    3. Take the census of words and spellings.
    4. Give every form a status and report what the interpreter must change.

    Collect every program

    Ask for, and look for, all sources — each one brings variants the others do not:

    • programs generated by the machine's postprocessor;
    • programs written or edited by hand at the machine;
    • programs from other CAM systems used on the same machine;
    • examples in the customer's own documents (a .docx or .pdf with sample programs counts);
    • programs inside archives attached to the request — unpack them, including nested archives;
    • programs you generate yourself from the CAM project with the customer's postprocessor. If the project's operations output their cycles as plain moves, switch them to canned-cycle output: that is the only way to get the real cycle calls the postprocessor writes. Where the postprocessor and the manual disagree, record both.

    Keep the originals unchanged; copy them into the workspace, one folder per source, so you can say later where a variant came from. If two sources contain the same files, compare them byte for byte and keep one.

    Read the encoding before reading the text. Programs from some controls are not UTF-8 (GBK, CP1251 and others occur), and a file that mixes two encodings may not open in the CAM system at all — that is a property of the file, not of the interpreter; report it and leave it out of the interpreter work. When you take program text out of a Word document, keep the minus signs and hyphens: Word stores some of them as separate elements, and a naive text extraction drops them, turning Z-6 into Z6.

    Know the machine

    The interpreter moves the axes of the machine schema, so the names in the program must be mapped to them.

    • Read the axis addresses from the machine schema of the CAM project (the machine file of the project lists an Address for every axis — for example X1, Y1, Z1, B1, Cs1, X2, Z2). A project file is a container, not a zip archive: take the machine file from the machine folder the project uses, or ask the user for it.
    • Read the channels: which axes, spindles and turrets belong to which channel.
    • Get the machine maker's M code table if there is one. Codes that only switch something on the machine (clamps, doors, coolant variants, measuring) do not move it, but the interpreter must recognize them. Axis brakes are a case of their own: the SDK can switch the machine's automatic brakes, so ask whether brake codes must show in the simulation.

    Take the census

    Strip strings and comments first — the comment characters of this control from its manual and from the interpreter's analyzer settings (;, (…), "…" strings and others) — then sort every word into a category, keeping its spelling form separate. The categories that matter:

    Category Examples Why it matters
    G functions G0, G17, G96, G710 each needs a register value and a handler
    M functions M3, M30, M120, M8 standard ones are handled by the interpreter, machine ones go to the INI file
    Axes without = X10, B90 the kernel reads them as register values
    Axes with = B1=90, C1=DC(0), Cs1=IC(5) numbered axes and dimension functions are read by the interpreter itself
    Spindles with a number S2=3000, M1=3, SPOS[1]=0 which spindle the word belongs to
    Other addresses with = CR=17.5, TURN=2, T="b3" values that are expressions or strings
    Calls with brackets CYCLE81(…), MSG("…"), WORKPIECE(…) cycles and procedures
    Keywords TRAORI, DIAMON, SUPA, MCALL modes and transformations
    Parameters R80=400, X=R80 values computed from expressions

    For every form record how many programs use it and two or three of them. A form used by one program in fifty is still a form the interpreter must handle or name.

    Map the census to the interpreter

    For each form decide one of:

    Status Meaning What to do
    Supported the interpreter simulates it correctly nothing; keep a program that uses it in the test set
    INI file a variant of something supported: another axis name, a machine M code, a word without effect add it to InterpreterSettings.ini, adding the key once in code if the interpreter does not have it yet (see "Make variations a setting, not a code change" in "Develop .NET interpreters" (develop-dotnet-interpreter))
    Code a behavior that changes the toolpath and is not implemented implement it, with a test program
    Not simulated the simulation cannot show it, or the control's behavior is unknown read it, warn once per program, write it in the README

    The quickest way to fill the table is a run: send every program through the interpreter (see "Run the programs" in "Verify interpretation" (verify-interpretation)) and collect the warnings of the CAM log — each unknown word, unknown axis and unsupported cycle has its own message. Then look at the forms that produced no warning but may still be wrong: a word the kernel skipped silently, an axis that moved in a program and stood still in another.

    The kernel writes its messages about the words it reads, and the interpreter's own Kernel.Log lines, only when Use logs and Use log interaction with the interpreter are on (System setup → Additional → Logs, the same in the CAM system and in Tuner). Turn both on before the run, or the log stays empty.

    Rules

    • Never edit a customer program to make it pass. The interpreter must read the programs as the machine gets them.
    • Do not conclude "the program never uses X" from one program; check all of them, and say how many you checked.
    • Examples written for another machine (a generic manual, a document for a different machine) show what the control can do; they are not proof that this machine's programs contain it. Mark which source a form came from.
    • Report axis names together with the machine schema they were checked against, and list every spelling of each axis (B90, B=90, B1=90, B=DC(30)): a name mapping must cover all of them.

    Done means

    Every source of programs is listed with its file count; the census table exists with forms, counts and sample programs; every form has a status; the machine's axis addresses, channels and machine M codes are known; files the CAM system cannot read are named with the reason.

    In this article