fixies in the focus script. now properly handling MCM02 screen

This commit is contained in:
Salijoghli 2025-11-10 12:25:06 +04:00
parent 19bc4b3812
commit 1644ef72c8
20 changed files with 183 additions and 74 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

View File

@ -33,7 +33,7 @@
"covert": true,
"dpm_view_path": "autStand/Custom_Views/Enternet-Windows/DPMS/DPM Devices/MCM02/NCS1_1_DPM1",
"fc": "BNA8",
"rotation": "0deg",
"rotation": "270deg",
"show_dpm_device_view": true,
"show_dpm_view": true
},

View File

@ -82,7 +82,6 @@ def source_id_lookup(self, source_id):
return
page_id = global_project_page_ids.get(source_id)
system.perspective.print(page_id)
if page_id:
navigate_to_url(self, source_id, page_id)

View File

@ -1,18 +1,35 @@
def calculateFocus(self, child, scale=1.7):
"""
Hybrid focusing:
- MCM01: precise per-rotation affine for (dx, dy) (unchanged)
- MCM02: search-style mapping:
* 0°/180°: strong horizontal (dx from x,y), dy very gentle (clamped)
* 90°/270°: dx = 0, dy from x (fits your left/right anchors)
"""
# Read rotation
# --- rotation ---
try:
rot = int(str(self.session.custom.rotation).replace("deg", "")) % 360
except:
rot = 0
# Device normalized coords (0..1)
x = float(child.position.x)
y = float(child.position.y)
# system
# --- child coords ---
try:
x = float(child.position.x)
y = float(child.position.y)
w = float(child.position.width)
except:
system.perspective.print("Invalid position data on child component.")
return {"x": 0, "y": 0, "scale": scale}
# Per-rotation affine coefficients (dx, dy)
COEFFS = {
# --- zone ---
try:
zone = child.props.params.tagProps[0].split("/")[1]
except:
zone = "MCM01"
# ======== MCM01 (your proven mapping, unchanged) ========
COEFFS_MCM01 = {
0: dict(ax= 956.86984, bx=-1853.94329, cx= -17.57191,
ay= 124.82245, by= -191.28916, cy= 227.58568),
90: dict(ax=-601.58230, bx= -218.90739, cx=1466.46475,
@ -23,23 +40,65 @@ def calculateFocus(self, child, scale=1.7):
ay=-1341.88064, by= 1615.55073, cy= 142.77638),
}
c = COEFFS.get(rot, COEFFS[0])
# ======== MCM02 (fit from your new table) ========
dx = c['ax'] + c['bx']*x + c['cx']*y
dy = c['ay'] + c['by']*x + c['cy']*y
# 0°: dx ≈ a + b*x + c*y (LS fit on: left/right/center/top/bottom)
_M2_DX_0 = dict(a= 691.72633028, b=-1788.01433165, c= 295.57517840)
# dy kept light & clamped around center (use a small gain around 0.5)
def _m2_dy0(y):
dy = 320.0 * (0.5 - y) # gentle bias
return max(min(dy, 120.0), -120.0)
# Keep your wide-device tweak if you still want it (optional)
# 180°: dx ≈ a + b*x + c*y
_M2_DX_180 = dict(a=-730.66959977, b= 1680.89494266, c= -70.52210472)
def _m2_dy180(y):
dy = 200.0 * (y - 0.5) # tiny bias
return max(min(dy, 80.0), -80.0)
# 90°: dx = 0, dy ≈ A + B*x (two-point fit from left/right; matches your sheet well)
_M2_DY_90_A = 278.8
_M2_DY_90_B = -1663.6 # ~ from (left 215.88) → (right -1213.52)
# 270°: dx = 0, dy ≈ A + B*x
_M2_DY_270_A = -1284.8
_M2_DY_270_B = 1686.1 # ~ from (left -1221.17) → (right 227.06)
# ======== compute (dx, dy) ========
if zone == "MCM01":
c = COEFFS_MCM01.get(rot, COEFFS_MCM01[0])
dx = c["ax"] + c["bx"] * x + c["cx"] * y
dy = c["ay"] + c["by"] * x + c["cy"] * y
else: # ------- MCM02 (search-style) -------
if rot == 0:
dx = _M2_DX_0["a"] + _M2_DX_0["b"] * x + _M2_DX_0["c"] * y
dy = _m2_dy0(y)
elif rot == 180:
dx = _M2_DX_180["a"] + _M2_DX_180["b"] * x + _M2_DX_180["c"] * y
dy = _m2_dy180(y)
elif rot == 90:
dx = 0.0
dy = _M2_DY_90_A + _M2_DY_90_B * x
elif rot == 270:
dx = 0.0
dy = _M2_DY_270_A + _M2_DY_270_B * x
else:
dx, dy = 0.0, 0.0
# --- slight downward shift for flat rotations ---
if rot in (0, 180):
dy -=50
# ======== wide device tweak (unchanged) ========
try:
deviceWidthPixels = float(child.position.width) * 1850.0
deviceWidthPixels = float(w) * 1850.0
if deviceWidthPixels > 1200:
scale = max(scale, 1.8)
dy -= 100
except:
deviceWidthPixels = 0.0
if deviceWidthPixels > 1200:
scale = 1.8
dy -= 100
pass
return {"x": dx, "y": dy, "scale": scale}
def deviceType(self, path, props):
try:
docked_view = "Docked-East-"
@ -76,8 +135,7 @@ def deviceType(self, path, props):
def handleTagHighlight(view, currentValue):
tagAndPriority = str(currentValue.value
or "")
tagAndPriority = str(currentValue.value or "")
container = view.rootContainer.getChildren()[0]
# --- CASE 1: Remove all highlights by applying CLEAR class ---
@ -91,9 +149,7 @@ def handleTagHighlight(view, currentValue):
except:
pass
return False
return
if "||" not in tagAndPriority:
return

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -1,8 +1,8 @@
{
"custom": {
"scale": 1,
"scale": 1.7,
"x": 0,
"y": 0
"y": -505.882352941
},
"params": {
"controls": {
@ -399,7 +399,7 @@
"position": {
"height": 0.0324,
"width": 0.0182,
"x": 0.1025
"x": 0.0811
},
"propConfig": {
"meta.visible": {
@ -649,8 +649,8 @@
"name": "root"
},
"position": {
"x": -0.3026,
"y": -0.0454
"x": 0.0177,
"y": 0.0972
},
"props": {
"mode": "percent",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -9,8 +9,8 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-07T09:08:37Z"
"timestamp": "2025-11-10T08:23:52Z"
},
"lastModificationSignature": "6a0c7ce1d755d49b45b6489b852bca4e290f2e672b178c72d710c24c0e7dd09e"
"lastModificationSignature": "655d54ec57f4bfefbde0993c8cebd4c39238eaee970eea1bb8bd2857614753da"
}
}

View File

@ -10,8 +10,8 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-08T16:05:26Z"
"timestamp": "2025-11-10T08:24:01Z"
},
"lastModificationSignature": "ea059f1c01773e5f7981e0ce2977404a2138645c02da13fbacab590e082d56ff"
"lastModificationSignature": "9282e242ac006f57eeb0c0cf3bd4f5b45e6d2a70a7bcd655c087a76d3bbe8491"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -399,7 +399,7 @@
"position": {
"height": 0.0324,
"width": 0.0182,
"x": 0.1025
"x": 0.1019
},
"propConfig": {
"meta.visible": {
@ -649,8 +649,8 @@
"name": "root"
},
"position": {
"x": -0.3026,
"y": -0.0454
"x": 0.0177,
"y": 0.0972
},
"props": {
"mode": "percent",

View File

@ -10,8 +10,8 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-08T15:49:02Z"
"timestamp": "2025-11-10T07:51:12Z"
},
"lastModificationSignature": "fc06166aab9aa9e8cea364c5f6e76bea4a062ac1ca1d26499c315d65ed74c602"
"lastModificationSignature": "7ed61682197c07d06f24ffb96111945db9934345f101afd1a1e3c4c29405bc15"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -1,18 +1,36 @@
def calculateFocus(self, child, scale=1.7):
"""
Please don't modify!
Hybrid focusing:
- MCM01: precise per-rotation affine for (dx, dy)
- MCM02: search-style mapping:
* 0°/180°: strong horizontal (dx from x,y), dy very gentle (clamped)
* 90°/270°: dx = 0, dy from x left/right anchors)
"""
# Read rotation
# --- rotation ---
try:
rot = int(str(self.session.custom.rotation).replace("deg", "")) % 360
except:
rot = 0
# Device normalized coords (0..1)
x = float(child.position.x)
y = float(child.position.y)
# system
# --- child coords ---
try:
x = float(child.position.x)
y = float(child.position.y)
w = float(child.position.width)
except:
system.perspective.print("Invalid position data on child component.")
return {"x": 0, "y": 0, "scale": scale}
# Per-rotation affine coefficients (dx, dy)
COEFFS = {
# --- zone ---
try:
zone = child.props.params.tagProps[0].split("/")[1]
except:
zone = "MCM01"
# ======== MCM01 ========
COEFFS_MCM01 = {
0: dict(ax= 956.86984, bx=-1853.94329, cx= -17.57191,
ay= 124.82245, by= -191.28916, cy= 227.58568),
90: dict(ax=-601.58230, bx= -218.90739, cx=1466.46475,
@ -23,23 +41,65 @@ def calculateFocus(self, child, scale=1.7):
ay=-1341.88064, by= 1615.55073, cy= 142.77638),
}
c = COEFFS.get(rot, COEFFS[0])
# ======== MCM02 ========
dx = c['ax'] + c['bx']*x + c['cx']*y
dy = c['ay'] + c['by']*x + c['cy']*y
# 0°: dx ≈ a + b*x + c*y
_M2_DX_0 = dict(a= 691.72633028, b=-1788.01433165, c= 295.57517840)
# dy kept light & clamped around center (use a small gain around 0.5)
def _m2_dy0(y):
dy = 320.0 * (0.5 - y) # gentle bias
return max(min(dy, 120.0), -120.0)
# Keep your wide-device tweak if you still want it (optional)
# 180°: dx ≈ a + b*x + c*y
_M2_DX_180 = dict(a=-730.66959977, b= 1680.89494266, c= -70.52210472)
def _m2_dy180(y):
dy = 200.0 * (y - 0.5) # tiny bias
return max(min(dy, 80.0), -80.0)
# 90°: dx = 0, dy ≈ A + B*x (two-point fit from left/right; matches your sheet well)
_M2_DY_90_A = 278.8
_M2_DY_90_B = -1663.6 # ~ from (left 215.88) → (right -1213.52)
# 270°: dx = 0, dy ≈ A + B*x
_M2_DY_270_A = -1284.8
_M2_DY_270_B = 1686.1 # ~ from (left -1221.17) → (right 227.06)
# ======== compute (dx, dy) ========
if zone == "MCM01":
c = COEFFS_MCM01.get(rot, COEFFS_MCM01[0])
dx = c["ax"] + c["bx"] * x + c["cx"] * y
dy = c["ay"] + c["by"] * x + c["cy"] * y
else: # ------- MCM02 (search-style) -------
if rot == 0:
dx = _M2_DX_0["a"] + _M2_DX_0["b"] * x + _M2_DX_0["c"] * y
dy = _m2_dy0(y)
elif rot == 180:
dx = _M2_DX_180["a"] + _M2_DX_180["b"] * x + _M2_DX_180["c"] * y
dy = _m2_dy180(y)
elif rot == 90:
dx = 0.0
dy = _M2_DY_90_A + _M2_DY_90_B * x
elif rot == 270:
dx = 0.0
dy = _M2_DY_270_A + _M2_DY_270_B * x
else:
dx, dy = 0.0, 0.0
# --- slight downward shift for flat rotations ---
if rot in (0, 180):
dy -=50
# ======== wide device tweak (unchanged) ========
try:
deviceWidthPixels = float(child.position.width) * 1850.0
deviceWidthPixels = float(w) * 1850.0
if deviceWidthPixels > 1200:
scale = max(scale, 1.8)
dy -= 100
except:
deviceWidthPixels = 0.0
if deviceWidthPixels > 1200:
scale = 1.8
dy -= 100
pass
return {"x": dx, "y": dy, "scale": scale}
def deviceType(self, path, props):
try:
docked_view = "Docked-East-"
@ -76,8 +136,7 @@ def deviceType(self, path, props):
def handleTagHighlight(view, currentValue):
tagAndPriority = str(currentValue.value
or "")
tagAndPriority = str(currentValue.value or "")
container = view.rootContainer.getChildren()[0]
# --- CASE 1: Remove all highlights by applying CLEAR class ---
@ -91,9 +150,7 @@ def handleTagHighlight(view, currentValue):
except:
pass
return False
return
if "||" not in tagAndPriority:
return

View File

@ -9,9 +9,9 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-08T10:20:50Z"
"timestamp": "2025-11-10T08:21:37Z"
},
"hintScope": 2,
"lastModificationSignature": "7377f0a17b7f9f674d5849df420248ed992fa1247fc5d875dd838b6562200c36"
"lastModificationSignature": "cd2c568061de4f6630ff358400a39202df6df7cdebd0d66b6e2e82ec8b4aff0c"
}
}

View File

@ -82,7 +82,6 @@ def source_id_lookup(self, source_id):
return
page_id = global_project_page_ids.get(source_id)
system.perspective.print(page_id)
if page_id:
navigate_to_url(self, source_id, page_id)

View File

@ -9,9 +9,9 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-04T09:00:38Z"
"timestamp": "2025-11-08T16:16:38Z"
},
"hintScope": 2,
"lastModificationSignature": "190c5ab2191a81be3e66c94cb8c3816e9b90095631d2b2bda6387a09cc6114ed"
"lastModificationSignature": "9571b09b33547ea26660f739980dcd2a51b5a61ab78a36abe0b0ba0878eb233f"
}
}

View File

@ -227,12 +227,10 @@ global_device_mapping = {}
def build_device_mapping(full_tag_path):
"""
Builds global_device_mapping for devices under the same PLC and parent device.
Adds support for:
- Chute FIOM devices (e.g. S03_CH109_FIOM_1 when clicking S03_CH109)
- Shared JR and PE devices used by multiple chutes (e.g. S03_1_JR1, S03_1_LRPE1)
Builds global_device_mapping for devices under the same Conveyor and Chute.
Support for:
- Shared JR and Long Range PE devices used by multiple chutes (e.g. S03_1_JR1, S03_1_LRPE1)
"""
system.perspective.print(full_tag_path)
global global_device_mapping
global_device_mapping.clear()

View File

@ -9,9 +9,9 @@
"attributes": {
"lastModification": {
"actor": "admin",
"timestamp": "2025-11-07T17:19:28Z"
"timestamp": "2025-11-10T08:22:57Z"
},
"hintScope": 2,
"lastModificationSignature": "54520a6186926aa8832b5cbe2759f81c22a12624775ddf70a3144bce00c188b0"
"lastModificationSignature": "7e8409fd526bf5aff961f6d891601db7f9cd4f57996b1df945d6924877f44902"
}
}