From 5eda1fae3f5692caaa4ed36ed79773e7352fb700 Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Tue, 1 Mar 2022 09:46:33 +0300 Subject: [PATCH] add `sun` --- Auxiliary_utils/Sun/Makefile | 21 ++++++ Auxiliary_utils/Sun/Readme | 9 +++ Auxiliary_utils/Sun/sun.c | 73 +++++++++++++++++++ Auxiliary_utils/bash_scripts/getflats | 0 Auxiliary_utils/bash_scripts/park_tel.sh | 0 Auxiliary_utils/bash_scripts/point_AH.sh | 0 .../bash_scripts/point_get_flat.sh | 0 Auxiliary_utils/bash_scripts/run | 0 Auxiliary_utils/bash_scripts/run_w_arrays | 0 Daemons/README_install/netdaemons_start | 0 Daemons/astrosib/HWoff | 0 Daemons/astrosib/HWon | 0 Daemons/astrosib/STARTobs | 0 Daemons/astrosib/STOPobs | 0 Daemons/netsocket/HWpoweroff | 0 Daemons/netsocket/HWpoweron | 0 Daemons/netsocket/MOUNTpoweronoff | 0 Daemons/weatherdaemon/chkweather | 0 Docs/Alignment/makelist | 0 Docs/focus | 0 20 files changed, 103 insertions(+) create mode 100644 Auxiliary_utils/Sun/Makefile create mode 100644 Auxiliary_utils/Sun/Readme create mode 100644 Auxiliary_utils/Sun/sun.c mode change 100644 => 100755 Auxiliary_utils/bash_scripts/getflats mode change 100644 => 100755 Auxiliary_utils/bash_scripts/park_tel.sh mode change 100644 => 100755 Auxiliary_utils/bash_scripts/point_AH.sh mode change 100644 => 100755 Auxiliary_utils/bash_scripts/point_get_flat.sh mode change 100644 => 100755 Auxiliary_utils/bash_scripts/run mode change 100755 => 100644 Auxiliary_utils/bash_scripts/run_w_arrays mode change 100644 => 100755 Daemons/README_install/netdaemons_start mode change 100755 => 100644 Daemons/astrosib/HWoff mode change 100755 => 100644 Daemons/astrosib/HWon mode change 100755 => 100644 Daemons/astrosib/STARTobs mode change 100755 => 100644 Daemons/astrosib/STOPobs mode change 100644 => 100755 Daemons/netsocket/HWpoweroff mode change 100644 => 100755 Daemons/netsocket/HWpoweron mode change 100644 => 100755 Daemons/netsocket/MOUNTpoweronoff mode change 100755 => 100644 Daemons/weatherdaemon/chkweather mode change 100644 => 100755 Docs/Alignment/makelist mode change 100644 => 100755 Docs/focus diff --git a/Auxiliary_utils/Sun/Makefile b/Auxiliary_utils/Sun/Makefile new file mode 100644 index 0000000..d3bff37 --- /dev/null +++ b/Auxiliary_utils/Sun/Makefile @@ -0,0 +1,21 @@ +# run `make DEF=...` to add extra defines +PROGRAM = noon +LDFLAGS := -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--discard-all +LDFLAGS += -lnova +SRCS := $(wildcard *.c) +DEFINES := $(DEF) -D_GNU_SOURCE -D_XOPEN_SOURCE=1111 +CFLAGS += -O2 -Wno-trampolines -std=gnu99 +CC = gcc + + +LINKS := sunrise sunset + +all : $(LINKS) + +$(LINKS) : $(PROGRAM) + @echo "make links" + ln -s $< $@ || true + +$(PROGRAM): sun.c + @echo -e "\t\tCC $<" + $(CC) $(LDFLAGS) $(CFLAGS) $(DEFINES) -o $@ $< diff --git a/Auxiliary_utils/Sun/Readme b/Auxiliary_utils/Sun/Readme new file mode 100644 index 0000000..289ec28 --- /dev/null +++ b/Auxiliary_utils/Sun/Readme @@ -0,0 +1,9 @@ +Calculates times of sunrise, sunset and noon, gives @ stdout just UNIX time of event + +Sunrise/sunset - for particular angle below horizon (default: -18degr). + +Usage: + +- just `noon`, `sunrise` or `sunset` for default angles; +- `sunrise/sunset angle` for `angle` in degrees below horizon; +- `sunrise/sunset "standard"|"civil"|"nautic"|"astro" - calculates event for -0.833degr, -6degr, -12degr and -18degr. diff --git a/Auxiliary_utils/Sun/sun.c b/Auxiliary_utils/Sun/sun.c new file mode 100644 index 0000000..f3246db --- /dev/null +++ b/Auxiliary_utils/Sun/sun.c @@ -0,0 +1,73 @@ +/* +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Copyright (C) 2003 Liam Girdwood + + +A simple example showing some solar calculations. + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const double horizons[] = {LN_SOLAR_STANDART_HORIZON, LN_SOLAR_CIVIL_HORIZON, LN_SOLAR_NAUTIC_HORIZON, LN_SOLAR_ASTRONOMICAL_HORIZON}; +static const char *hnames[] = {"standard", "civil", "nautic", "astro"}; + +int main (int argc, char **argv){ + struct ln_equ_posn equ; + struct ln_rst_time rst; + struct ln_zonedate rise; + struct ln_lnlat_posn observer; + double JD, angle = LN_SOLAR_ASTRONOMICAL_HORIZON; + time_t t; + + if(argc == 2){ + if(isdigit(*argv[1])) angle = -atof(argv[1]); // angle value + else{ // angle name + for(int i = 0; i < sizeof(horizons)/sizeof(double); ++i){ + if(strcasecmp(argv[1], hnames[i]) == 0){ + angle = horizons[i]; + break; + } + } + } + }else if(argc > 2){ + fprintf(stderr, "Usage: %s [positive angle in degr] OR %s [\"standard\"|\"civil\"|\"nautic\"|\"astro\"]\n", + argv[0], argv[0]); + return 1; + } + + observer.lat = 43.653528; + observer.lng = 41.4414375; + JD = ln_get_julian_from_sys(); + ln_get_solar_equ_coords (JD, &equ); + if(ln_get_solar_rst_horizon(JD, &observer, angle, &rst) == 1) return 1; + if(strcasecmp(basename(argv[0]), "sunrise") == 0) + ln_get_timet_from_julian(rst.rise, &t); + else if(strcasecmp(basename(argv[0]), "sunset") == 0) + ln_get_timet_from_julian(rst.set, &t); + else + ln_get_timet_from_julian(rst.transit, &t); + printf("%zd\n", t); + return 0; +} diff --git a/Auxiliary_utils/bash_scripts/getflats b/Auxiliary_utils/bash_scripts/getflats old mode 100644 new mode 100755 diff --git a/Auxiliary_utils/bash_scripts/park_tel.sh b/Auxiliary_utils/bash_scripts/park_tel.sh old mode 100644 new mode 100755 diff --git a/Auxiliary_utils/bash_scripts/point_AH.sh b/Auxiliary_utils/bash_scripts/point_AH.sh old mode 100644 new mode 100755 diff --git a/Auxiliary_utils/bash_scripts/point_get_flat.sh b/Auxiliary_utils/bash_scripts/point_get_flat.sh old mode 100644 new mode 100755 diff --git a/Auxiliary_utils/bash_scripts/run b/Auxiliary_utils/bash_scripts/run old mode 100644 new mode 100755 diff --git a/Auxiliary_utils/bash_scripts/run_w_arrays b/Auxiliary_utils/bash_scripts/run_w_arrays old mode 100755 new mode 100644 diff --git a/Daemons/README_install/netdaemons_start b/Daemons/README_install/netdaemons_start old mode 100644 new mode 100755 diff --git a/Daemons/astrosib/HWoff b/Daemons/astrosib/HWoff old mode 100755 new mode 100644 diff --git a/Daemons/astrosib/HWon b/Daemons/astrosib/HWon old mode 100755 new mode 100644 diff --git a/Daemons/astrosib/STARTobs b/Daemons/astrosib/STARTobs old mode 100755 new mode 100644 diff --git a/Daemons/astrosib/STOPobs b/Daemons/astrosib/STOPobs old mode 100755 new mode 100644 diff --git a/Daemons/netsocket/HWpoweroff b/Daemons/netsocket/HWpoweroff old mode 100644 new mode 100755 diff --git a/Daemons/netsocket/HWpoweron b/Daemons/netsocket/HWpoweron old mode 100644 new mode 100755 diff --git a/Daemons/netsocket/MOUNTpoweronoff b/Daemons/netsocket/MOUNTpoweronoff old mode 100644 new mode 100755 diff --git a/Daemons/weatherdaemon/chkweather b/Daemons/weatherdaemon/chkweather old mode 100755 new mode 100644 diff --git a/Docs/Alignment/makelist b/Docs/Alignment/makelist old mode 100644 new mode 100755 diff --git a/Docs/focus b/Docs/focus old mode 100644 new mode 100755