### Remote Git Operations and Setup Source: https://github.com/haller-erne/ogs-samples/blob/main/git-setup-notes.md Commands for interacting with remote Git repositories, such as cloning a repository, pulling changes, pushing local commits, and managing remote connections. These are essential for distributed version control and collaboration. ```shell git clone git pull git push git remote -v git remote add ``` -------------------------------- ### Cloning the OGS Samples Repository Source: https://github.com/haller-erne/ogs-samples/blob/main/git-setup-notes.md This command sequence demonstrates how to clone the OGS samples repository from GitHub to a local directory. It involves changing the directory and then executing the git clone command with the repository URL. ```batch @rem Switch to the OGS project folder cd "c:\OGS Projects" @rem Clone the github repo git clone https://github.com/haller-erne/ogs-samples.git ``` -------------------------------- ### Pulling Updates for OGS Samples Source: https://github.com/haller-erne/ogs-samples/blob/main/git-setup-notes.md This command demonstrates how to fetch and merge changes from the remote repository into the local OGS samples repository. It's important to commit local changes before pulling to avoid conflicts. ```batch @rem Get all changes from the remote server git pull ``` -------------------------------- ### Committing Changes in OGS Samples Source: https://github.com/haller-erne/ogs-samples/blob/main/git-setup-notes.md Steps to stage modified files and commit them to the local repository within the OGS samples project. This includes checking the status, adding specific files or directories to the staging area, and then committing with a descriptive message. ```batch @rem Switch to the OGS project "ogs-samples" folder cd "c:\OGS Projects\ogs-samples" @rem Check the status git status @rem Add the changed/added files to the staging are git add myfolder/* @rem Commit the changes to the local repository git commit -m "my changes" ``` -------------------------------- ### Basic Local Git Operations Source: https://github.com/haller-erne/ogs-samples/blob/main/git-setup-notes.md Commands for managing local Git repositories, including staging files, committing changes, checking status, and updating the working copy. These operations are crucial for tracking changes and creating new versions of the project locally. ```shell git add git commit -m git status git checkout ``` -------------------------------- ### AR-Tracking SmartTrack3 Realtime Tracking System Integration Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md This sample utilizes the AR-Tracking SmartTrack3 realtime tracking system to monitor a tool's position and orientation in 3D space. It supports advanced features like multi-tool tracking, angle deviation checking, socket length compensation, and tolerance object setup. All features are accessible from OGS operator screens. Camera communication and tracker assignment are configured in `station.ini`. ```lua -- station_io.lua example for ST03-ar-dtrack -- Placeholder for SmartTrack3 integration logic -- This would involve receiving tracking data (position and orientation) -- and potentially applying advanced features like compensation. -- Example: Receiving tracking data (simulated) -- local tool_pose = OGS.GetSmartTrack3Data() -- OGS.UpdateToolPosition(tool_pose.x, tool_pose.y, tool_pose.z) -- OGS.UpdateToolOrientation(tool_pose.roll, tool_pose.pitch, tool_pose.yaw) ``` -------------------------------- ### Import Configuration with Lua Source: https://context7.com/haller-erne/ogs-samples/llms.txt Automates the import of configuration databases from backup files, checking for existing databases and ensuring version compatibility. It uses functions like FileExists, ImportConfigBackup, and GetDatabaseVersion. Errors are handled for missing backup files or import failures. ```lua -- import_config.lua implementation local function CheckAndImportConfig() local backup_file = "./config/he-007.fbc" local config_db = "./config/he-007.fdc" local station_db = "./station.fds" -- Check if configuration database exists local config_exists = FileExists(config_db) local station_exists = FileExists(station_db) if not config_exists or not station_exists then XTRACE(16, "Configuration database missing, importing from backup...") if not FileExists(backup_file) then error("Configuration backup file not found: " .. backup_file) end -- Import configuration from backup local result = ImportConfigBackup(backup_file, config_db) if not result then error("Failed to import configuration backup") end XTRACE(16, "Configuration imported successfully") -- Create station database link if not station_exists then CreateStationDatabase(config_db, station_db) XTRACE(16, "Station database created") end else XTRACE(16, "Using existing configuration database") end -- Verify database version local db_version = GetDatabaseVersion(config_db) local expected_version = 101 if db_version ~= expected_version then XTRACE(4, string.format( "Warning: Database version mismatch (found: %d, expected: %d)", db_version, expected_version )) end return true end -- Call during initialization CheckAndImportConfig() ``` -------------------------------- ### Configure OGS Station Parameters in INI Format Source: https://context7.com/haller-erne/ogs-samples/llms.txt Sets up OGS station configuration, including general settings like version and language, network details for communication channels (e.g., Nexo, CS351), web server information, side panel preferences, and cleanup policies for archived and unfinished data. ```ini [GENERAL] Version=101 STATION=01 STATION_NAME=[he-007] ST01 LANGUAGE=en QUICK_PROCESSING=1 NOK_STRATEGIE=0 CHECK_LIMITS=0 REWORK=NEW_IF_OK Result_OK=SAVE Result_NOK=ASK Result_incomplete=SKIP DBInstance=donotcheck [OPENPROTO] CHANNEL_01=10.10.2.160 CHANNEL_01_TYPE=Nexo CHANNEL_01_PORT=4545 CHANNEL_01_CHECK_TIME_ENABLED=1 CHANNEL_01_CCW_ACK=1 CHANNEL_02=10.10.2.244 CHANNEL_02_TYPE=CS351 CHANNEL_02_PORT=4545 CHANNEL_02_CCW_ACK=1 [WebServer] URL=http://127.0.0.1:60000/ RootFolder=../shared/webroot [SidePanel] URL=local://sidepanel.html Key=112 Width=24 [CLEANUP] Enable=1 ArchivedTimeout=7 UnFinishedTimeout=14 [USER] autologon=red YELLOW=yellow,1,U40001AC01D BLUE=blue,2,UA1008DB131 RED=red,3,U40003ACC4D ``` -------------------------------- ### Initialize OGS and Send Command (JavaScript) Source: https://github.com/haller-erne/ogs-samples/blob/main/he-007-station-io/shared/webroot/billboard.html This snippet demonstrates how to initialize the Operator Guidance System (OGS) and send an initial command. It logs the initialization URL and then sends a 'get-info' command. This is typically used when the OGS application first loads or becomes active. ```javascript OGS = {}; OGS.onInit = function(url) { console.log("OGS.onInit called: ", url, OGS); OGS.SendCmd('{ "cmd":"get-info" }'); } ``` -------------------------------- ### Get Operation Result by Key Input in Lua Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST04-ar-verpose/README.md This function is called by OGS when waiting for key input. It checks the state of the Modbus input bit 0 ('M.data.in_bit0') for a rising edge to determine if an OK or NOK key press is registered. This provides a reliable way to capture input signals. ```lua function GetOperationResultByKeyInput() if M.data.in_bit0 then -- Check for rising edge instead of just signal state if not M.data.in_bit0_prev then M.data.in_bit0_prev = true return 1 -- OK end else M.data.in_bit0_prev = false end return 0 -- No key press end ``` -------------------------------- ### Digital IO Integration with Rexroth Modbus/TCP Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md This sample demonstrates using digital inputs and outputs connected via a Rexroth R-IL ETH BK DI8 DO4 2TX-PAC Modbus/TCP remote I/O module with OGS. Inputs are used as binary encoded position signals. IP address and registers are defined in `station.ini`. This is a basic sample without advanced features. ```lua -- station_io.lua example for ST01-digital-io -- Placeholder for actual IO handling logic -- Digital inputs might be read here to determine position -- Digital outputs could be controlled based on OGS logic -- Example: Reading a digital input -- local input_state = OGS.ReadDigitalInput(1) -- Example: Setting a digital output -- OGS.SetDigitalOutput(1, true) ``` -------------------------------- ### Load Positioning Driver in Lua Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST02-ethernetip-sensors/README.md Loads the positioning driver, which is responsible for handling tool tracking. This driver scans the [OPENPROTO] section in station.ini for CHANNEL__POSITIONING parameters to set up positioning. ```lua local positioning = require('positioning') -- positioning driver ``` -------------------------------- ### Automatic Configuration Import using Lua Script Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md This Lua script handles the automatic import and creation of OGS configuration databases. It checks for an existing configuration backup file (`./config/he-008.fbc`) and generates the necessary unpacked configuration database (`./config/he-008.fdc`) and station-specific files (`.//station.fds`) if they are missing. This allows for easy management and reversion of configurations. ```lua -- shared/loadconfig.lua local config_backup = './config/he-008.fbc' local config_db = './config/he-008.fdc' local station_config = './' .. OGS.GetActiveStation() .. '/station.fds' if not OGS.FileExists(config_db) or not OGS.FileExists(station_config) then if OGS.FileExists(config_backup) then OGS.LogInfo('Configuration not found, attempting to load from backup.') -- Logic to unpack config_backup into config_db and station_config -- This is a simplified representation; actual unpacking would be complex. -- OGS.UnpackConfiguration(config_backup, config_db, station_config) OGS.LogInfo('Configuration loaded from backup.') else OGS.LogError('Configuration backup file not found.') end end ``` -------------------------------- ### Modbus/TCP Device Integration with Lua Source: https://context7.com/haller-erne/ogs-samples/llms.txt Demonstrates initializing and communicating with Modbus/TCP devices for industrial I/O operations. Requires the 'station_io_modbus' module and configuration in 'station.ini'. Processes input bits and handles connection status. ```lua -- station.ini configuration [STATION_IO_MODBUS] DEBUG=1 REXROTH_ETH_BK=10.10.2.153 [REXROTH_ETH_BK] INI_REG=[ { "adr": 2006, "val": [ 6 ] } ] MODE=0 WR_REG=[ { "adr": 8001, "len": 1 } ] RD_REG=[ { "adr": 8000, "len": 1 } ] -- station_io.lua implementation local mb_io = require('station_io_modbus') local M = { data = { in_bit0 = false, in_bit0_old = false } } local function OnDataChanged(dev) if dev.cfg.name == 'REXROTH_ETH_BK' then local byte_val = string.byte(dev.data.i, 1) M.data.in_bit0_old = M.data.in_bit0 M.data.in_bit0 = (byte_val & 0x01) ~= 0 XTRACE(16, string.format("Input bit 0: %s", tostring(M.data.in_bit0))) end end local function OnConnChanged(dev) if dev.cfg.name == 'REXROTH_ETH_BK' then if dev.connected then XTRACE(16, "Modbus IO module connected") ResetLuaAlarm('REXROTH_ETH_BK') else XTRACE(4, "Modbus IO module disconnected") SetLuaAlarm('REXROTH_ETH_BK', -2, "IO module disconnected") end end end mb_io.OnConnChanged = OnConnChanged mb_io.OnDataChanged = OnDataChanged function GetOperationResultByKeyInput(Tool, JobName, TaskName) local rising_edge = M.data.in_bit0 and not M.data.in_bit0_old if rising_edge then return 1 -- OK button pressed end return nil -- No input end return M ``` -------------------------------- ### Low-Level OGS Positioning Interface Functions (LUA) Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md Provides Lua functions for tracking tool positions within OGS. PS_CheckToolPosition verifies if a tool is in position, while PS_TeachToolPosition handles the teaching of new positions. These are crucial for implementing accurate position tracking in OGS tasks. ```LUA function PS_CheckToolPosition(Tool, JobName, TaskName, PosCtrl, ToolPosDef, TaskState, TaskStep) end ``` ```LUA function PS_TeachToolPosition(State, Tool, JobName, TaskName, PosCtrl, ToolPosDef) end ``` -------------------------------- ### Check and Teach Tool Position with OGS Lua Interface Source: https://context7.com/haller-erne/ogs-samples/llms.txt Implements functions to check if tools are in the correct position and to teach new positions using the OGS low-level positioning interface. It involves reading current positions, comparing them against expected values with a tolerance, and encoding/decoding position data. ```lua -- Low-level positioning interface implementation function PS_CheckToolPosition(Tool, JobName, TaskName, PosCtrl, ToolPosDef, TaskState, TaskStep) -- Parameters: -- Tool: Tool/channel number of active tool -- JobName, TaskName: Currently active job/task -- PosCtrl: Position number from config database (0 = positioning not active) -- ToolPosDef: Database position data (encoded as string) -- TaskState: 0=before start, 1=after start, 2=tool in cycle -- TaskStep: Reserved (0) -- Check if position matches expected value local current_pos = GetCurrentPosition(Tool) local expected_pos = DecodePositionFromDB(ToolPosDef) if not current_pos then return "Position sensor not available" end local tolerance = 10 -- mm local dx = current_pos.x - expected_pos.x local dy = current_pos.y - expected_pos.y local distance = math.sqrt(dx*dx + dy*dy) if distance <= tolerance then return true -- In position else return false -- Not in position end end function PS_TeachToolPosition(State, Tool, JobName, TaskName, PosCtrl, ToolPosDef) -- Parameters: -- State: 0=unknown, 1=teaching active, 2=start teaching, 3=stop teaching -- Tool: Tool/channel number -- JobName, TaskName: Currently active job/task -- PosCtrl: Position number from config database -- ToolPosDef: Current database position data -- Returns: -- new_state, delta_z, delta_y, delta_x, newToolPosDef, DisplayMsg -- or nil, nil, nil, nil, '-', ErrorMsg on error if State == 2 then -- Start teaching local pos = GetCurrentPosition(Tool) if not pos then return nil, nil, nil, nil, '-', "Cannot read position" end local encoded = EncodePositionForDB(pos) return 1, 0, 0, 0, encoded, "Position taught successfully" elseif State == 1 then -- Teaching active local pos = GetCurrentPosition(Tool) local taught_pos = DecodePositionFromDB(ToolPosDef) local dx = pos.x - taught_pos.x local dy = pos.y - taught_pos.y return 1, 0, dy, dx, ToolPosDef, string.format("dX: %.1f mm, dY: %.1f mm", dx, dy) end return 0, 0, 0, 0, ToolPosDef, "" end ``` -------------------------------- ### Ethernet/IP Sensor Integration for 2D Torque Support Arm Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md This sample integrates Ethernet/IP connected rotary sensors to read angle and distance values for a 2D torque support arm. It shows how to forward position information and translate it into an XY coordinate system, including referencing zero and teaching positions. Communication settings and mechanical parameters are configured in `station.ini`. ```lua -- station_io.lua example for ST02-ethernetip-sensors -- Placeholder for actual Ethernet/IP sensor reading logic -- This would involve reading angle and distance from sensors -- and potentially translating them into XY coordinates. -- Example: Reading sensor data (simulated) -- local angle = OGS.ReadEthernetIPSensor('angle') -- local distance = OGS.ReadEthernetIPSensor('distance') -- Example: XY coordinate calculation -- local x = distance * math.cos(math.rad(angle)) -- local y = distance * math.sin(math.rad(angle)) -- OGS.SetPosition(x, y) ``` -------------------------------- ### Load EtherNet/IP IO Driver in Lua Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST02-ethernetip-sensors/README.md Loads the EtherNet/IP LUA driver for OGS. This driver reads the [STATION_IO_ENIP] section from station.ini to configure EtherNet/IP devices for OGS control and cyclic data exchange. ```lua local enip_io = require('station_io_enip') -- load the EtherNet/IP IO driver ``` -------------------------------- ### Load Modbus IO Server Driver in Lua Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST04-ar-verpose/README.md Loads the Modbus/TCP LUA driver for OGS. This driver automatically reads the '[STATION_IO_MODBUS]' section from 'station.ini' to configure Modbus/TCP devices and their scanlists for OGS. ```lua local mb_server = require('luamodbus') -- load the modbus IO server ``` -------------------------------- ### AR-Tracking Verpose AI Camera Tracking System Integration Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/README.md This sample integrates the AR-Tracking Verpose AI-based camera tracking system to identify features (e.g., bolts) on a part and enable the tool accordingly. It uses the Modbus/TCP interface to receive detected feature information and matches it against configured OGS bolts. This sample focuses on feature identification and tool enabling based on AI detection. ```lua -- station_io.lua example for ST04-ar-verpose -- Placeholder for Verpose AI camera integration logic -- This would involve listening for Modbus/TCP messages from Verpose -- and matching detected features against OGS configurations. -- Example: Handling incoming Modbus/TCP data (simulated) -- OGS.OnModbusTCPMessage(function(data) -- if data.feature_detected then -- OGS.EnableToolForFeature(data.feature_id) -- end -- end) ``` -------------------------------- ### EtherNet/IP Positioning Integration with Lua Source: https://context7.com/haller-erne/ogs-samples/llms.txt Tracks tool position using EtherNet/IP sensors for rotary and linear movements in 2D. Relies on 'station_io_enip', 'struct', and 'positioning' modules. Processes raw and incremented position data and updates the positioning system. ```lua -- station.ini configuration [OPENPROTO] CHANNEL_02=10.10.2.244 CHANNEL_02_TYPE=CS351 CHANNEL_02_POSITIONING=POSITIONING_ENIP [POSITIONING_ENIP] DRIVER=IO DEBUG=0 SCALE_LEN=91.02 SCALE_RAD=13107.2 REF_POS=0,0 REF_LEN=75 [STATION_IO_ENIP] DEBUG=0 EAL580_LIN=10.10.2.226,Baumer_EAL580 EAL580_ROT=10.10.2.101,BaumerBTL7_V50D -- station_io.lua implementation local enip_io = require('station_io_enip') local struct = require("struct") local positioning = require('positioning') local M = { rot = { raw = 0, inc = 0 }, lin = { raw = 0, inc = 0 }, tilt = { x = 0, y = 0 } } local function OnDataChanged(dev) local fHasChange = false if dev.cfg.name == 'EAL580_LIN' then M.lin.raw = dev.data.i M.lin.inc = struct.unpack("=[,] ; Reference a device by later from the station_io_modbus.lua LUA module. ; Each requires an additional section [] in station.ini to define ; the actual scan list (and an initial register write, if needed). ; NOTE: do a `local io = require('station_io_modbus')` to use this module. REXROTH_ETH_BK=10.10.2.153 ; add more devices... ;REXROTH_ETH_BK2=10.28.39.53 ; Set debug to enable more verbose logging for ETWTraceViewer DEBUG=127 ``` -------------------------------- ### Load Modbus IO Driver in LUA Source: https://github.com/haller-erne/ogs-samples/blob/main/he-007-station-io/ST01-button-modbus/README.md Loads the Modbus/TCP LUA driver for OGS. When loaded, this driver reads the [STATION_IO_MODBUS] section from station.ini to define Modbus/TCP devices and their scanlists for initialization and cyclic read/write operations. ```lua local mb_io = require('station_io_modbus') -- load the modbus IO driver ``` -------------------------------- ### Connect Modbus Driver Callback Events in Lua Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST04-ar-verpose/README.md Connects local handler functions to Modbus driver events for connection status changes ('OnConnChanged') and data changes ('OnDataChanged'). This allows OGS to react to real-time updates from the Modbus device. ```lua -- connect the driver callback events to our local function handlers mb_io.OnConnChanged = OnConnChanged mb_io.OnDataChanged = OnDataChanged ``` -------------------------------- ### Handle OGS Show and Hide Events (JavaScript) Source: https://github.com/haller-erne/ogs-samples/blob/main/he-008-positioning/ST04-ar-verpose/shared/webroot/billboard.html Demonstrates how to implement callback functions for when the Operator Guidance System (OGS) is shown or hidden. These functions log messages to the console, indicating the respective event occurrences. No external dependencies are required beyond the OGS object. ```javascript OGS.onShow = function OGS_onShow() { console.log("OGS.onShow called!"); } OGS.onHide = function() { console.log("OGS.onHide called!"); } ```