Skip to content

Conversation

@g7gpr
Copy link
Contributor

@g7gpr g7gpr commented Aug 3, 2025

(vRMS) au000a@walnut:~/source/RMS$ sudo timedatectl set-timezone Australia/Eucla
(vRMS) au000a@walnut:~/source/RMS$ date
Sun  3 Aug 21:30:34 +0845 2025
(vRMS) au000a@walnut:~/source/RMS$ python -m Utils.CameraControl SetAutoReboot Everyday,noon
Loading the default config!
Creating directory: /home/au000a/RMS_data
   Success: True
Creating directory: /home/au000a/RMS_data/logs
   Success: True
2025/08/03 12:45:42-INFO-CameraControl-line:612 -   replaced "noon" with 13.0 for machine time noon
2025/08/03 12:45:42-INFO-CameraControl-line:624 - Set autoreboot: Everyday at 1300
Shutting down logging...
Logging shutdown complete.
(vRMS) au000a@walnut:~/source/RMS$ sudo timedatectl set-timezone Australia/Perth
(vRMS) au000a@walnut:~/source/RMS$ date
Sun  3 Aug 20:45:55 AWST 2025
(vRMS) au000a@walnut:~/source/RMS$ python -m Utils.CameraControl SetAutoReboot Everyday,noon
Loading the default config!
Creating directory: /home/au000a/RMS_data
   Success: True
Creating directory: /home/au000a/RMS_data/logs
   Success: True
2025/08/03 12:46:02-INFO-CameraControl-line:612 -   replaced "noon" with 12.0 for machine time noon
2025/08/03 12:46:02-INFO-CameraControl-line:624 - Set autoreboot: Everyday at 1200
Shutting down logging...
Logging shutdown complete.
(vRMS) au000a@walnut:~/source/RMS$ sudo timedatectl set-timezone UTC
(vRMS) au000a@walnut:~/source/RMS$ python -m Utils.CameraControl SetAutoReboot Everyday,noon
Loading the default config!
Creating directory: /home/au000a/RMS_data
   Success: True
Creating directory: /home/au000a/RMS_data/logs
   Success: True
2025/08/03 12:46:29-INFO-CameraControl-line:612 -   replaced "noon" with 4.0 for machine time noon
2025/08/03 12:46:29-INFO-CameraControl-line:624 - Set autoreboot: Everyday at 400
Shutting down logging...
Logging shutdown complete.

@g7gpr
Copy link
Contributor Author

g7gpr commented Aug 3, 2025

(vRMS) au000c@walnut:~/source/RMS$ python -m Utils.CameraControl SwitchMode day
Loading the default config!
Creating directory: /home/au000c/RMS_data
   Success: True
Creating directory: /home/au000c/RMS_data/logs
   Success: True
2025/08/03 13:13:32-INFO-CameraControl-line:406 - NTP disabled
2025/08/03 13:13:32-INFO-CameraControl-line:612 -   replaced "noon" with 4.0 for station solar noon
2025/08/03 13:13:32-INFO-CameraControl-line:624 - Set autoreboot: Everyday at 400
2025/08/03 13:13:33-INFO-CameraControl-line:795 - time set to 2025-08-03 13:13:33.356596
2025/08/03 13:13:33-INFO-CameraControl-line:515 - Set Camera.Param.[0].DayNightColor to 0x00000001
2025/08/03 13:13:34-INFO-CameraControl-line:515 - Set Camera.Param.[0].ElecLevel to 50
2025/08/03 13:13:34-INFO-CameraControl-line:489 - Set Camera.ParamEx.[0].BroadTrends.AutoGain to 1
2025/08/03 13:13:34-INFO-CameraControl-line:472 - Set Camera.ClearFog.[0].enable to True
2025/08/03 13:13:34-INFO-CameraControl-line:472 - Set Camera.ClearFog.[0].level to 30
2025/08/03 13:13:34-INFO-CameraControl-line:92 - Camera rebooting, please wait....
Shutting down logging...
2025/08/03 13:13:40-INFO-CameraControl-line:101 - reboot successful
Logging shutdown complete.

@g7gpr g7gpr marked this pull request as ready for review August 3, 2025 13:14
@g7gpr g7gpr requested a review from markmac99 August 3, 2025 13:19
@Cybis320
Copy link
Contributor

Cybis320 commented Aug 3, 2025

Oh, so clever! merging into alpha1 and testing.

@Cybis320
Copy link
Contributor

Cybis320 commented Aug 3, 2025

If you think that makes sense, could you also update the default camera_settings.json as part of this PR?

    ["SetAutoReboot", "Everyday,noon"],

Copy link
Contributor

@markmac99 markmac99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on the Issue about the necessity of first setting the camera TZ and clock to match the station.

Also given the appropriately simple approach for computing local noon in UTC, i'd probably not bother with a function and just use station_noon_in_utc = 12 - int(config.longitude/15).
Personally, i'd also ditch the other function and just inline the required three lines, i can't see anyone needing to improve the code and it'd make it simpler to read.

@g7gpr
Copy link
Contributor Author

g7gpr commented Aug 4, 2025

I think Mark is right. If you set the time using the set time command, time zones do not matter.

If you use the camera's NTP client, then it does matter. Since folk might use the NTP client, we should take that into account.

Did I get that right?

So, I have three options.

  1. Get the camera time, and whatever it is, compute when solar noon will be. I like that because it changes the fewest settings, but it is a bit eccentric.

  2. Set the camera timezone to the machine timezone. That's what I think is most sensible, and what I would do for my own systems.

  3. Force the cameras to UTC. I don't think we should be changing settings on people's equipment.

So it's a choice between 1 and 2. Personally, I think 1, because it is the least invasive, but happy to hear other folks thoughts.

All the other comments about inlining, sure, happy to do.

@Cybis320
Copy link
Contributor

Cybis320 commented Aug 4, 2025

Right, I think if we want to support NTP and non-NTP, and don't want to alter the camera TZ, then option 1 it is:

  • set camera time (ignored if NTP enabled?)
  • get the delta (d) btw now and target time
  • get the camera time (tc)
  • set reboot time = round(tc+d).

There was also Mark's idea to reboot a moment before night capture starts. Should the target only be noon? Should dusk be an option?

Then there's also the option to deadman reboot: always attempt to push back reboot to the next hour except for the reboot hour if any (requires a watchdog process).

Edit: actually maybe it doesn't need a watchdog, just send the command moving back reboot to the next hour every hour. If the command doesn't land, camera reboots.

@g7gpr
Copy link
Contributor Author

g7gpr commented Aug 4, 2025

We should not set the camera time as part of this command. A command to set the reboot to noon has a bug if it changes anything other than the reboot time.

An operator might have set the camera time to some time, for some reason that we do not know, and we should not be changing it, unless explicitly asked.

All we need to do is compute the time of station noon, and transform that into camera time, and schedule a reboot at that time. We could reboot at dusk, but that adds complexity, and I'd like to keep the simplicity of this piece of code. The other problem with dusk, is that dusk does not happen everyday everywhere on a planet. Polar regions can go for hundreds of hours without a dusk. I do not consider planets with multiple stars for this pr.

As for resending commands, that is already taken care of. I set the reboot time at each transition to night mode, and I think other code keeps resending the transition to night mode.

@Cybis320
Copy link
Contributor

Cybis320 commented Aug 4, 2025

Fair point about not setting time first, but then when we do set time or set tz, should it trigger a new noon computation automatically?

I do not consider planets with multiple stars for this pr.

Whut? We just had a request from someone on Tatooin ;)

As for resending commands, that is already taken care of. I set the reboot time at each transition to night mode, and I think other code keeps resending the transition to night mode.

Sorry, I'm not following.

@g7gpr
Copy link
Contributor Author

g7gpr commented Aug 4, 2025

@dvida
Copy link
Contributor

dvida commented Aug 18, 2025

Hey guys,
Is this ready to merge? Any outstanding issues?

@g7gpr
Copy link
Contributor Author

g7gpr commented Aug 19, 2025

Not ready to merge. Waiting for help on the timezone function.

@g7gpr g7gpr marked this pull request as draft August 19, 2025 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants