ccatobs/telescope-control-system

support set time command

Opened this issue · 0 comments

you can set the time by hand if there are issues with the ntp/ptp. ideally only done for testing

image

curl command

curl 'http://172.16.5.95:8080/?Module=DataSets.CmdGeneralTransfer&Chapter=3&Command' -X POST --data-raw 'Command=Set+Time&Year=2024&Day+of+Year=163&Seconds+of+Day=24595'

python script to set time on the ACU

import requests
from datetime import datetime

def get_current_time():
    # Get the current time
    now = datetime.utcnow()
    
    # Extract the required components
    year = now.year
    day_of_year = now.timetuple().tm_yday
    seconds_of_day = now.hour * 3600 + now.minute * 60 + now.second
    
    # Return the formatted time
    return year, day_of_year, seconds_of_day

def send_time_data(url):
    # Get the current time
    year, day_of_year, seconds_of_day = get_current_time()
    
    # Prepare the data payload
    data = {
        'Command': 'Set Time',
        'Year': year,
        'Day of Year': day_of_year,
        'Seconds of Day': seconds_of_day
    }
    
    # Send the POST request
    response = requests.post(url, data=data)
    
    # Return the response
    return response

# Define the URL
url = 'http://172.16.5.95:8080/?Module=DataSets.CmdGeneralTransfer&Chapter=3&Command'

# Send the time data
response = send_time_data(url)

# Print the response
print(f"Status Code: {response.status_code}")
print(f"Response Text: {response.text}")