Skip to content

Commit

Permalink
All the CCD drivers now lock the mutex for async upload
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Jan 23, 2019
1 parent d4e9258 commit 7ca4016
Show file tree
Hide file tree
Showing 23 changed files with 1,311 additions and 1,128 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/indi-altaircam/CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@ find_package(ALTAIRCAM REQUIRED)

# Using Altair Library
set(ALTAIRCAM_VERSION_MAJOR 0)
set(ALTAIRCAM_VERSION_MINOR 1)
set(ALTAIRCAM_VERSION_MINOR 2)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/indi_altaircam.xml.cmake ${CMAKE_CURRENT_BINARY_DIR}/indi_altaircam.xml)
Expand Down
493 changes: 251 additions & 242 deletions 3rdparty/indi-altaircam/indi_altair.cpp

Large diffs are not rendered by default.

104 changes: 55 additions & 49 deletions 3rdparty/indi-apogee/apogee_ccd.cpp
@@ -1,21 +1,25 @@
#if 0
Apogee CCD
INDI Driver for Apogee CCDs and Filter Wheels
Copyright (C) 2014 Jasem Mutlaq <mutlaqja AT ikarustech DOT com>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Apogee CCD
INDI Driver for Apogee CCDs and Filter Wheels
Copyright (C) 2014 Jasem Mutlaq <mutlaqja AT ikarustech DOT com>

This library is free software;
you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
either
version 2.1 of the License, or (at your option) any later version.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library;
if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA

#endif

Expand All @@ -41,12 +45,12 @@
#include <memory>

#ifdef OSX_EMBEDED_MODE
#include "Alta.h"
#include "AltaF.h"
#include "Ascent.h"
#include "Aspen.h"
#include "Quad.h"
#include "ApgLogger.h"
#include "Alta.h"
#include "AltaF.h"
#include "Ascent.h"
#include "Aspen.h"
#include "Quad.h"
#include "ApgLogger.h"
#else
#include <libapogee/Alta.h>
#include <libapogee/AltaF.h>
Expand Down Expand Up @@ -287,7 +291,7 @@ bool ApogeeCCD::getCameraParams()

IDSetSwitch(&CoolerSP, nullptr);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("getCameraParams failed. %s.", err.what());
return false;
Expand All @@ -303,7 +307,7 @@ bool ApogeeCCD::getCameraParams()
{
fStatus = ApgCam->GetFanMode();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("GetFanMode failed. %s.", err.what());
return false;
Expand Down Expand Up @@ -338,7 +342,7 @@ bool ApogeeCCD::getCameraParams()
{
minDuration = ApgCam->GetMinExposureTime();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("get_MinExposureTime() failed. %s.", err.what());
return false;
Expand All @@ -365,7 +369,7 @@ int ApogeeCCD::SetTemperature(double temperature)
if (isSimulation() == false)
ApgCam->SetCoolerSetPoint(temperature);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("SetCoolerSetPoint failed. %s.", err.what());
return -1;
Expand Down Expand Up @@ -404,7 +408,7 @@ bool ApogeeCCD::ISNewSwitch(const char *dev, const char *name, ISState *states,
if (isSimulation() == false)
ApgCam->SetCcdAdcSpeed(Apg::AdcSpeed_Normal);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
IUResetSwitch(&ReadOutSP);
ReadOutSP.s = IPS_ALERT;
Expand All @@ -420,7 +424,7 @@ bool ApogeeCCD::ISNewSwitch(const char *dev, const char *name, ISState *states,
if (isSimulation() == false)
ApgCam->SetCcdAdcSpeed(Apg::AdcSpeed_Fast);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
IUResetSwitch(&ReadOutSP);
ReadOutSP.s = IPS_ALERT;
Expand Down Expand Up @@ -539,7 +543,7 @@ bool ApogeeCCD::StartExposure(float duration)
PrimaryCCD.setExposureDuration(ExposureRequest);
}
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("StartExposure() failed. %s.", err.what());
return false;
Expand All @@ -555,7 +559,7 @@ bool ApogeeCCD::StartExposure(float duration)
PrimaryCCD.setExposureDuration(ExposureRequest);
}
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("StartExposure() failed. %s.", err.what());
return false;
Expand All @@ -576,7 +580,7 @@ bool ApogeeCCD::AbortExposure()
if (isSimulation() == false)
ApgCam->StopExposure(false);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("AbortExposure() failed. %s.", err.what());
return false;
Expand Down Expand Up @@ -641,7 +645,7 @@ bool ApogeeCCD::UpdateCCDFrame(int x, int y, int w, int h)
ApgCam->SetRoiNumRows(imageHeight);
}
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("Setting image area failed. %s.", err.what());
return false;
Expand Down Expand Up @@ -670,7 +674,7 @@ bool ApogeeCCD::UpdateCCDBin(int binx, int biny)
if (isSimulation() == false)
ApgCam->SetRoiBinCol(binx);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("SetRoiBinCol failed. %s.", err.what());
return false;
Expand All @@ -681,7 +685,7 @@ bool ApogeeCCD::UpdateCCDBin(int binx, int biny)
if (isSimulation() == false)
ApgCam->SetRoiBinRow(biny);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("SetRoiBinRow failed. %s.", err.what());
return false;
Expand All @@ -697,10 +701,11 @@ bool ApogeeCCD::UpdateCCDBin(int binx, int biny)
int ApogeeCCD::grabImage()
{
std::vector<uint16_t> pImageData;
unsigned short *image = (unsigned short *)PrimaryCCD.getFrameBuffer();
uint16_t *image = reinterpret_cast<uint16_t*>(PrimaryCCD.getFrameBuffer());

try
{
std::unique_lock<std::mutex> guard(ccdBufferLock);
if (isSimulation())
{
for (int i = 0; i < imageHeight; i++)
Expand All @@ -714,8 +719,9 @@ int ApogeeCCD::grabImage()
imageHeight = ApgCam->GetRoiNumRows();
copy(pImageData.begin(), pImageData.end(), image);
}
guard.unlock();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("GetImage failed. %s.", err.what());
return -1;
Expand Down Expand Up @@ -913,8 +919,8 @@ bool ApogeeCCD::Connect()
if (isSimulation())
{
msg = std::string("<d>address=0,interface=usb,deviceType=camera,id=0x49,firmwareRev=0x21,model=AltaU-"
"4020ML,interfaceStatus=NA</d><d>address=1,interface=usb,model=Filter "
"Wheel,deviceType=filterWheel,id=0xFFFF,firmwareRev=0xFFEE</d>");
"4020ML,interfaceStatus=NA</d><d>address=1,interface=usb,model=Filter "
"Wheel,deviceType=filterWheel,id=0xFFFF,firmwareRev=0xFFEE</d>");
addr = GetUsbAddress(msg);
}
else
Expand All @@ -926,7 +932,7 @@ bool ApogeeCCD::Connect()
msg = lookUsb.Find();
addr = GetUsbAddress(msg);
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("Error getting USB address: %s", err.what());
return false;
Expand Down Expand Up @@ -958,7 +964,7 @@ bool ApogeeCCD::Connect()
msg = look4cam.Find(subnet);
LOGF_DEBUG("Network search result: %s", msg.c_str());
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("Error getting network address: %s", err.what());
return false;
Expand Down Expand Up @@ -1042,7 +1048,7 @@ bool ApogeeCCD::Connect()

default:
LOGF_ERROR("Model %s is not supported by the INDI Apogee driver.",
GetItemFromFindStr(msg, "model=").c_str());
GetItemFromFindStr(msg, "model=").c_str());
return false;
break;
}
Expand All @@ -1055,7 +1061,7 @@ bool ApogeeCCD::Connect()
ApgCam->Init();
}
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("Error opening camera: %s", err.what());
return false;
Expand All @@ -1076,7 +1082,7 @@ bool ApogeeCCD::Disconnect()
if (isSimulation() == false)
ApgCam->CloseConnection();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
LOGF_ERROR("Error: CloseConnection failed. %s.", err.what());
return false;
Expand All @@ -1103,7 +1109,7 @@ void ApogeeCCD::activateCooler(bool enable)
coolerSet = true;
}
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
CoolerSP.s = IPS_ALERT;
CoolerS[0].s = ISS_OFF;
Expand Down Expand Up @@ -1174,7 +1180,7 @@ void ApogeeCCD::TimerHit()
else
ccdTemp = ApgCam->GetTempCcd();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
TemperatureNP.s = IPS_IDLE;
LOGF_ERROR("GetTempCcd failed. %s.", err.what());
Expand All @@ -1198,7 +1204,7 @@ void ApogeeCCD::TimerHit()
else
ccdTemp = ApgCam->GetTempCcd();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
TemperatureNP.s = IPS_ALERT;
LOGF_ERROR("GetTempCcd failed. %s.", err.what());
Expand Down Expand Up @@ -1229,7 +1235,7 @@ void ApogeeCCD::TimerHit()
else
coolerPower = ApgCam->GetCoolerDrive();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
CoolerNP.s = IPS_IDLE;
LOGF_ERROR("GetCoolerDrive failed. %s.", err.what());
Expand Down Expand Up @@ -1257,7 +1263,7 @@ void ApogeeCCD::TimerHit()
else
coolerPower = ApgCam->GetCoolerDrive();
}
catch (std::runtime_error& err)
catch (std::runtime_error &err)
{
CoolerNP.s = IPS_ALERT;
LOGF_ERROR("GetCoolerDrive failed. %s.", err.what());
Expand Down
17 changes: 14 additions & 3 deletions 3rdparty/indi-asi/CMakeLists.txt
Expand Up @@ -15,8 +15,8 @@ find_package(Threads REQUIRED)
# Using ASI EFW SDK Version 0.3.1205 updated on 2017-12-05
# Using ASI ST4 SDK Version 1.0 updated on 2018-07-23
# Using ASI EAF SDK Version 0.0.1128 updated on 2019-01-21
set(ASI_VERSION_MAJOR 0)
set(ASI_VERSION_MINOR 9)
set(ASI_VERSION_MAJOR 1)
set(ASI_VERSION_MINOR 0)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/indi_asi.xml.cmake ${CMAKE_CURRENT_BINARY_DIR}/indi_asi.xml)
Expand All @@ -28,6 +28,14 @@ include_directories( ${CFITSIO_INCLUDE_DIR})

include(CMakeCommon)

if (INDI_WEBSOCKET)
find_package(websocketpp REQUIRED)
find_package(Boost COMPONENTS system thread)
include_directories (${Boost_INCLUDE_DIRS})
add_definitions(-DHAVE_WEBSOCKET)
SET(HAVE_WEBSOCKET 1)
endif()

if (APPLE)
set(ASICAMLIB ${CMAKE_CURRENT_SOURCE_DIR}/mac/libASICamera2.bin)
set(ASIFWLIB ${CMAKE_CURRENT_SOURCE_DIR}/mac/libEFWFilter.bin)
Expand Down Expand Up @@ -68,8 +76,11 @@ set(indi_asi_SRCS
)

add_executable(indi_asi_ccd ${indi_asi_SRCS})

target_link_libraries(indi_asi_ccd ${INDI_LIBRARIES} ${CFITSIO_LIBRARIES} ${ASICAMLIB} ${USB1_LIBRARIES} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
if (HAVE_WEBSOCKET)
target_link_libraries(indi_asi_ccd ${Boost_LIBRARIES})
endif()



########### indi_asi_wheel ###########
Expand Down

0 comments on commit 7ca4016

Please sign in to comment.