Skip to main content

CHI Support

CHI Support Issues

This is a developer page regarding support changes made to CHI that aren't being tracked anywhere else.

Changing Offsets (2021-08-01)

CHI is reporting that the control is losing/changing offsets that shouldn't be changing.

Andrea added some UGM GMS alerts, comparing the offsets to static values and raising an alert when they change. CHI reported that the alert was happening spuriously. Todd made a small alteration of the condition for the alert to allow the permitted offset value(s) to be within some tolerance of the expected value (rather than a comparison for equality, which seemed to be the issue with the spurious alerts).

Current pertinent code
UserGUIModule.yparam = "YFenceOffset"
UserGUIModule.expected_yparamvalue = 58.1250 -- #CHIP
UserGUIModule.yparamvalue_eq_tolerance = 0.0001
UserGUIModule.lparam = "LaserOffset"
UserGUIModule.expected_lparamvalue = 2.2500 -- #CHIP
UserGUIModule.lparamvalue_eq_tolerance = 0.0001
UserGUIModule.xparam = "G54 X Offset"
UserGUIModule.expected_xparamvalue = -3.3030 -- #CHIP
UserGUIModule.xpoundnum = 5221
UserGUIModule.xparamvalue_eq_tolerance = 0.0001

UserGUIModule.tracked_values = {
	{ UserGUIModule.yparam, UserGUIModule.expected_yparamvalue, function() return w.GetOEMParamValue(UserGUIModule.yparam) end },
	{ UserGUIModule.lparam, UserGUIModule.expected_lparamvalue, function() return w.GetOEMParamValue(UserGUIModule.lparam) end },
	{ UserGUIModule.xparam, UserGUIModule.expected_xparamvalue, function() return mc.mcCntlGetPoundVar(inst, UserGUIModule.xpoundnum) end },
}

function UserGUIModule.UserScreenLoadScript()
	------------------ Add user code below this line ------------------ 
	UserGUIModule.debug_log("UserGUIModule.UserScreenLoadScript")
	UserGUIModule.check_config_and_params(true)
	
	local title = "Fence Offset Incorrect!"
	local handle = w.GetGMSHandleFromTitle(title)
	if handle == nil then
		local t = {	["Class"] = "Alarm",
						["Title"] = title,
						["Description"] = string.format("The offset is incorrect! Contact Maintenance.\nExpected: %0.4f", tonumber(user.expected_yparamvalue)),
						["CloseAlert"] = 0,
						["HideCloseBtn"] = 0,
						["Action1"] = { {["Type"] = "Enable", ["Level"] = 2, ["Value"] = 0},
										{["Type"] = "Notification", ["Open"] = 1},
										},
						["Conditions"] = { {["Set"] = 2, -- NOT
											["Conditions"] = { {["Type"] = "Register",
																["Device"] = "MachMotionOEMParameters",
																["Register"] = user.yparam,
																["ValueType"] = 0,
																["Value"] = user.expected_yparamvalue - user.yparamvalue_eq_tolerance,
																["Value2"] = user.expected_yparamvalue + user.yparamvalue_eq_tolerance,
																["Compare"] = 6, -- BETWEEN
																["Time"] = 0}
															}
											}
										}
						}
		w.CreateSystemGlobalMessage(t)
	end
	
	local title = "Laser Offset Incorrect!"
	local handle = w.GetGMSHandleFromTitle(title)
	if handle == nil then
		local t = {	["Class"] = "Alarm",
						["Title"] = title,
						["Description"] = string.format("The offset is incorrect! Contact Maintenance.\nExpected: %0.4f", tonumber(user.expected_lparamvalue)),
						["CloseAlert"] = 0,
						["HideCloseBtn"] = 0,
						["Action1"] = { {["Type"] = "Enable", ["Level"] = 2, ["Value"] = 0},
										{["Type"] = "Notification", ["Open"] = 1},
										},
						["Conditions"] = { {["Set"] = 2, -- NOT
											["Conditions"] = { {["Type"] = "Register",
																["Device"] = "MachMotionOEMParameters",
																["Register"] = user.lparam,
																["ValueType"] = 0,
																["Value"] = user.expected_lparamvalue - user.lparamvalue_eq_tolerance,
																["Value2"] = user.expected_lparamvalue + user.lparamvalue_eq_tolerance,
																["Compare"] = 6, -- BETWEEN
																["Time"] = 0}
															}
											}
										}
						}
		w.CreateSystemGlobalMessage(t)
	end
	
	local title = "X Offset Incorrect!"
	local handle = w.GetGMSHandleFromTitle(title)
	if handle == nil then
		local t = {	["Class"] = "Alarm",
						["Title"] = title,
						["Description"] = string.format("The offset is incorrect! Contact Maintenance.\nExpected: %0.4f", tonumber(user.expected_xparamvalue)),
						["CloseAlert"] = 0,
						["HideCloseBtn"] = 0,
						["Action1"] = { {["Type"] = "Enable", ["Level"] = 2, ["Value"] = 0},
										{["Type"] = "Notification", ["Open"] = 1},
										},
						["Conditions"] = { {["Set"] = 2, -- NOT
											["Conditions"] = { 	{["Type"] = "Pound",
																["Number"] = user.xpoundnum,
																["Value"] = user.expected_xparamvalue - user.xparamvalue_eq_tolerance,
																["Value2"] = user.expected_xparamvalue + user.xparamvalue_eq_tolerance,
																["Compare"] = 6, -- BETWEEN
																["Time"] = 0},
															}
											}
										}
						}
		w.CreateSystemGlobalMessage(t)
	end
	
	
	user.InitializeToolpath()
	
	m.screen.HideAxis(mc.OB1_AXIS)
	m.screen.HideAxis(mc.OB2_AXIS)
	m.screen.HideAxis(mc.C_AXIS)
	
	user.PullFilesFromServer()
	
	is_ok, chicsv = pcall(CHIModule.LoadCSVs)
	if not is_ok then
		w.AlarmMessage(chicsv)
		chicsv = nil
	end
	
	user.InitializeIO()
	
	------------------ Don't Edit below this line ------------------ 
	return true, true, w.FunctionCompleted()	
end