Ladder99 / fanuc-driver

Configurable Fanuc Focas data collector and post processor.
Apache License 2.0
74 stars 25 forks source link

MTConnect - Program number not showing in Agent #68

Closed MRIIOT closed 2 years ago

MRIIOT commented 2 years ago

Program number is not shown in Agent output.

Trace from CNC shows the below resulting data structure for ProductionData.

2022/10/28 15:36:51.130|TRACE|[production] Veneer arrival invocation result:
{
  "program": {
    "running": {
      "name": "O999",
      "number": 999,
      "size_b": 2000,
      "comment": "( 123 )",
      "modified": 1666944000000
    },
    "main": {
      "name": "",
      "number": 999,
      "size_b": 2000,
      "comment": "( 123 )",
      "modified": 1666944000000
    }
  },
  "pieces": {
    "produced": 99999,
    "produced_life": 99999,
    "remaining": 0
  },
  "timers": {
    "cycle_time_ms": 1000
  }
} |l99.driver.fanuc.veneers.ProductionData|

DataItem where program number/name should appear:

<DataItem category="EVENT" id="{{device}}_p{{path}}_prg_name" type="PROGRAM"/>

SHDR evaluation expression:

l99.driver.fanuc.veneers.ProductionData, fanuc: >-
        p = device+`_p`+observation.marker[0].number;
        ShdrSample p+`_tmr_cycle` (data.timers.cycle_time_ms / 1000);
        ShdrEvent p+`_part_count_life` data.pieces.produced_life;
        ShdrEvent p+`_part_count_complete` data.pieces.produced;
        ShdrEvent p+`_part_count_remain` data.pieces.remaining;
        ShdrEvent p+`_prg_name` data.program.main.name;
        ShdrEvent p+`_prg_cmt` data.program.main.comment;
        ShdrEvent p+`_prg_size` data.program.main.size_b;
        ShdrEvent p+`_prg_mod` data.program.main.modified;

Should be changed to account for running program (data.program.running.name) if main program (data.program.main.name) is empty.

TODO SHDR eval
MRIIOT commented 2 years ago
        ShdrEvent p+`_prg_name` (data.program.running.name == `` ? data.program.main.name : data.program.running.name);