initial commit

This commit is contained in:
Edward Emelianov 2024-06-03 16:38:39 +03:00
parent 0206dd7f90
commit 14a9324ec5
17 changed files with 707 additions and 0 deletions

96
CMakeLists.txt Normal file
View File

@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.20)
set(PROJ loccorr)
set(MAJOR_VERSION "0")
set(MID_VERSION "0")
set(MINOR_VERSION "1")
set(VERSION "${MAJOR_VERSION}.${MID_VERSION}.${MINOR_VERSION}")
project(${PROJ} VERSION ${VERSION} LANGUAGES C)
message("\n\nPlease, check current version: ${VERSION}\n\n")
# list of options
# three-state DEBUG option
set(DEBUG OFF CACHE STRING "Debug mode: on/part/off (full debug, release with debug info, full release)")
set_property(CACHE DEBUG PROPERTY STRINGS PART ON OFF)
#option(DEBUG "Compile in debug mode" OFF)
option(LCDUMMY "Dummy local corrector plugin" ON)
option(TELDUMMY "Dummy telescope plugin" ON)
# here is one of two variants: all .c in directory or .c files in list
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
# default flags
message("\n\nDIR: ${CMAKE_CURRENT_SOURCE_DIR}\n\n")
# fmacro-prefix-map: https://stackoverflow.com/a/53848526/1965803 - replace full path with short
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -Wextra -fno-builtin-strlen -fmacro-prefix-map=\"${CMAKE_CURRENT_SOURCE_DIR}\"/=\"\" ")
message("Check install dir prefix: ${CMAKE_INSTALL_PREFIX}")
add_definitions(-D_XOPEN_SOURCE=1234 -D_DEFAULT_SOURCE -D_GNU_SOURCE
-DPACKAGE_VERSION=\"${VERSION}\" -DMINOR_VERSION=\"${MINOR_VERSION}\"
-DMID_VERSION=\"${MID_VERSION}\" -DMAJOR_VERSION=\"${MAJOR_VESION}\")
set(CMAKE_COLOR_MAKEFILE ON)
# cmake -DDEBUG=on/part/off -> debug / release with debug info / release
if(DEBUG STREQUAL "PART") # part
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -march=native -fdata-sections -ffunction-sections -flto=auto")
add_definitions(-DEBUG)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -flto=auto")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(CMAKE_VERBOSE_MAKEFILE "ON")
elseif(DEBUG) # on
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -g3 -ggdb -Werror")
add_definitions(-DEBUG)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_VERBOSE_MAKEFILE "ON")
else() # off
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -march=native -fdata-sections -ffunction-sections -flto=auto")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -flto=auto")
set(CMAKE_BUILD_TYPE Release)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
#find_package(CFITSIO REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(${PROJ} REQUIRED usefull_macros improc ccdcapture)
include(FindOpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
add_definitions(-DOMP_FOUND)
endif()
# Dummy plugins
if(LCDUMMY)
add_subdirectory(Dummy_loccorr)
endif()
if(TELDUMMY)
add_subdirectory(Dummy_telescope)
endif()
# exe & lib files; install
include(GNUInstallDirs)
#add_library(${PROJLIB} SHARED ${LIBSRC})
add_executable(${PROJ} ${SOURCES})
target_link_libraries(${PROJ} ${${PROJ}_LIBRARIES} -lm ${CMAKE_DL_LIBS})
#target_link_libraries(${PROJLIB} ${CFITSIO_LIBRARIES} ${${PROJLIB}_LIBRARIES})
include_directories(${${PROJ}_INCLUDE_DIRS} .)
link_directories(${${PROJ}_LIBRARY_DIRS} )
set(PCFILE "${CMAKE_BINARY_DIR}/${PROJLIB}.pc")
#configure_file("${PROJLIB}.pc.in" ${PCFILE} @ONLY)
#set_target_properties(${PROJLIB} PROPERTIES VERSION ${VERSION})
#set_target_properties(${PROJLIB} PROPERTIES PUBLIC_HEADER ${LIBHEADER})
# Installation of the program
include(GNUInstallDirs)
install(TARGETS ${PROJ}
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
#install(TARGETS ${PROJ} DESTINATION "bin")
#install(TARGETS ${PROJLIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#install(TARGETS PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#install(FILES ${PCFILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.20)
set(EXTLIB lcdummy)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(PkgConfig REQUIRED)
pkg_check_modules(${EXTLIB} REQUIRED usefull_macros)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC)
include_directories(${${EXTLIB}_INCLUDE_DIRS} ..)
link_directories(${${EXTLIB}_LIBRARY_DIRS})
add_library(${EXTLIB} SHARED ${SRC})
target_link_libraries(${EXTLIB} ${${EXTLIB}_LIBRARIES} -fPIC)
install(TARGETS ${EXTLIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

28
Dummy_loccorr/main.c Normal file
View File

@ -0,0 +1,28 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "corrdevice.h"
#include <stdio.h>
void test(){
printf("Dummy local corrector tested\n");
}
__attribute__ ((visibility("default"))) corrdev_t device = {
.testdevice = test,
};

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.20)
set(EXTLIB teldummy)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(PkgConfig REQUIRED)
pkg_check_modules(${EXTLIB} REQUIRED usefull_macros)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC)
include_directories(${${EXTLIB}_INCLUDE_DIRS} ..)
link_directories(${${EXTLIB}_LIBRARY_DIRS})
add_library(${EXTLIB} SHARED ${SRC})
target_link_libraries(${EXTLIB} ${${EXTLIB}_LIBRARIES} -fPIC)
install(TARGETS ${EXTLIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

28
Dummy_telescope/main.c Normal file
View File

@ -0,0 +1,28 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "corrdevice.h"
#include <stdio.h>
void test(){
printf("Dummy telescope tested\n");
}
__attribute__ ((visibility("default"))) corrdev_t device = {
.testdevice = test,
};

99
cmdlnopts.c Normal file
View File

@ -0,0 +1,99 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <usefull_macros.h>
#include "cmdlnopts.h"
static int help;
// DEFAULTS
// default global parameters
glob_pars Glob_pars = {
.captkey = -1,
};
// need this to proper work with only-long args
//#define NA (-__COUNTER__)
// TODO: fix the bug in usefull_macros first!!!
#define NA (0)
/*
* Define command line options by filling structure:
* name has_arg flag val type argptr help
*/
myoption cmdlnopts[] = {
{"lcplugin",NEED_ARG, NULL, 'L', arg_string, APTR(&Glob_pars.lcplugin), "local corrector plugin (e.g liblcesprif.so)"},
{"telplugin", NEED_ARG, NULL, 'T', arg_string, APTR(&Glob_pars.telplugin), "telescope plugin (e.g. libbtaacs.so)"},
{"help", NO_ARGS, NULL, 'h', arg_int, APTR(&help), "show this help"},
{"verbose", NO_ARGS, NULL, 'V', arg_none, APTR(&Glob_pars.verbose), "verbose level (-V - messages, -VV - debug, -VVV - all shit)"},
{"logfile", NEED_ARG, NULL, 'l', arg_string, APTR(&Glob_pars.logfile), "logging file name (if run as server)"},
{"fitshead",NEED_ARG, NULL, 'H', arg_string, APTR(&Glob_pars.lcheader), "output FITS header with loccorr information"},
{"path", NEED_ARG, NULL, NA, arg_string, APTR(&Glob_pars.path), "UNIX socket name (command socket)"},
{"port", NEED_ARG, NULL, 'p', arg_string, APTR(&Glob_pars.port), "INET command socket port (can't be both UNIX and INET)"},
{"imageport",NEED_ARG, NULL, NA, arg_string, APTR(&Glob_pars.jpegport), "INET JPEG socket port"},
{"outfile", NEED_ARG, NULL, 'o', arg_string, APTR(&Glob_pars.jpegfile), "output JPEG image file name"},
{"shmkey", NEED_ARG, NULL, 'k', arg_int, APTR(&Glob_pars.captkey), "image SHM key of capture process"},
{"cport", NEED_ARG, NULL, NA, arg_string, APTR(&Glob_pars.captcmdport),"INET command socket port of capture process"},
{"cpath", NEED_ARG, NULL, NA, arg_string, APTR(&Glob_pars.captpath), "UNIX command socket path or address of image capture server"},
{"ciport", NEED_ARG, NULL, NA, arg_string, APTR(&Glob_pars.captimport),"INET image socket port of capture process"},
{"unix", NO_ARGS, NULL, 'U', arg_int, APTR(&Glob_pars.cisun), "capture command channel is UNIX socket"},
//{"", NEED_ARG, NULL, '', arg_double, APTR(&Glob_pars.), N_("")},
end_option
};
/**
* Parse command line options and return dynamically allocated structure
* to global parameters
* @param argc - copy of argc from main
* @param argv - copy of argv from main
* @return allocated structure with global parameters
*/
void parse_args(int argc, char **argv){
// format of help: "Usage: progname [args]\n"
change_helpstring("Version: " PACKAGE_VERSION "\nTo restart server kill it with SIGUSR1\n\nUsage: %s [args]\n\twhere args are:\n");
// parse arguments
parseargs(&argc, &argv, cmdlnopts);
if(help) showhelp(-1, cmdlnopts);
DBG("argc=%d", argc);
if(argc > 0){
WARNX("%d unused parameter[s]:", argc);
for(int i = 0; i < argc; ++i)
fprintf(stderr, "%4d: %s\n", i, argv[i]);
WARNX("Fix command line and run again");
exit(-1);
}
}
/**
* @brief verbose - print additional messages depending of Glob_pars.verbose
* @param levl - message level
* @param fmt - message
*/
void verbose(int levl, const char *fmt, ...){
va_list ar;
if(levl > Glob_pars.verbose) return;
//printf("%s: ", __progname);
va_start(ar, fmt);
vprintf(fmt, ar);
va_end(ar);
printf("\n");
}

46
cmdlnopts.h Normal file
View File

@ -0,0 +1,46 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <usefull_macros.h>
/*
* here are some typedef's for global data
*/
typedef struct{
char *lcplugin; // local corrector plugin
char *telplugin; // telescope plugin
char *logfile; // when run as server log here
char *path; // UNIX socket name
char *port; // INET socket port
char *jpegport; // port to send/receive jpeg images (by default == port+1)
char *jpegfile; // output file name
char *lcheader; // output FITS header with loccorr information
char *captcmdport; // INET command socket port of capture process
char *captpath; // UNIX command socket path of capture process or image capture server address
char *captimport; // INET image socket port of capture process
int cisun; // capture command channel is UNIX socket
int captkey; // image SHM key of capture process
int verbose; // each '-V' increases it
} glob_pars;
extern glob_pars Glob_pars;
void parse_args(int argc, char **argv);
void verbose(int levl, const char *fmt, ...);

23
corrdevice.h Normal file
View File

@ -0,0 +1,23 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
typedef struct{
void (*testdevice);
} corrdev_t;

1
loccorr.cflags Normal file
View File

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

6
loccorr.config Normal file
View File

@ -0,0 +1,6 @@
#define EBUG
#define OMP_FOUND
#define _GNU_SOURCE
#define _XOPEN_SOURCE 666
#define _DEFAULT_SOURCE
#define PACKAGE_VERSION "xxx"

1
loccorr.creator Normal file
View File

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

186
loccorr.creator.user Normal file
View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 12.0.1, 2024-03-20T17:32:36. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{cf63021e-ef53-49b0-b03b-2f2570cdf3b6}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">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">qt2</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="qlonglong" 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="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</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="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</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="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">4</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<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="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eddy/Docs/SAO/Image_processing/Prefocal_corrector(local_corrector)/code/mk</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="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" 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="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" 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.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" 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>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/home/eddy/Docs/SAO/Image_processing/Prefocal_corrector(local_corrector)/code/mk/loccorr</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
<value type="QString" key="RunConfiguration.Arguments">-p 12345</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseTerminal">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">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
loccorr.cxxflags Normal file
View File

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

10
loccorr.files Normal file
View File

@ -0,0 +1,10 @@
CMakeLists.txt
Dummy_loccorr/CMakeLists.txt
Dummy_loccorr/main.c
Dummy_telescope/CMakeLists.txt
Dummy_telescope/main.c
cmdlnopts.c
cmdlnopts.h
corrdevice.h
loccorrbase.h
main.c

1
loccorr.includes Normal file
View File

@ -0,0 +1 @@
.

23
loccorrbase.h Normal file
View File

@ -0,0 +1,23 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// max & min TCP socket port number
#define LC_PORTN_MAX (65535)
#define LC_PORTN_MIN (1024)

128
main.c Normal file
View File

@ -0,0 +1,128 @@
/*
* This file is part of the loccorr project.
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <signal.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <usefull_macros.h>
#include "cmdlnopts.h"
#include "loccorrbase.h"
static pid_t childpid = 0;
void signals(int signo){
DBG("signo=%d", signo);
if(childpid){ // master process
if(signo == SIGUSR1){ // kill child
kill(childpid, signo);
signal(signo, signals);
return;
}
WARNX("Master killed with sig=%d", signo);
LOGERR("Master killed with sig=%d", signo);
exit(signo);
}
// slave: make proper suicide
if(signo){
WARNX("Get signal %d - exit", signo);
LOGWARN("Get signal %d - exit", signo);
}
// do something here
DBG("exit(%d)", signo);
exit(signo);
}
// check unix/net socket
static int chk(char *port, int path, const char *what){
if(port){
if(path){
WARNX("Options `port` and UNIX-socket `path` can't be used together!");
return 1;
}
int p = atoi(port);
if(p < LC_PORTN_MIN || p > LC_PORTN_MAX){
WARNX("Wrong port value: %d", p);
return 1;
}
}
if(!path && !port){
WARNX("Point port or path of %s", what);
return 1;
}
return 0;
}
int main(int argc, char **argv){
initial_setup();
parse_args(argc, argv);
int r = chk(Glob_pars.port, (Glob_pars.path != NULL), "current server");
if(r) return r;
r = chk(Glob_pars.captcmdport, (Glob_pars.captpath && Glob_pars.cisun), "image capture server (don't forget -U for UNIX-socket)");
if(r) return r;
if(Glob_pars.captkey == -1 && !Glob_pars.captimport){
WARNX("Point port or SHM key of image server");
return 2;
}
if(!Glob_pars.lcplugin && !Glob_pars.telplugin){
WARNX("Point local corrector and/or telesope plugin");
return 3;
}
if(Glob_pars.logfile){
int lvl = LOGLEVEL_WARN + Glob_pars.verbose;
DBG("level = %d", lvl);
if(lvl > LOGLEVEL_ANY) lvl = LOGLEVEL_ANY;
verbose(1, "Log file %s @ level %d\n", Glob_pars.logfile, lvl);
OPENLOG(Glob_pars.logfile, lvl, 1);
if(!globlog) WARNX("Can't create log file");
}
signal(SIGINT, signals);
signal(SIGQUIT, signals);
signal(SIGABRT, signals);
signal(SIGTERM, signals);
signal(SIGHUP, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGUSR1, signals); // restart server
LOGMSG("Started");
DBG("Started");
#ifndef EBUG
unsigned int pause = 5;
while(1){
childpid = fork();
if(childpid){ // master
double t0 = dtime();
LOGMSG("Created child with pid %d", childpid);
wait(NULL);
LOGERR("Child %d died", childpid);
if(dtime() - t0 < 1.) pause += 5;
else pause = 1;
if(pause > 900) pause = 900;
sleep(pause); // wait a little before respawn
}else{ // slave
prctl(PR_SET_PDEATHSIG, SIGTERM); // send SIGTERM to child when parent dies
break;
}
}
#endif
sleep(5);
return 0;
}