@@ -44,7 +44,7 @@ def process(self, orbit_data: Orbit):
4444class LegacyBPMView (ViewInterface ):
4545 def __init__ (self , prefix ):
4646 # For Tango, prefix is like "server_name/instance_name:bpm_pv_name"
47- # We need to extract the server/instance part and construct the device name
47+
4848 self .prefix = prefix
4949 self .counter = itertools .count ()
5050 # Extract base prefix (server_name/instance_name) by splitting on ':'
@@ -144,6 +144,8 @@ async def push(self, data: TuneData):
144144 device_name = f"{ self .prefix } /tune_device"
145145 device = DeviceProxy (device_name )
146146
147+ logger .debug (f"TuneView.push: Writing tune X={ tune_x :.10f} , Y={ tune_y :.10f} to { device_name } " )
148+
147149 await asyncio .get_event_loop ().run_in_executor (
148150 None ,
149151 lambda : device .write_attribute ("x" , tune_x )
@@ -152,9 +154,11 @@ async def push(self, data: TuneData):
152154 None ,
153155 lambda : device .write_attribute ("y" , tune_y )
154156 )
157+
158+ logger .info (f"TuneView.push: >>>>>>>> Successfully wrote tune X={ tune_x :.10f} , Y={ tune_y :.10f} " )
155159
156160 except Exception as e :
157- logger .error (f"Error processing tune object data : { e } " )
161+ logger .error (f"TuneView.push: ❌ Error writing tune values : { e } " )
158162
159163
160164class RepeatedResultView :
@@ -178,15 +182,23 @@ def set_bpm_mimicry(self, bpm_mimicry):
178182 async def heart_beat (self ):
179183 """
180184 Periodic heartbeat function to push default BPM data.
185+
186+ Note: We do NOT republish tune here because tune values should only
187+ be published when fresh calculations are complete. Republishing cached
188+ tune values would overwrite fresh values with stale ones.
181189 """
182- logger .debug (f"{ self .__class__ .__name__ } heartbeat { datetime .now ()} , publishing bpm, orbit, twiss " )
190+ logger .debug (f"{ self .__class__ .__name__ } heartbeat { datetime .now ()} , publishing bpm, orbit" )
183191 await self .orbit_object_publisher .publish ()
184- await self .tune_publisher .publish ()
192+ # DO NOT publish tune here - it's published by push_twiss() with fresh values
193+ # await self.tune_publisher.publish() # ← REMOVED: This was overwriting fresh tune values with stale cache
185194 await self .legacy_bpm_publisher .publish ()
186- logger .info (f"{ self .__class__ .__name__ } view heartbeat { datetime .now ()} , published bpm, orbit, twiss " )
195+ logger .info (f"{ self .__class__ .__name__ } view heartbeat { datetime .now ()} , published bpm, orbit" )
187196
188197 async def push_twiss (self , twiss_result : TwissWithAggregatedKValues ):
189- self .tune_publisher .set_data (TuneData (x = twiss_result .x .tune , y = twiss_result .y .tune ))
198+ tune_x = float (twiss_result .x .tune )
199+ tune_y = float (twiss_result .y .tune )
200+ logger .info (f"RepeatedResultView.push_twiss: Publishing FRESH tune values X={ tune_x :.10f} , Y={ tune_y :.10f} " )
201+ self .tune_publisher .set_data (TuneData (x = tune_x , y = tune_y ))
190202 await self .tune_publisher .publish ()
191203
192204 async def push_orbit (self , orbit_result : Orbit ):
0 commit comments