fix some bugs

This commit is contained in:
eddyem 2020-01-23 17:33:32 +03:00
parent 4da483b33a
commit ec25bc36c7
21 changed files with 3849 additions and 3454 deletions

1
Apogee_control.cflags Normal file
View File

@ -0,0 +1 @@
-std=c17

7
Apogee_control.config Normal file
View File

@ -0,0 +1,7 @@
// Add predefined macros for your project here. For example:
// #define THE_ANSWER 42
#define IMAGEVIEW
#define EBUG
#define USEPNG
#define USERAW

1
Apogee_control.creator Normal file
View File

@ -0,0 +1 @@
[General]

256
Apogee_control.creator.user Normal file
View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.1, 2020-01-10T12:15:02. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{cf63021e-ef53-49b0-b03b-2f2570cdf3b6}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">KOI8-R</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">false</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">1</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">false</value>
<value type="QString" key="ClangCodeModel.WarningConfigId">{44e88e9a-8179-42ea-8aad-1bea96363cc6}</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">{44e88e9a-8179-42ea-8aad-1bea96363cc6}</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs">
<value type="QString">/home/eddy/tmp/apogee_control/Apogee_control.creator</value>
</valuelist>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eddy/tmp/apogee_control</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">По умолчанию</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eddy/tmp/apogee_control</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">cmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">cmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Конфигурация развёртывания</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Особая программа</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

1
Apogee_control.cxxflags Normal file
View File

@ -0,0 +1 @@
-std=c++17

16
Apogee_control.files Normal file
View File

@ -0,0 +1,16 @@
airmass.c
am.c
bta_print.c
bta_print.h
bta_shdata.c
bta_shdata.h
camtools.c
camtools.h
defhdrs.c
defhdrs.h
macros.c
macros.h
takepic.c
takepic.h
usage.c
usage.h

2
Apogee_control.includes Normal file
View File

@ -0,0 +1,2 @@
.
./image_view_module

View File

@ -1,25 +1,24 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.6)
set(PROJ apogee_control)
project(${PROJ})
set(VERSION "0.2.0")
set(CMAKE_COLOR_MAKEFILE ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
if(DEFINED EBUG)
add_definitions(-DEBUG)
set(CFLAGS ${CFLAGS} -Werror)
message("CFLAGS: ${CFLAGS}")
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
project(${PROJ} VERSION ${PROJ_VERSION} LANGUAGES C CXX)
#if(DEFINED CMAKE_INSTALL_PREFIX AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
# set(CMAKE_INSTALL_PREFIX "/usr")
#endif()
if(DEFINED CMAKE_INSTALL_PREFIX AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
set(CMAKE_INSTALL_PREFIX "/usr")
endif()
message("Install dir prefix: ${CMAKE_INSTALL_PREFIX}")
if(NOT DEFINED LOCALEDIR)
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
endif()
set(SOURCES defhdrs.c takepic.c usage.c camtools.c am.c macros.c)
if(DEFINED USE_BTA AND USE_BTA STREQUAL "yes")
set(SOURCES ${SOURCES} bta_print.c)
if(NOT DEFINED NOBTA)
set(SOURCES ${SOURCES} bta_print.c bta_shdata.c)
add_definitions(-DUSE_BTA)
endif()
if(DEFINED TELALT)
@ -45,26 +44,26 @@ endif()
add_definitions(-DTHREAD_NUMBER=${PROCESSOR_COUNT})
message("In multithreaded operations will use ${PROCESSOR_COUNT} threads")
set(LCPATH ${CMAKE_CURRENT_SOURCE_DIR}/locale/ru)
set(CFLAGS -O2 -Wextra -Wall -Werror -W -std=gnu99)
set(CFLAGS ${CFLAGS} -O2 -Wextra -Wall -W -std=gnu99)
#set(CFLAGS ${CFLAGS} -O2 -std=gnu99)
set(PO_FILE ${LCPATH}/messages.po)
set(MO_FILE ${LCPATH}/LC_MESSAGES/${PROJ}.mo)
set(RU_FILE ${LCPATH}/ru.po)
add_executable(${PROJ} ${SOURCES} ${PO_FILE} ${MO_FILE})
find_package(PkgConfig REQUIRED)
# find CFITSIO
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
FIND_PACKAGE(CFITSIO REQUIRED)
set(MODULES apogeec>=1.71 libusb>=0.1.10)
if(DEFINED USE_BTA AND USE_BTA STREQUAL "yes")
set(MODULES ${MODULES} sla)
set(MODULES cfitsio>=3.0 apogeec>=1.71 libusb>=0.1.10)
if(NOT DEFINED NOBTA)
#set(MODULES ${MODULES} sla)
target_link_libraries(${PROJ} crypt sofa_c)
endif()
if(DEFINED USE_PNG AND USE_PNG STREQUAL "yes")
if(DEFINED USEPNG)
set(MODULES ${MODULES} libpng>=1.2)
add_definitions(-DUSEPNG)
endif()
pkg_check_modules(${PROJ} REQUIRED ${MODULES})
if(DEFINED USE_RAW AND USE_RAW STREQUAL "yes")
if(DEFINED USERAW)
add_definitions(-DUSERAW)
endif()
@ -75,23 +74,22 @@ if(OPENMP_FOUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
add_executable(${PROJ} ${SOURCES} ${PO_FILE} ${MO_FILE})
include_directories(${${PROJ}_INCLUDE_DIRS} ${CFITSIO_INCLUDE_DIR} image_view_module)
include_directories(${${PROJ}_INCLUDE_DIRS} image_view_module)
link_directories(${${PROJ}_LIBRARY_DIRS})
add_definitions(${CFLAGS} -DLOCALEDIR=\"${LOCALEDIR}\" -DPACKAGE_VERSION=\"${VERSION}\"
-DGETTEXT_PACKAGE=\"${PROJ}\" -DPROJNAME=\"${PROJ}\")
if(DEFINED USE_IMAGEVIEW AND USE_IMAGEVIEW STREQUAL "yes")
if(NOT DEFINED NOIMAGEVIEW)
add_subdirectory(image_view_module)
endif()
if(IMAGEVIEW_FOUND)
message("Found OpenGL. Will use ${IMLIB} to show data")
find_package(X11 REQUIRED)
target_link_libraries(${PROJ} ${IMLIB} ${X11_LIBRARIES} ${${PROJ}_LIBRARIES} ${CFITSIO_LIBRARIES} -lm)
target_link_libraries(${PROJ} ${X11_LIBRARIES} ${${PROJ}_LIBRARIES} -lm ${IMLIB})
add_definitions(-DIMAGEVIEW)
else()
message("Will compile without image view module")
target_link_libraries(${PROJ} ${${PROJ}_LIBRARIES} ${CFITSIO_LIBRARIES} -lm)
target_link_libraries(${PROJ} ${${PROJ}_LIBRARIES} -lm)
endif()
# Installation of the program

View File

@ -28,15 +28,21 @@
* file_name - name of file to write to,
* "-" - stdout (default)
*/
#include "bta_shdata.h"
#include "takepic.h"
#include "camtools.h"
#include "bta_print.h"
#include "macros.h"
#include "usage.h" // command line parameters
#include "bta_shdata.h"
#include "camtools.h"
#include "defhdrs.h"
#include <slamac.h> // SLA macros
#include "macros.h"
#include "takepic.h"
#include "usage.h" // command line parameters
#include <sofa.h>
//#include <slamac.h> // SLA macros
#ifndef DR2S
#define DR2S 1.3750987083139757010431557155385240879777313391975e4
#endif
/*
extern void sla_amp(double*, double*, double*, double*, double*, double*);
void slaamp(double ra, double da, double date, double eq, double *rm, double *dm ){
@ -44,22 +50,45 @@ void slaamp(double ra, double da, double date, double eq, double *rm, double *dm
sla_amp(&r, &d, &mjd, &equi, rm, dm);
}
const double jd0 = 2400000.5; // JD for MJD==0
*/
/**
* convert apparent coordinates (nowadays) to mean (JD2000)
* appRA, appDecl in seconds
* r, d in seconds
*/
void calc_mean(double appRA, double appDecl, double *r, double *d){
double ra, dec;
void calc_mean(double appRA, double appDecl, double *r, double *dc){
double ra=0., dec=0., utc1, utc2, tai1, tai2, tt1, tt2, fd, eo, ri;
int y, m, d, H, M;
DBG("appRa: %g'', appDecl'': %g", appRA, appDecl);
appRA *= DS2R;
appDecl *= DAS2R;
//DBG("appRa: %g, appDecl: %g", appRA, appDecl);
double mjd = JDate - jd0;
/* double mjd = JDate - jd0;
slaamp(appRA, appDecl, mjd, 2000.0, &ra, &dec);
ra *= DR2S;
dec *= DR2AS;
DBG("SLALIB: r=%g'', d=%g''", ra, dec);
ra = 0.; dec = 0.;*/
// SOFA
#define SOFA(f, ...) do{if(f(__VA_ARGS__)){WARNX("Error in " #f); goto rtn;}}while(0)
// 1. convert system JDate to UTC
SOFA(iauJd2cal, JDate, 0., &y, &m, &d, &fd);
fd *= 24.;
H = (int)fd;
fd = (fd - H)*60.;
M = (int)fd;
fd = (fd - M)*60.;
SOFA(iauDtf2d, "UTC", y, m, d, H, M, fd, &utc1, &utc2);
SOFA(iauUtctai, utc1, utc2, &tai1, &tai2);
SOFA(iauTaitt, tai1, tai2, &tt1, &tt2);
iauAtic13(appRA, appDecl, tt1, tt2, &ri, &dec, &eo);
ra = iauAnp(ri + eo);
ra *= DR2S;
dec *= DR2AS;
DBG("SOFA: r=%g'', d=%g''", ra, dec);
#undef SOFA
rtn:
if(r) *r = ra;
if(d) *d = dec;
if(dc) *dc = dec;
}
char comment[FLEN_CARD];

View File

@ -23,6 +23,8 @@
#ifndef __BTA_PRINT_H__
#define __BTA_PRINT_H__
#include <fitsio.h>
void write_bta_data(fitsfile *fp);
int push_param();

345
bta_shdata.c Normal file
View File

@ -0,0 +1,345 @@
#include <crypt.h>
#include "bta_shdata.h"
#include "usefull_macros.h"
#pragma pack(push, 4)
// Main command channel (level 5)
struct CMD_Queue mcmd = {{"Mcmd"}, 0200,0,-1,0};
// Operator command channel (level 4)
struct CMD_Queue ocmd = {{"Ocmd"}, 0200,0,-1,0};
// User command channel (level 2/3)
struct CMD_Queue ucmd = {{"Ucmd"}, 0200,0,-1,0};
#define MSGLEN (80)
static char msg[MSGLEN];
#define PERR(...) do{snprintf(msg, MSGLEN, __VA_ARGS__); perror(msg);} while(0)
#ifndef BTA_MODULE
struct BTA_Data *sdt;
struct BTA_Local *sdtl;
struct SHM_Block sdat = {
{"Sdat"},
sizeof(struct BTA_Data),
2048,0444,
SHM_RDONLY,
bta_data_init,
bta_data_check,
bta_data_close,
ClientSide,-1,NULL
};
int snd_id = -1; // client sender ID
int cmd_src_pid = 0; // next command source PID
uint32_t cmd_src_ip = 0;// next command source IP
/**
* Init data
*/
void bta_data_init() {
sdt = (struct BTA_Data *)sdat.addr;
sdtl = (struct BTA_Local *)(sdat.addr+sizeof(struct BTA_Data));
if(sdat.side == ClientSide) {
if(sdt->magic != sdat.key.code) {
WARN("Wrong shared data (maybe server turned off)");
}
if(sdt->version == 0) {
WARN("Null shared data version (maybe server turned off)");
}
else if(sdt->version != BTA_Data_Ver) {
WARN("Wrong shared data version: I'am - %d, but server - %d ...",
BTA_Data_Ver, sdt->version );
}
if(sdt->size != sdat.size) {
if(sdt->size > sdat.size) {
WARN("Wrong shared area size: I needs - %d, but server - %d ...",
sdat.size, sdt->size );
} else {
WARN("Attention! Too little shared data structure!");
WARN("I needs - %d, but server gives only %d ...",
sdat.size, sdt->size );
WARN("May be server's version too old!?");
}
}
return;
}
/* ServerSide */
if(sdt->magic == sdat.key.code &&
sdt->version == BTA_Data_Ver &&
sdt->size == sdat.size)
return;
memset(sdat.addr, 0, sdat.maxsize);
sdt->magic = sdat.key.code;
sdt->version = BTA_Data_Ver;
sdt->size = sdat.size;
Tel_Hardware = Hard_On;
Pos_Corr = PC_On;
TrkOk_Mode = UseDiffVel | UseDiffAZ ;
inp_B = 591.;
Pressure = 595.;
PEP_code_A = 0x002aaa;
PEP_code_Z = 0x002aaa;
PEP_code_P = 0x002aaa;
PEP_code_F = 0x002aaa;
PEP_code_D = 0x002aaa;
DomeSEW_N = 1;
}
int bta_data_check() {
return( (sdt->magic == sdat.key.code) && (sdt->version == BTA_Data_Ver) );
}
void bta_data_close() {
if(sdat.side == ServerSide) {
sdt->magic = 0;
sdt->version = 0;
}
}
/**
* Allocate shared memory segment
*/
int get_shm_block(struct SHM_Block *sb, int server) {
int getsize = (server)? sb->maxsize : sb->size;
// first try to find existing one
sb->id = shmget(sb->key.code, getsize, sb->mode);
if(sb->id < 0 && errno == ENOENT && server){
// if no - try to create a new one
int cresize = sb->maxsize;
if(sb->size > cresize){
WARN("Wrong shm maxsize(%d) < realsize(%d)",sb->maxsize,sb->size);
cresize = sb->size;
}
sb->id = shmget(sb->key.code, cresize, IPC_CREAT|IPC_EXCL|sb->mode);
}
if(sb->id < 0){
if(server)
PERR("Can't create shared memory segment '%s'",sb->key.name);
else
PERR("Can't find shared segment '%s' (maybe no server process) ",sb->key.name);
return 0;
}
// attach it to our memory space
sb->addr = (unsigned char *) shmat(sb->id, NULL, sb->atflag);
if((long)sb->addr == -1){
PERR("Can't attach shared memory segment '%s'",sb->key.name);
return 0;
}
if(server && (shmctl(sb->id, SHM_LOCK, NULL) < 0)){
PERR("Can't prevents swapping of shared memory segment '%s'",sb->key.name);
return 0;
}
DBG("Create & attach shared memory segment '%s' %dbytes", sb->key.name, sb->size);
sb->side = server;
if(sb->init != NULL)
sb->init();
return 1;
}
int close_shm_block(struct SHM_Block *sb){
int ret;
if(sb->close != NULL)
sb->close();
if(sb->side == ServerSide) {
// ret = shmctl(sb->id, SHM_UNLOCK, NULL);
ret = shmctl(sb->id, IPC_RMID, NULL);
}
ret = shmdt (sb->addr);
return(ret);
}
/**
* Create|Find command queue
*/
void get_cmd_queue(struct CMD_Queue *cq, int server){
if (!server && cq->id >= 0) { //if already in use set current
snd_id = cq->id;
return;
}
// first try to find existing one
cq->id = msgget(cq->key.code, cq->mode);
// if no - try to create a new one
if(cq->id<0 && errno == ENOENT && server)
cq->id = msgget(cq->key.code, IPC_CREAT|IPC_EXCL|cq->mode);
if(cq->id<0){
if(server)
PERR("Can't create comand queue '%s'",cq->key.name);
else
PERR("Can't find comand queue '%s' (maybe no server process) ",cq->key.name);
return;
}
cq->side = server;
if(server){
char buf[120];
while(msgrcv(cq->id, (struct msgbuf *)buf, 112, 0, IPC_NOWAIT) > 0);
}else
snd_id = cq->id;
cq->acckey = 0;
}
#endif // BTA_MODULE
int check_shm_block(struct SHM_Block *sb) {
if(sb->check)
return(sb->check());
else return(0);
}
/**
* Set access key in current channel
*/
void set_acckey(uint32_t newkey){
if(snd_id < 0) return;
if(ucmd.id == snd_id) ucmd.acckey = newkey;
else if(ocmd.id == snd_id) ocmd.acckey = newkey;
else if(mcmd.id == snd_id) mcmd.acckey = newkey;
}
/**
* Setup source data for one following command if default values
* (IP == 0 - local, PID = current) not suits
*/
void set_cmd_src(uint32_t ip, int pid) {
cmd_src_pid = pid;
cmd_src_ip = ip;
}
#pragma pack(push, 4)
/**
* Send client commands to server
*/
void send_cmd(int cmd_code, char *buf, int size) {
struct my_msgbuf mbuf;
if(snd_id < 0) return;
if(size > 100) size = 100;
if(cmd_code > 0)
mbuf.mtype = cmd_code;
else
return;
if(ucmd.id == snd_id) mbuf.acckey = ucmd.acckey;
else if(ocmd.id == snd_id) mbuf.acckey = ocmd.acckey;
else if(mcmd.id == snd_id) mbuf.acckey = mcmd.acckey;
mbuf.src_pid = cmd_src_pid ? cmd_src_pid : getpid();
mbuf.src_ip = cmd_src_ip;
cmd_src_pid = cmd_src_ip = 0;
if(size > 0)
memcpy(mbuf.mtext, buf, size);
else {
mbuf.mtext[0] = 0;
size = 1;
}
msgsnd(snd_id, (struct msgbuf *)&mbuf, size+12, IPC_NOWAIT);
}
void send_cmd_noarg(int cmd_code) {
send_cmd(cmd_code, NULL, 0);
}
void send_cmd_str(int cmd_code, char *arg) {
send_cmd(cmd_code, arg, strlen(arg)+1);
}
void send_cmd_i1(int cmd_code, int32_t arg1) {
send_cmd(cmd_code, (char *)&arg1, sizeof(int32_t));
}
void send_cmd_i2(int cmd_code, int32_t arg1, int32_t arg2) {
int32_t ibuf[2];
ibuf[0] = arg1;
ibuf[1] = arg2;
send_cmd(cmd_code, (char *)ibuf, 2*sizeof(int32_t));
}
void send_cmd_i3(int cmd_code, int32_t arg1, int32_t arg2, int32_t arg3) {
int32_t ibuf[3];
ibuf[0] = arg1;
ibuf[1] = arg2;
ibuf[2] = arg3;
send_cmd(cmd_code, (char *)ibuf, 3*sizeof(int32_t));
}
void send_cmd_i4(int cmd_code, int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4) {
int32_t ibuf[4];
ibuf[0] = arg1;
ibuf[1] = arg2;
ibuf[2] = arg3;
ibuf[3] = arg4;
send_cmd(cmd_code, (char *)ibuf, 4*sizeof(int32_t));
}
void send_cmd_d1(int32_t cmd_code, double arg1) {
send_cmd(cmd_code, (char *)&arg1, sizeof(double));
}
void send_cmd_d2(int cmd_code, double arg1, double arg2) {
double dbuf[2];
dbuf[0] = arg1;
dbuf[1] = arg2;
send_cmd(cmd_code, (char *)dbuf, 2*sizeof(double));
}
void send_cmd_i1d1(int cmd_code, int32_t arg1, double arg2) {
struct {
int32_t ival;
double dval;
} buf;
buf.ival = arg1;
buf.dval = arg2;
send_cmd(cmd_code, (char *)&buf, sizeof(buf));
}
void send_cmd_i2d1(int cmd_code, int32_t arg1, int32_t arg2, double arg3) {
struct {
int32_t ival[2];
double dval;
} buf;
buf.ival[0] = arg1;
buf.ival[1] = arg2;
buf.dval = arg3;
send_cmd(cmd_code, (char *)&buf, sizeof(buf));
}
void send_cmd_i3d1(int cmd_code, int32_t arg1, int32_t arg2, int32_t arg3, double arg4) {
struct {
int32_t ival[3];
double dval;
} buf;
buf.ival[0] = arg1;
buf.ival[1] = arg2;
buf.ival[2] = arg3;
buf.dval = arg4;
send_cmd(cmd_code, (char *)&buf, sizeof(buf));
}
void encode_lev_passwd(char *passwd, int nlev, uint32_t *keylev, uint32_t *codlev){
char salt[4];
char *encr;
union {
uint32_t ui;
char c[4];
} key, cod;
sprintf(salt,"L%1d",nlev);
encr = (char *)crypt(passwd, salt);
cod.c[0] = encr[2];
key.c[0] = encr[3];
cod.c[1] = encr[4];
key.c[1] = encr[5];
cod.c[2] = encr[6];
key.c[2] = encr[7];
cod.c[3] = encr[8];
key.c[3] = encr[9];
*keylev = key.ui;
*codlev = cod.ui;
}
int find_lev_passwd(char *passwd, uint32_t *keylev, uint32_t *codlev){
int nlev;
for(nlev = 5; nlev > 0; --nlev){
encode_lev_passwd(passwd, nlev, keylev, codlev);
if(*codlev == code_Lev(nlev)) break;
}
return(nlev);
}
int check_lev_passwd(char *passwd){
uint32_t keylev,codlev;
int nlev;
nlev = find_lev_passwd(passwd, &keylev, &codlev);
if(nlev > 0) set_acckey(keylev);
return(nlev);
}
#pragma pack(pop)

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ double avr, std; // average value and standard deviation
* if user set option fan-speed=F, then speed would be set to F
* if onoff == FALSE, try to set speed according to hot Peltier temperature
* if onoff == TRUE, set speed=3, if cooler is on, else set speed=0
*/
*
void AutoadjustFanSpeed(bool onoff){
int Mode = 3, curMode, stat;
double temp, HotTemp;
@ -67,7 +67,7 @@ void AutoadjustFanSpeed(bool onoff){
else
// "îÅ ÍÏÇÕ ÓÍÅÎÉÔØ ÓËÏÒÏÓÔØ ×ÒÁÝÅÎÉÑ ×ÅÎÔÉÌÑÔÏÒÏ×!\n"
ERR("Can't set fan speed\n");
}
}*/
double printCoolerStat(double *t_ext){
double temp, extemp, settemp;
@ -279,7 +279,7 @@ int writepng(char *filename, int width, int height, void *data){
FILE *fp = NULL;
png_structp pngptr = NULL;
png_infop infoptr = NULL;
void *row;
png_const_bytep row = data + (height-1)*width*sizeof(u_int16_t);
if ((fp = fopen(filename, "wb")) == NULL){
err = -errno;
goto done;
@ -294,13 +294,13 @@ int writepng(char *filename, int width, int height, void *data){
goto done;
}
png_init_io(pngptr, fp);
png_set_compression_level(pngptr, 6);
png_set_compression_level(pngptr, 5);
png_set_IHDR(pngptr, infoptr, width, height, 16, PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(pngptr, infoptr);
png_set_swap(pngptr);
for(row = data; height > 0; row += width * sizeof(u_int16_t), height--)
for(; height > 0; row -= width * sizeof(u_int16_t), height--)
png_write_row(pngptr, row);
png_write_end(pngptr, infoptr);
err = 0;
@ -369,9 +369,9 @@ void gray2rgb(double gray, GLubyte *rgb){
}
double linfun(double arg){ return arg; } // bung for PREVIEW_LINEAR
double logfun(double arg){ return log(1.+arg); } // for PREVIEW_LOG
double (*colorfun)(double) = linfun; // default function to convert color
static double linfun(double arg){ return arg; } // bung for PREVIEW_LINEAR
static double logfun(double arg){ return log(1.+arg); } // for PREVIEW_LOG
static double (*colorfun)(double) = linfun; // default function to convert color
void change_colorfun(colorfn_type f){
switch (f){

View File

@ -23,6 +23,9 @@
#ifndef __CAMTOOLS_H__
#define __CAMTOOLS_H__
#include <fitsio.h>
#include <stdbool.h>
#define TRYFITS(f, ...) \
do{if(!test_headers){ int status = 0; \
f(__VA_ARGS__, &status); \
@ -42,7 +45,7 @@ extern double avr, std;
extern time_t expStartsAt;
void AutoadjustFanSpeed(bool onoff);
//void AutoadjustFanSpeed(bool onoff);
double printCoolerStat(double *t_ext);
void print_stat(unsigned short *img, long size, FILE* f);
@ -57,9 +60,9 @@ int writeraw(char *filename, int width, int height, void *data);
#endif // USERAW
#ifdef IMAGEVIEW
#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/freeglut.h>
#include <GL/glext.h>
#include <GL/glut.h>
#include <math.h>
// functions for converting grayscale value into colour

View File

@ -32,17 +32,16 @@ YPIXELSZ
IMSCALE
*/
#define _GNU_SOURCE
#include <math.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <fitsio.h>
#include <math.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include "defhdrs.h"
#include "usage.h"
#include "macros.h"
#include "camtools.h"
#include "defhdrs.h"
#include "macros.h"
#include "usage.h"
// global keylist
static KeyList *FITS_keys = NULL;
@ -237,7 +236,7 @@ void add_fits_header(int datatype, char *keyname, void *value, char *comment){
void _log(char* r, void* p){snprintf(r, FLEN_CARD, "'%s'", (int*)p ? "true" : "false");}
void _str(char* r, void* p){snprintf(r, FLEN_CARD, "'%s'", (char*)p);}
void _unk(char* r, void* p __attribute((unused))){sprintf(r, "unknown datatype");}
char tmp[FLEN_CARD], res[FLEN_CARD];
char tmp[FLEN_CARD*2], res[FLEN_CARD];
void (*__)(char*, void*);
switch(datatype){
case TBIT:
@ -263,18 +262,26 @@ void add_fits_header(int datatype, char *keyname, void *value, char *comment){
if(rec){
if(comment){
if(strlen(res) < 21)
snprintf(tmp, FLEN_CARD, "%-21s / %s", res, comment);
snprintf(tmp, sizeof(tmp), "%-21s / %s", res, comment);
else
snprintf(tmp, FLEN_CARD, "%s / %s", res, comment);
}else snprintf(tmp, FLEN_CARD, "%s", res);
snprintf(tmp, sizeof(tmp), "%s / %s", res, comment);
}else snprintf(tmp, sizeof(tmp), "%s", res);
tmp[FLEN_CARD-1] = 0;
list_modify_key(FITS_keys, keyname, tmp, 0);
}else{
if(comment){
if(strlen(res) < 21)
snprintf(tmp, FLEN_CARD, "%-8s= %-20s", keyname, res);
snprintf(tmp, sizeof(tmp), "%-8s= %-20s / %s", keyname, res, comment);
else
snprintf(tmp, FLEN_CARD, "%-8s=%s", keyname, res);
snprintf(res, FLEN_CARD, "%s / %s", tmp, comment);
list_add_record(&FITS_keys, res, 0);
snprintf(tmp, sizeof(tmp), "%-8s=%s / %s", keyname, res, comment);
}else{
if(strlen(res) < 21)
snprintf(tmp, sizeof(tmp), "%-8s= %-20s", keyname, res);
else
snprintf(tmp, sizeof(tmp), "%-8s=%s", keyname, res);
}
tmp[FLEN_CARD-1] = 0;
list_add_record(&FITS_keys, tmp, 0);
}
}

View File

@ -29,7 +29,7 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} IMSOURCES)
find_package(PkgConfig REQUIRED)
find_package(OpenGL)
find_package(GLUT)
find_package(X11)
find_package(X11 REQUIRED)
if(NOT GLUT_FOUND OR NOT OPENGL_FOUND OR NOT X11_FOUND)
message("GLUT library not found, image view won't be available")
@ -143,7 +143,7 @@ else()
)
endif(NOT DEFINED NOGETTEXT)
endif(NOT DEFINED STANDALONE)
target_link_libraries(${IMLIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} -lm -lpthread)
target_link_libraries(${IMLIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${X11_LIBRARIES} -lm -lpthread)
include_directories(${${IMLIB}_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ..)
link_directories(${${IMLIB}_LIBRARY_DIRS})
endif(NOT GLUT_FOUND OR NOT OPENGL_FOUND OR NOT X11_FOUND)

View File

@ -209,10 +209,11 @@ void RedrawWindow(){
}
w /= 2.; h /= 2.;
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(-w, -h );
glTexCoord2f(1.0f, 0.0f); glVertex2f( w, -h );
glTexCoord2f(1.0f, 1.0f); glVertex2f( w, h );
glTexCoord2f(0.0f, 1.0f); glVertex2f(-w, h );
glTexCoord2f(1.0f, 1.0f); glVertex2f( -w, -h ); // top right
glTexCoord2f(1.0f, 0.0f); glVertex2f( -w, h ); // bottom right
glTexCoord2f(0.0f, 0.0f); glVertex2f(w, h ); // bottom left
glTexCoord2f(0.0f, 1.0f); glVertex2f(w, -h ); // top left
glEnd();
glDisable(GL_TEXTURE_2D);
glFinish();

1
netcamID Normal file
View File

@ -0,0 +1 @@
apogee_control -M interface=ethernet,deviceType=camera,address=192.168.99.121,port=80,mac=000951ffffff81ffffffed22,interfaceStatus=Available,id=0x1a3,firmwareRev=0x132,model=Aspen-16M

169
takepic.c
View File

@ -19,35 +19,35 @@
* MA 02110-1301, USA.
*/
#include "takepic.h"
#include <locale.h>
#include <signal.h>
#include <dirent.h>
#include <float.h>
#include <usb.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
#include <locale.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <usb.h>
#include "defhdrs.h"
#include "usage.h"
#include "camtools.h"
#ifdef USE_BTA
#include "bta_print.h"
#endif
#include "macros.h"
#include "camtools.h"
#include "defhdrs.h"
#ifdef IMAGEVIEW
#include "imageview.h"
#endif
#include "macros.h"
#include "takepic.h"
#include "usage.h"
#define BUFF_SIZ 4096
#define PROC_BASE "/proc"
#define TMBUFSIZ 40 // time string buffer length
char *pidfilename = "/tmp/apogee_control.pid"; // pidfile
static char *pidfilename = "/tmp/apogee_control.pid"; // pidfile
char tm_buf[TMBUFSIZ]; // time string buffer
static char tm_buf[TMBUFSIZ]; // time string buffer
char *camera = NULL, *sensor = NULL, viewfield[80];
double pixX, pixY; // pixel size
@ -57,18 +57,18 @@ int test_headers = 0; // don't even try to open camera device, just show FITS ke
double t_ext, t_int; // hot & cold side temperatures
time_t expStartsAt; // time of exposition start (time_t)
int itime(){ // time in seconds to count intervals
static int itime(){ // time in seconds to count intervals
struct timeval ct;
gettimeofday(&ct, NULL);
return (ct.tv_sec);
}
int time0;
int ltime(){ // time since last time0 reinitialising
static int time0;
static int ltime(){ // time since last time0 reinitialising
return(itime()-time0);
}
// return string with current date/time
size_t curtime(char *s_time){
static size_t curtime(char *s_time){
time_t tm = time(NULL);
size_t s = strftime(s_time, TMBUFSIZ, "%d/%m/%Y,%H:%M:%S", localtime(&tm));
if(!s) info("curtime() error");
@ -76,7 +76,7 @@ size_t curtime(char *s_time){
}
// find the first non-exists filename & put it into buff
int check_filename(char *buff, char *outfile, char *ext){
static int check_filename(char *buff, char *outfile, char *ext){
struct stat filestat;
int num;
for(num = 1; num < 10000; num++){
@ -88,9 +88,9 @@ int check_filename(char *buff, char *outfile, char *ext){
return 0;
}
void reset_usb_port(int pid, int vid){
static void reset_usb_port(int pid, int vid){
int fd, rc;
char buf[256], *d = NULL, *f = NULL;
char buf[FILENAME_MAX*3], *d = NULL, *f = NULL;
struct usb_bus *bus;
struct usb_device *dev;
int found = 0;
@ -112,9 +112,9 @@ void reset_usb_port(int pid, int vid){
return;
}
DBG("found camera device, reseting");
snprintf(buf, 255, "/dev/bus/usb/%s/%s", d,f);
snprintf(buf, sizeof(buf), "/dev/bus/usb/%s/%s", d,f);
fd = open(buf, O_WRONLY);
if (fd < 0) {
if (fd < 0){
// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÆÁÊÌ ÕÓÔÒÏÊÓÔ×Á %s: %s"
ERR(_("Can't open device file %s: %s"), buf, strerror(errno));
return;
@ -133,14 +133,17 @@ void reset_usb_port(int pid, int vid){
static void signals(int sig){
int u;
// "ðÏÌÕÞÅÎ ÓÉÇÎÁÌ %d, ÏÔËÌÀÞÁÀÓØ.\n"
if(sig){
signal(sig, signals);
printf(_("Get signal %d, quit.\n"), sig);
}
u = unlink(pidfilename);
// "îÅ ÍÏÇÕ ÕÄÁÌÉÔØ PID-ÆÁÊÌ"
if(u == -1) perror(_("Can't delete PIDfile"));
ApnGlueWheelClose();
DBG("wheel closed");
// ApnGlueExpAbort(); // this function stubs all!
// DBG("exp aborted");
ApnGlueExpAbort(); // this function stubs all!
DBG("exp aborted");
ApnGlueClose();
DBG("device closed");
#ifdef IMAGEVIEW
@ -149,10 +152,10 @@ static void signals(int sig){
exit(sig);
}
int sigcounter = 3;
static int sigcounter = 3;
static void cnt_signals(int sig){
--sigcounter;
if(sigcounter != 0){
if(sigcounter){
// "îÁÖÍÉÔÅ Ctrl+C ÅÝÅ %d ÒÁÚ[Á], ÞÔÏÂÙ ÐÒÅÒ×ÁÔØ ÓÞÉÔÙ×ÁÎÉÅ\n"
printf(_("Press Ctrl+C %d time[s] more to interrupt reading\n"), sigcounter);
signal(SIGINT, cnt_signals);
@ -162,14 +165,14 @@ static void cnt_signals(int sig){
}
// Try to ignore all signals exept SIGINT, which is counted
void ignore_signals(){
static void ignore_signals(){
sigcounter = 3;
for(int _=0; _<256; _++)
signal(_, SIG_IGN);
signal(SIGINT, cnt_signals);
}
// We must take care about signals to avoid ctrl+C problems
void catch_signals(){
static void catch_signals(){
for(int _=0; _<256; _++)
signal(_, SIG_IGN);
signal(SIGTERM, signals); // kill (-15) - quit
@ -178,16 +181,16 @@ void catch_signals(){
signal(SIGQUIT, signals); // ctrl+\ - quit
//signal(SIGTSTP, SIG_IGN); // ignore ctrl+Z
}
/*
void restore_signals(){
sigcounter = 3;
for(int _=0; _<256; _++)
signal(_, SIG_DFL);
unlink(pidfilename);
}
}*/
// check for running process
void check4running(){
static void check4running(){
// get process name from /proc
int readname(char *name, pid_t pid){
char *pp = name, byte, path[256];
@ -248,7 +251,7 @@ void check4running(){
}
// Work with turret
void parse_turret_args(){
static void parse_turret_args(){
int maxPos, curPos;
if(ApnGlueWheelOpen(Nwheel, Apn_Filter_FW50_7S)){
// "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÔÕÒÅÌØ"
@ -286,7 +289,7 @@ wheelret:
}
#ifdef IMAGEVIEW
void change_displayed_image(unsigned short *buf, windowData *win){
static void change_displayed_image(unsigned short *buf, windowData *win){
FNAME();
if(!win) return;
pthread_mutex_lock(&win->mutex);
@ -352,16 +355,31 @@ int main(int argc, char **argv){
exit(9);
}
DBG("open %d", Ncam);
ApnGlueGetName(&sensor, &camera);
camera = strdup(camera); sensor = strdup(sensor);
// ApnGlueGetName(&sensor, &camera);
// camera = strdup(camera); sensor = strdup(sensor); - bug. it shows a shit!
// "ïÂÎÁÒÕÖÅÎÁ ËÁÍÅÒÁ '%s' Ó ÄÁÔÞÉËÏÍ '%s'"
info(_("Find camera '%s' with sensor '%s'"), camera, sensor);
// "áÄÒÅÓ USB: "
char *msg = NULL;
char *findnm(const char *nm){
char *f = strstr(msg, nm);
DBG("f=%s", f);
if(!f) return NULL;
f += strlen(nm);
DBG("f=%s", f);
char *e = strchr(f, '\n');
DBG("e=%s", e);
size_t l = (e) ? (size_t)(e-f) : strlen(f);
char *r = MALLOC(char, l+1);
snprintf(r, l, f);
DBG("r=%s", r);
return r;
}
msg = ApnGlueGetInfo(&pid, &vid);
if(msg){
printf("\n Camera info:\n%s\n", msg);
//printf("\n Camera info:\n%s\n", msg);
camera = findnm("Model: ");
sensor = findnm("Sensor: ");
info(_("Camera '%s' with sensor '%s' detected"), camera, sensor);
free(msg);
}
@ -383,6 +401,7 @@ DBG("open %d", Ncam);
}
goto returning;
}
// And then we can do other work
if(save_Tlog){
struct stat s;
@ -408,9 +427,10 @@ DBG("open %d", Ncam);
if(print_hdr)
fprintf(f_statlog, "Time\t\t\tUnix time\tTexp\tTint\tText\tImax\tImin\tIavr\tIstd\tNover\tN>3std\tIavr3\t\tIstd3\n");
}
//ApnGlueSetFan(3);
ApnGlueGetMaxValues (NULL, &roiw, &roih, &osw, &osh, &binw, &binh,
ApnGlueGetMaxValues(NULL, &roiw, &roih, &osw, &osh, &binw, &binh,
&shtr, &mintemp);
info(_("Max binning: %dx%d\n"), binw, binh);
DBG("Shtr = %d, mintemp = %g", shtr, mintemp);
ApnGlueGetGeom(&pixX, &pixY);
// "\núÁÔ×ÏÒ "
printf(_("\nThe shutter is "));
@ -429,7 +449,7 @@ DBG("open %d", Ncam);
info(_("Switch cooler off"));
}else{
if(temperature >= mintemp){
if(temperature == 0) temperature += DBL_EPSILON; // remove problem of zero temperature
if(temperature == 0.) temperature += 2.*DBL_EPSILON; // remove problem of zero temperature
ApnGlueSetTemp(temperature);
// "éÚÍÅÎÅÎÉÅ ÔÅÍÐÅÒÁÔÕÒÙ ÈÏÌÏÄÉÌØÎÉËÁ"
info(_("Changing of cooler setpoint"));
@ -439,27 +459,45 @@ DBG("open %d", Ncam);
}
}
if(fanspd > -1){
ApnGlueSetFan(fanspd);
if(ApnGlueGetFan() == fanspd)
// "õÓÔÁÎÁ×ÌÉ×ÁÀ ÓËÏÒÏÓÔØ ×ÒÁÝÅÎÉÑ ×ÅÎÔÉÌÑÔÏÒÏ× × %d\n"
info(_("Set fan speed %d\n"), fanspd);
else
// "îÅ ÍÏÇÕ ÓÍÅÎÉÔØ ÓËÏÒÏÓÔØ ×ÒÁÝÅÎÉÑ ×ÅÎÔÉÌÑÔÏÒÏ×!\n"
ERR("Can't set fan speed\n");
}
if(only_T || exptime < 0) goto returning;
// òÁÚÍÅÒ ÐÉËÓÅÌÑ: %g x %g
//info(_("Pixel size: %g x %g"), pixX, pixY);
snprintf(viewfield, 79, "(0, %d)(0, %d)", roiw, roih);
--roiw;
--roih;
snprintf(viewfield, 79, "(0, %d)(0, %d)", roiw-osw, roih-osh);
// "÷ÉÄÉÍÏÅ ÐÏÌÅ: %s"
info(_("Field of view: %s"), viewfield);
// "ðÏÌÅ ÉÚÏÂÒÁÖÅÎÉÑ: (0, %d)(0, %d)"
info(_("Array field: (0, %d)(0, %d)"), roiw+osw, roih+osh);
info(_("Array field: (0, %d)(0, %d)"), roiw, roih);
if(X0 == -1) X0 = 0; // default parameters
if(Y0 == -1) Y0 = 0;
if(X1 == -1 || X1 > roiw) X1 = roiw;
if(Y1 == -1 || Y1 > roih) Y1 = roih;
if(X0 != 0 || X1 != roiw) osw = 0; // check overskan
if(Y0 != 0 || Y1 != roih) osh = 0;
// check overskan
if(X0 != 0 || X1 != roiw){
if(X1 == roiw) X1 -= osw;
osw = 0;
}
if(Y0 != 0 || Y1 != roih){
if(Y1 == roih) Y1 -= osh;
osh = 0;
}
if(hbin > binw) hbin = binw;
if(vbin > binh) vbin = binh;
AutoadjustFanSpeed(FALSE);
//AutoadjustFanSpeed(FALSE);
if(noflash) ApnGluePreFlash(0);
if(noclean) ApnGlueDisablePostExpFlushing(1);
if(twelveBit)
@ -475,8 +513,7 @@ DBG("open %d", Ncam);
double E = 0.;
if(!twelveBit)
ApnGlueSetDatabits(Apn_Resolution_TwelveBit);
if(ApnGlueSetExpGeom(roiw, roih, 0, 0, 8, 8,
0, 0, &imW, &imH, whynot)){
if(ApnGlueSetExpGeom(8, 8, 0, 0, 8, 8, 0, 0, &imW, &imH, whynot)){
// "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÐÁÒÁÍÅÔÒÙ ÓÞÉÔÙ×ÁÎÉÑ: %s"
ERR("Can't set readout parameters: %s", whynot);
goto returning;
@ -491,7 +528,7 @@ DBG("open %d", Ncam);
if(pid > 0 && vid > 0)
reset_usb_port(pid, vid);
// "ïÛÉÂËÁ ÜËÓÐÏÚÉÃÉÉ!"
if(ApnGlueStartExp(&E, 0)) ERR("Error exposing frame!");
if(ApnGlueStartExp(&E, 0)) ERR("Error exposing pre-exp frame!");
}
ignore_signals();
if(ApnGlueReadPixels(buf, L, whynot)){
@ -504,12 +541,16 @@ DBG("open %d", Ncam);
if(!twelveBit)
ApnGlueSetDatabits(Apn_Resolution_SixteenBit);
}
if(ApnGlueSetExpGeom(X1-X0, Y1-Y0, osw, osh, hbin, vbin,
if(ApnGlueSetExpGeom(X1-X0-1, Y1-Y0+1, osw, osh, hbin, vbin,
X0, Y0, &imW, &imH, whynot)){
DBG("ApnGlueSetExpGeom(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s)", X1-X0+1, Y1-Y0+1, osw, osh, hbin, vbin,
X0, Y0, imW, imH, whynot);
// "îÅ ÍÏÇÕ ÕÓÔÁÎÏ×ÉÔØ ÐÁÒÁÍÅÔÒÙ ÓÞÉÔÙ×ÁÎÉÑ: %s"
ERR("Can't set readout parameters: %s", whynot);
goto returning;
}
DBG("ApnGlueSetExpGeom(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s)", X1-X0+1, Y1-Y0+1, osw, osh, hbin, vbin,
X0, Y0, imW, imH, whynot);
} // <------ end of non-fake block
DBG("geomery: %dx%d", imW, imH);
int L = imW*imH;
@ -531,9 +572,9 @@ DBG("open %d", Ncam);
if(fake) pics = 0;
DBG("start %d expositions", pics);
for (i = 0; i < pics; i++){
DBG("spd");
/*DBG("spd");
AutoadjustFanSpeed(FALSE);
DBG("cooler");
DBG("cooler");*/
temperature = printCoolerStat(NULL);
double E;
int I;
@ -543,6 +584,7 @@ DBG("open %d", Ncam);
ignore_signals();
DBG("start exp");
if(ApnGlueStartExp(&E, shutter)){
DBG("pid=%d, vid=%d", pid, vid);
if(pid > 0 && vid > 0)
reset_usb_port(pid, vid);
// "ïÛÉÂËÁ ÜËÓÐÏÚÉÃÉÉ!"
@ -569,7 +611,7 @@ DBG("open %d", Ncam);
if(save_Tlog && curtime(tm_buf)){
fprintf(f_tlog, "%s\t%ld\t%.2f\t%.2f\tX\n", tm_buf, time(NULL), t_int, t_ext);
}
AutoadjustFanSpeed(FALSE);
//AutoadjustFanSpeed(FALSE);
int tt = ltime();
printf("%d sec\n", tt);
if(I - tt > time_interval){
@ -677,7 +719,7 @@ DBG("open %d", Ncam);
if(save_Tlog && curtime(tm_buf)){
fprintf(f_tlog, "%s\t%ld\t%.2f\t%.2f\tI\n", tm_buf, time(NULL), temperature, t_ext);
}
AutoadjustFanSpeed(FALSE);
//AutoadjustFanSpeed(FALSE);
if(delta > 10) sleep(10);
else sleep(delta);
}
@ -704,20 +746,6 @@ DBG("open %d", Ncam);
#endif
returning:
if(!only_turret){
if(!fake){
// set fan speed to 0 or 3 according cooler status
AutoadjustFanSpeed(TRUE);
DBG("abort exp");
ApnGlueExpAbort();
DBG("close");
ApnGlueClose();
restore_signals();
DBG("free buffers & close files");
free(buf);
free_fits_list();
if(f_tlog) fclose(f_tlog);
if(f_statlog) fclose(f_statlog);
}
#ifdef IMAGEVIEW
DBG("test for GL window");
if(mainwin){ //window was created - wait for manual close
@ -728,6 +756,11 @@ returning:
FREE(im.rawdata);
}
#endif
if(!fake){
if(f_tlog) fclose(f_tlog);
if(f_statlog) fclose(f_statlog);
signals(0);
}
}
return 0;
}

View File

@ -24,28 +24,28 @@
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 501
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <err.h>
#include <limits.h>
#include <errno.h>
#include <math.h>
#include <stdbool.h>
#include <fitsio.h>
#include <libintl.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <fitsio.h>
#include <libapogee.h>
#include <libintl.h>
#include <limits.h>
#include <math.h>
#ifdef USEPNG
#include <png.h>
#endif /* USEPNG */
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <libapogee.h>
#ifndef GETTEXT_PACKAGE
#define GETTEXT_PACKAGE "apogee_control"

View File

@ -92,6 +92,7 @@ bool
;
int myatoi(int *num, const char *str){ // "careful" atoi
if(!num || !str) return -1;
long tmp;
char *endptr;
tmp = strtol(str, &endptr, 0);
@ -131,8 +132,8 @@ void usage(char *fmt, ...){
printf("\n\n");
}
va_end(ap);
// "Использование:\t%s [опции] [префикс выходных файлов]\n"
printf(_("Usage:\t%s [options] [output files prefix] [additional headers]\n"),
// "Использование:\t%s [опции]\n"
printf(_("Usage:\t%s [options]\n"),
__progname);
// "\tïÐÃÉÉ:\n"
printf(_("\tOptions:\n"));