bool MICCD::UpdateCCDFrame(int x, int y, int w, int h) { /* Add the X and Y offsets */ long x_1 = x / PrimaryCCD.getBinX(); long y_1 = y / PrimaryCCD.getBinY(); long x_2 = x_1 + (w / PrimaryCCD.getBinX()); long y_2 = y_1 + (h / PrimaryCCD.getBinY()); if (x_2 > PrimaryCCD.getXRes()) { LOGF_ERROR("Error: Requested width out of bounds %ld", x_2); return false; } else if (y_2 > PrimaryCCD.getYRes()) { LOGF_ERROR("Error: Requested height out of bounds %ld", y_2); return false; } LOGF_DEBUG("The Final image area is (%ld, %ld), (%ld, %ld)\n", x_1, y_1, x_2, y_2); int imageWidth = x_2 - x_1; int imageHeight = y_2 - y_1; // Set UNBINNED coords PrimaryCCD.setFrame(x, y, w, h); PrimaryCCD.setFrameBufferSize(imageWidth * imageHeight * PrimaryCCD.getBPP() / 8); return true; }
// Send a command to the mount. Return the number of bytes received or 0 if // case of error // commands are null terminated, replies end with /n int QFW::send_command(int fd, const char* cmd, char *resp) { int err; int nbytes = 0; char errmsg[MAXRBUF]; int cmd_len = strlen(cmd); char dmp[255]; dump(dmp, cmd); LOGF_DEBUG("CMD <%s>", dmp); tcflush(fd, TCIOFLUSH); if ((err = tty_write(fd, cmd, cmd_len, &nbytes)) != TTY_OK) { tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial write error: %s", errmsg); return 0; } err = tty_read_section(fd, resp, '\n', QUANTUM_TIMEOUT, &nbytes); if (err) { tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial read error: %s", errmsg); return 0; } resp[nbytes] = 0; dump(dmp, resp); LOGF_DEBUG("RES <%s>", dmp); return nbytes; }
void MICCD::updateTemperature() { float ccdtemp = 0; float ccdpower = 0; int err = 0; if (isSimulation()) { ccdtemp = TemperatureN[0].value; if (TemperatureN[0].value < TemperatureRequest) ccdtemp += TEMP_THRESHOLD; else if (TemperatureN[0].value > TemperatureRequest) ccdtemp -= TEMP_THRESHOLD; ccdpower = 30; } else { if (gxccd_get_value(cameraHandle, GV_CHIP_TEMPERATURE, &ccdtemp) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Getting temperature failed: %s.", errorStr); err |= 1; } if (gxccd_get_value(cameraHandle, GV_POWER_UTILIZATION, &ccdpower) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Getting voltage failed: %s.", errorStr); err |= 2; } } TemperatureN[0].value = ccdtemp; CoolerN[0].value = ccdpower * 100.0; if (TemperatureNP.s == IPS_BUSY && fabs(TemperatureN[0].value - TemperatureRequest) <= TEMP_THRESHOLD) { // end of temperature ramp TemperatureN[0].value = TemperatureRequest; TemperatureNP.s = IPS_OK; } if (err) { if (err & 1) TemperatureNP.s = IPS_ALERT; if (err & 2) CoolerNP.s = IPS_ALERT; } else { CoolerNP.s = IPS_OK; } IDSetNumber(&TemperatureNP, nullptr); IDSetNumber(&CoolerNP, nullptr); temperatureID = IEAddTimer(POLLMS, MICCD::updateTemperatureHelper, this); }
bool ArmPlat::slpSendRxInt( char *command, int *rcode ) { int nbytes_wrrd = 0; int rc; char errstr[MAXRBUF]; char res[SLP_SEND_BUF_SIZE]={0}; LOGF_DEBUG("Tx [%s]", command); //tty_set_debug( 1 ); if ((rc = tty_write_string(PortFD, command, &nbytes_wrrd)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); //IDLog( "ERROR Tx: <%s>\n", errstr ); LOGF_ERROR("Send error: %s.", errstr); return false; } if ((rc = tty_read_section(PortFD, res, '#', ArmPlat_TIMEOUT, &nbytes_wrrd)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); //IDLog( "ERROR Rx: <%s> error msg <%s>\n", res, errstr ); LOGF_ERROR("Echo receiving error: %s.", errstr); return false; } LOGF_DEBUG("Rx [%s]", res); //if ( ( strstr( command, "getpos" ) == nullptr ) && ( strstr( command, "temps" ) == nullptr ) ) //IDLog( "Rx: <%s>\n", res ); return getIntResultCode( command, res, rcode ); }
IPState WeatherSafetyProxy::executeScript() { char *cmd = ScriptsT[WSP_SCRIPT].text; if (access(cmd, F_OK|X_OK) == -1) { LOGF_ERROR("Cannot use script [%s], check its existence and permissions", cmd); LastParseSuccess = false; return IPS_ALERT; } LOGF_DEBUG("Run script: %s", cmd); FILE *handle = popen(cmd, "r"); if (handle == nullptr) { LOGF_ERROR("Failed to run script [%s]", strerror(errno)); LastParseSuccess = false; return IPS_ALERT; } char buf[BUFSIZ]; size_t byte_count = fread(buf, 1, BUFSIZ - 1, handle); fclose(handle); buf[byte_count] = 0; if (byte_count == 0) { LOGF_ERROR("Got no output from script [%s]", cmd); LastParseSuccess = false; return IPS_ALERT; } LOGF_DEBUG("Read %d bytes output [%s]", byte_count, buf); return parseSafetyJSON(buf, byte_count); }
bool SynscanDriver::sendCommand(const char * cmd, char * res, int cmd_len, int res_len) { int nbytes_written = 0, nbytes_read = 0, rc = -1; tcflush(PortFD, TCIOFLUSH); if (cmd_len > 0) { char hex_cmd[SYN_RES * 3] = {0}; hexDump(hex_cmd, cmd, cmd_len); LOGF_DEBUG("CMD <%s>", hex_cmd); rc = tty_write(PortFD, cmd, cmd_len, &nbytes_written); } else { LOGF_DEBUG("CMD <%s>", cmd); rc = tty_write_string(PortFD, cmd, &nbytes_written); } if (rc != TTY_OK) { char errstr[MAXRBUF] = {0}; tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Serial write error: %s.", errstr); return false; } if (res == nullptr) return true; if (res_len > 0) rc = tty_read(PortFD, res, res_len, SYN_TIMEOUT, &nbytes_read); else rc = tty_nread_section(PortFD, res, SYN_RES, SYN_DEL, SYN_TIMEOUT, &nbytes_read); if (rc != TTY_OK) { char errstr[MAXRBUF] = {0}; tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Serial read error: %s.", errstr); return false; } if (res_len > 0) { char hex_res[SYN_RES * 3] = {0}; hexDump(hex_res, res, res_len); LOGF_DEBUG("RES <%s>", hex_res); } else { LOGF_DEBUG("RES <%s>", res); } tcflush(PortFD, TCIOFLUSH); return true; }
bool MoonLite::Ack() { int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[5]={0}; short pos = -1; tcflush(PortFD, TCIOFLUSH); //Try to request the position of the focuser //Test for success on transmission and response //If either one fails, try again, up to 3 times, waiting 1 sec each time //If that fails, then return false. int numChecks = 0; bool success = false; while(numChecks < 3 && !success) { numChecks++; sleep(1); //wait 1 second between each test. bool transmissionSuccess = (rc = tty_write(PortFD, ":GP#", 4, &nbytes_written)) == TTY_OK; if(!transmissionSuccess) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Handshake Attempt %i, tty transmission error: %s.", numChecks, errstr); } bool responseSuccess = (rc = tty_read(PortFD, resp, 5, MOONLITE_TIMEOUT, &nbytes_read)) == TTY_OK; if(!responseSuccess) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Handshake Attempt %i, updatePosition response error: %s.", numChecks, errstr); } success = transmissionSuccess && responseSuccess; } if(!success) { LOG_INFO("Handshake failed after 3 attempts"); return false; } tcflush(PortFD, TCIOFLUSH); rc = sscanf(resp, "%hX#", &pos); return rc > 0; }
bool MoonLiteDRO::updateStepDelay() { int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[3]={0}; char cmd[DRO_CMD]={0}; short speed; if (m_ID == 1) strncpy(cmd, ":GD#", DRO_CMD); else strncpy(cmd, ":2GD#", DRO_CMD); LOGF_DEBUG("CMD <%s>", cmd); tcflush(PortFD, TCIOFLUSH); if ((rc = tty_write_string(PortFD, cmd, &nbytes_written)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepDelay error: %s.", errstr); return false; } if ((rc = tty_read_section(PortFD, resp, '#', MOONLITEDRO_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepDelay error: %s.", errstr); return false; } tcflush(PortFD, TCIOFLUSH); LOGF_DEBUG("RES <%s>", resp); rc = sscanf(resp, "%hX", &speed); if (rc > 0) { int focus_speed = -1; while (speed > 0) { speed >>= 1; focus_speed++; } StepDelayN[0].value = focus_speed; }
bool TCFS::read_tcfs(char *response, bool silent) { int err_code = 0, nbytes_read = 0; char err_msg[TCFS_ERROR_BUFFER]; if (isSimulation()) { strncpy(response, "SIMULATION", TCFS_MAX_CMD); return true; } // Read until encountring a CR if ((err_code = tty_read_section(PortFD, response, 0x0D, 2, &nbytes_read)) != TTY_OK) { if (!silent) { tty_error_msg(err_code, err_msg, 32); LOGF_ERROR("TTY error detected: %s", err_msg); } return false; } // Remove LF & CR response[nbytes_read - 2] = '\0'; LOGF_DEBUG("RES <%s>", response); return true; }
bool FlipFlat::getBrightness() { if (isSimulation()) { return true; } char response[FLAT_RES]={0}; if (!sendCommand(">J000", response)) return false; char brightnessString[4] = { 0 }; snprintf(brightnessString, 4, "%s", response + 4); int brightnessValue = 0; int rc = sscanf(brightnessString, "%d", &brightnessValue); if (rc <= 0) { LOGF_ERROR("Unable to parse brightness value (%s)", response); return false; } if (brightnessValue != prevBrightness) { prevBrightness = brightnessValue; LightIntensityN[0].value = brightnessValue; IDSetNumber(&LightIntensityNP, nullptr); } return true; }
bool FlipFlat::ping() { char response[FLAT_RES]={0}; if (!sendCommand(">P000", response)) return false; char productString[3] = { 0 }; snprintf(productString, 3, "%s", response + 2); int rc = sscanf(productString, "%d", &productID); if (rc <= 0) { LOGF_ERROR("Unable to parse input (%s)", response); return false; } if (productID == 99) { setDriverInterface(AUX_INTERFACE | LIGHTBOX_INTERFACE | DUSTCAP_INTERFACE); isFlipFlat = true; } else isFlipFlat = false; return true; }
bool ASIEAF::ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n) { if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { // Turn on/off beep if (!strcmp(name, BeepSP.name)) { EAF_ERROR_CODE rc = EAF_SUCCESS; if (!strcmp(BeepS[BEEP_ON].name, IUFindOnSwitchName(states, names, n))) rc = EAFSetBeep(m_ID, true); else rc = EAFSetBeep(m_ID, false); if (rc == EAF_SUCCESS) { IUUpdateSwitch(&BeepSP, states, names, n); BeepSP.s = IPS_OK; } else { BeepSP.s = IPS_ALERT; LOGF_ERROR("Failed to set beep state. Error: %d", rc); } IDSetSwitch(&BeepSP, nullptr); return true; } } return INDI::Focuser::ISNewSwitch(dev, name, states, names, n); }
IPState WeatherSafetyProxy::executeCurl() { CURL *curl_handle; CURLcode res; std::string readBuffer; curl_handle = curl_easy_init(); if (curl_handle) { curl_easy_setopt(curl_handle, CURLOPT_URL, UrlT[WSP_URL].text); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WSP_WriteCallback); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &readBuffer); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); LOGF_DEBUG("Call curl %s", UrlT[WSP_URL].text); res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { LOGF_ERROR("curl_easy_perform failed with [%s]", curl_easy_strerror(res)); return IPS_ALERT; } curl_easy_cleanup(curl_handle); LOGF_DEBUG("Read %d bytes output [%s]", readBuffer.size(), readBuffer.c_str()); return parseSafetyJSON(readBuffer.c_str(), readBuffer.size()); } else { LOG_ERROR("curl_easy_init failed"); return IPS_ALERT; } }
/************************************************************************************ * * ***********************************************************************************/ IPState ScopeDome::sendMove(double azDiff) { int rc; if (azDiff < 0) { uint16_t steps = (uint16_t)(-azDiff * stepsPerTurn / 360.0); LOGF_DEBUG("CCW (%d)", steps); steps = compensateInertia(steps); LOGF_DEBUG("CCW inertia (%d)", steps); if (steps == 0) return IPS_OK; rc = writeU16(CCWRotation, steps); } else { uint16_t steps = (uint16_t)(azDiff * stepsPerTurn / 360.0); LOGF_DEBUG("CW (%d)", steps); steps = compensateInertia(steps); LOGF_DEBUG("CW inertia (%d)", steps); if (steps == 0) return IPS_OK; rc = writeU16(CWRotation, steps); } if (rc != 0) { LOGF_ERROR("Error moving dome: %d", rc); } return IPS_BUSY; }
bool ArmPlat::setMaxSpeed(uint16_t nspeed) { speed = nspeed; // saved for later, and for possible change of port if ( port == -1 ) return false; int rc; char cmd[SLP_SEND_BUF_SIZE]={0}; rc = (int)(500000-((nspeed-1)*50)); if ( ( rc < 50 ) || ( rc > 500000 ) ) { LOGF_ERROR("Wrong speed %d", nspeed ); return false; } sprintf(cmd, "!step speedrangeus %d %d %d#", port, rc, rc ); if ( slpSendRxInt( cmd, &rc ) ) { if ( rc == 0 ) return true; } return false; }
bool RHI_CommandList::Submit() { // Ensure the command list has stopped recording if (m_is_recording) return false; // Fixes "Error: Vulkan: Queue 0x1f1c2542ee0 is waiting on semaphore 0x3e that has no way to be signaled." //vulkan_helper::fence::wait_reset(m_rhi_device, m_swap_chain->GetFenceImageAcquired()); m_current_frame = (m_current_frame + 1) % g_max_frames_in_flight; vector<VkSemaphore> wait_semaphores = { static_cast<VkSemaphore>(m_swap_chain->GetSemaphoreImageAcquired()) }; vector<VkSemaphore> signal_semaphores = { static_cast<VkSemaphore>(m_semaphores_render_finished[m_current_frame]) }; VkPipelineStageFlags wait_flags[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT }; VkSubmitInfo submit_info = {}; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submit_info.waitSemaphoreCount = static_cast<uint32_t>(wait_semaphores.size()); submit_info.pWaitSemaphores = wait_semaphores.data(); submit_info.pWaitDstStageMask = wait_flags; submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &CMD_BUFFER_VK; submit_info.signalSemaphoreCount = static_cast<uint32_t>(signal_semaphores.size()); submit_info.pSignalSemaphores = signal_semaphores.data(); auto result = vkQueueSubmit(m_rhi_device->GetContext()->queue_graphics, 1, &submit_info, IN_FLIGHT_FENCE_VK); if (result != VK_SUCCESS) { LOGF_ERROR("Failed to submit command buffer, %s.", Vulkan_Common::result_to_string(result)); } m_is_rendering = true; return result == VK_SUCCESS; }
RHI_RasterizerState::RHI_RasterizerState ( const shared_ptr<RHI_Device>& rhi_device, const RHI_Cull_Mode cull_mode, const RHI_Fill_Mode fill_mode, const bool depth_clip_enabled, const bool scissor_enabled, const bool multi_sample_enabled, const bool antialised_line_enabled) { if (!rhi_device) { LOG_ERROR_INVALID_INTERNALS(); return; } if (!rhi_device->GetContext()->device) { LOG_ERROR_INVALID_INTERNALS(); return; } // Save properties m_cull_mode = cull_mode; m_fill_mode = fill_mode; m_depth_clip_enabled = depth_clip_enabled; m_scissor_enabled = scissor_enabled; m_multi_sample_enabled = multi_sample_enabled; m_antialised_line_enabled = antialised_line_enabled; // Create rasterizer description D3D11_RASTERIZER_DESC desc; desc.CullMode = d3d11_cull_mode[cull_mode]; desc.FillMode = d3d11_polygon_mode[fill_mode]; desc.FrontCounterClockwise = false; desc.DepthBias = 0; desc.DepthBiasClamp = 0.0f; desc.SlopeScaledDepthBias = 0.0f; desc.DepthClipEnable = depth_clip_enabled; desc.MultisampleEnable = multi_sample_enabled; desc.AntialiasedLineEnable = antialised_line_enabled; desc.ScissorEnable = scissor_enabled; // Create rasterizer state auto rasterizer_state = static_cast<ID3D11RasterizerState*>(m_buffer); const auto result = rhi_device->GetContext()->device->CreateRasterizerState(&desc, &rasterizer_state); // Handle result if (SUCCEEDED(result)) { m_buffer = static_cast<void*>(rasterizer_state); m_initialized = true; } else { LOGF_ERROR("Failed to create the rasterizer state, %s.", D3D11_Common::dxgi_error_to_string(result)); m_initialized = false; } }
bool MICCD::Connect() { uint32_t cap = 0; if (isSimulation()) { LOGF_INFO("Connected to %s", name); cap = CCD_CAN_SUBFRAME | CCD_CAN_ABORT | CCD_CAN_BIN | CCD_HAS_SHUTTER | CCD_HAS_COOLER; SetCCDCapability(cap); numFilters = 5; return true; } if (!cameraHandle) { if (isEth) cameraHandle = gxccd_initialize_eth(cameraId); else cameraHandle = gxccd_initialize_usb(cameraId); } if (!cameraHandle) { LOGF_ERROR("Error connecting to %s.", name); return false; } LOGF_INFO("Connected to %s.", name); bool value; cap = CCD_CAN_ABORT | CCD_CAN_BIN; gxccd_get_boolean_parameter(cameraHandle, GBP_SUB_FRAME, &value); if (value) cap |= CCD_CAN_SUBFRAME; gxccd_get_boolean_parameter(cameraHandle, GBP_GUIDE, &value); if (value) cap |= CCD_HAS_ST4_PORT; gxccd_get_boolean_parameter(cameraHandle, GBP_SHUTTER, &value); if (value) cap |= CCD_HAS_SHUTTER; gxccd_get_boolean_parameter(cameraHandle, GBP_COOLER, &value); if (value) cap |= CCD_HAS_COOLER; gxccd_get_boolean_parameter(cameraHandle, GBP_GAIN, &hasGain); gxccd_get_boolean_parameter(cameraHandle, GBP_PREFLASH, &canDoPreflash); SetCCDCapability(cap); return true; }
bool MICCD::UpdateCCDBin(int hor, int ver) { if (hor < 1 || hor > maxBinX || ver < 1 || ver > maxBinY) { LOGF_ERROR("Binning (%dx%d) are out of range. Range from 1x1 to (%dx%d)", maxBinX, maxBinY); return false; } if (gxccd_set_binning(cameraHandle, hor, ver) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Setting binning failed: %s.", errorStr); return false; } PrimaryCCD.setBin(hor, ver); return UpdateCCDFrame(PrimaryCCD.getSubX(), PrimaryCCD.getSubY(), PrimaryCCD.getSubW(), PrimaryCCD.getSubH()); }
IPState DomeScript::ControlShutter(ShutterOperation operation) { if (RunScript(operation == SHUTTER_OPEN ? SCRIPT_OPEN : SCRIPT_CLOSE, nullptr)) { return IPS_BUSY; } LOGF_ERROR("Failed to %s shutter", operation == SHUTTER_OPEN ? "open" : "close"); return IPS_ALERT; }
bool QHYCFW2::SelectFilter(int f) { TargetFilter = f; char cmd[8] = {0}, res[8]={0}; int rc = -1, nbytes_written=0, nbytes_read=0; LOGF_DEBUG("CMD <%d>", TargetFilter-1); snprintf(cmd, 2, "%d", TargetFilter-1); if (isSimulation()) snprintf(res, 8, "%d", TargetFilter-1); else { if ((rc = tty_write_string(PortFD, cmd, &nbytes_written)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Sending command select filter failed: %s", error_message); return false; } if ((rc = tty_read(PortFD, res, 1, 30, &nbytes_read)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Reading select filter response failed: %s", error_message); return false; } LOGF_DEBUG("RES <%s>", res); } if (atoi(res)+1 == TargetFilter) { CurrentFilter = TargetFilter; SelectFilterDone(CurrentFilter); return true; } return false; }
bool MoonLite::updateTemperature() { int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[16]={0}; tcflush(PortFD, TCIOFLUSH); tty_write(PortFD, ":C#", 3, &nbytes_written); if ((rc = tty_write(PortFD, ":GT#", 4, &nbytes_written)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateTemperature error: %s.", errstr); return false; } if ((rc = tty_read_section(PortFD, resp, '#', MOONLITE_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateTemperature error: %s.", errstr); return false; } tcflush(PortFD, TCIOFLUSH); resp[nbytes_read-1] = '\0'; uint32_t temp = 0; rc = sscanf(resp, "%X", &temp); if (rc > 0) { // Signed hex TemperatureN[0].value = static_cast<int16_t>(temp) / 2.0; } else { LOGF_ERROR("Unknown error: focuser temperature value (%s)", resp); return false; } return true; }
bool ATIKCCD::StartExposure(float duration) { PrimaryCCD.setExposureDuration(duration); ExposureRequest = duration; // Camera needs to be in idle state to start exposure after previous abort int maxWaitCount = 1000; // 1000 * 0.1s = 100s while (ArtemisCameraState(hCam) != CAMERA_IDLE && --maxWaitCount > 0) { LOG_DEBUG("Waiting camera to be idle..."); usleep(100000); } if (maxWaitCount == 0) { LOG_ERROR("Camera not in idle state, can't start exposure"); return false; } LOGF_DEBUG("Start Exposure : %.3fs", duration); // if (m_CameraFlags & ARTEMIS_PROPERTIES_CAMERAFLAGS_HAS_SHUTTER) // { // if (PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME || // PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME) // { // ArtemisCloseShutter(hCam); // } // else // { // ArtemisOpenShutter(hCam); // } // } ArtemisSetDarkMode(hCam, PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME || PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME); int rc = ArtemisStartExposure(hCam, duration); if (rc != ARTEMIS_OK) { LOGF_ERROR("Failed to start exposure (%d).", rc); return false; } gettimeofday(&ExpStart, nullptr); if (ExposureRequest > VERBOSE_EXPOSURE) LOGF_INFO("Taking a %g seconds frame...", ExposureRequest); InExposure = true; pthread_mutex_lock(&condMutex); threadRequest = StateExposure; pthread_cond_signal(&cv); pthread_mutex_unlock(&condMutex); return true; }
bool ASIEAF::SetFocuserMaxPosition(uint32_t ticks) { EAF_ERROR_CODE rc = EAFSetMaxStep(m_ID, ticks); if (rc != EAF_SUCCESS) { LOGF_ERROR("Failed to set max step. Error: %d", rc); return false; } return true; }
bool ASIEAF::SyncFocuser(uint32_t ticks) { EAF_ERROR_CODE rc = EAFResetPostion(m_ID, ticks); if (rc != EAF_SUCCESS) { LOGF_ERROR("Failed to sync focuser. Error: %d", rc); return false; } return true; }
bool ASIEAF::gotoAbsolute(uint32_t position) { EAF_ERROR_CODE rc = EAFMove(m_ID, position); if (rc != EAF_SUCCESS) { LOGF_ERROR("Failed to set position. Error: %d", rc); return false; } return true; }
bool ASIEAF::AbortFocuser() { EAF_ERROR_CODE rc = EAFStop(m_ID); if (rc != EAF_SUCCESS) { LOGF_ERROR("Failed to stop focuser. Error: %d", rc); return false; } return true; }
void WatchDog::executeScript() { // child if (fork() == 0) { int rc = execlp(SettingsT[EXECUTE_SCRIPT].text, SettingsT[EXECUTE_SCRIPT].text, nullptr); if (rc) exit(rc); } // parent else { int statval; LOGF_INFO("Executing script %s...", SettingsT[EXECUTE_SCRIPT].text); LOGF_INFO("Waiting for script with PID %d to complete...", getpid()); wait(&statval); if (WIFEXITED(statval)) { int exit_code = WEXITSTATUS(statval); LOGF_INFO("Script complete with exit code %d", exit_code); if (exit_code == 0) shutdownStage = WATCHDOG_COMPLETE; else { LOGF_ERROR("Error: script %s failed. Shutdown procedure terminated.", SettingsT[EXECUTE_SCRIPT].text); shutdownStage = WATCHDOG_ERROR; return; } } else { LOGF_ERROR( "Error: script %s did not terminate with exit. Shutdown procedure terminated.", SettingsT[EXECUTE_SCRIPT].text); shutdownStage = WATCHDOG_ERROR; return; } } }
bool ASIEAF::isMoving() { bool moving = false; EAF_ERROR_CODE rc = EAFIsMoving(m_ID, &moving); if (rc != EAF_SUCCESS) { LOGF_ERROR("Failed to read motion status. Error: %d", rc); return false; } return moving; }
IPState MICCD::GuideWest(uint32_t ms) { if (gxccd_move_telescope(cameraHandle, static_cast<int16_t>(ms), 0) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("GuideWest() failed: %s.", errorStr); return IPS_ALERT; } return IPS_OK; }