本文整理汇总了C++中IDSetSwitch函数的典型用法代码示例。如果您正苦于以下问题:C++ IDSetSwitch函数的具体用法?C++ IDSetSwitch怎么用?C++ IDSetSwitch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IDSetSwitch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IDSetNumber
/************************************************************************************
*
* ***********************************************************************************/
bool BaaderDome::SetupParms()
{
targetAz = 0;
if (UpdatePosition())
IDSetNumber(&DomeAbsPosNP, nullptr);
if (UpdateShutterStatus())
IDSetSwitch(&DomeShutterSP, nullptr);
if (UpdateFlapStatus())
IDSetSwitch(&DomeFlapSP, nullptr);
if (InitPark())
{
// If loading parking data is successful, we just set the default parking values.
SetAxis1ParkDefault(0);
}
else
{
// Otherwise, we set all parking data to default in case no parking data is found.
SetAxis1Park(0);
SetAxis1ParkDefault(0);
}
return true;
}
示例2: INDI_UNUSED
bool FocuserInterface::processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
INDI_UNUSED(dev);
// This one is for us
if (strcmp(name, "FOCUS_MOTION") == 0)
{
// Record last direction and state.
FocusDirection prevDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;
IPState prevState = FocusMotionSP.s;
IUUpdateSwitch(&FocusMotionSP, states, names, n);
FocusDirection targetDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;
if (CanRelMove() || CanAbsMove() || HasVariableSpeed())
{
FocusMotionSP.s = IPS_OK;
}
// If we are dealing with a simple dumb DC focuser, we move in a specific direction in an open-loop fashion until stopped.
else
{
// If we are reversing direction let's issue abort first.
if (prevDirection != targetDirection && prevState == IPS_BUSY)
AbortFocuser();
FocusMotionSP.s = MoveFocuser(targetDirection, 0, 0);
}
IDSetSwitch(&FocusMotionSP, nullptr);
return true;
}
if (strcmp(name, "FOCUS_ABORT_MOTION") == 0)
{
IUResetSwitch(&AbortSP);
if (AbortFocuser())
{
AbortSP.s = IPS_OK;
if (CanAbsMove() && FocusAbsPosNP.s != IPS_IDLE)
{
FocusAbsPosNP.s = IPS_IDLE;
IDSetNumber(&FocusAbsPosNP, nullptr);
}
if (CanRelMove() && FocusRelPosNP.s != IPS_IDLE)
{
FocusRelPosNP.s = IPS_IDLE;
IDSetNumber(&FocusRelPosNP, nullptr);
}
}
else
AbortSP.s = IPS_ALERT;
IDSetSwitch(&AbortSP, nullptr);
return true;
}
return false;
}
示例3: IDSetSwitch
void QHYCCD::setCooler(bool enable)
{
if (enable && coolerEnabled == false)
{
CoolerS[0].s = ISS_ON;
CoolerS[1].s = ISS_OFF;
CoolerSP.s = IPS_OK;
IDSetSwitch(&CoolerSP, NULL);
CoolerNP.s = IPS_BUSY;
IDSetNumber(&CoolerNP, NULL);
DEBUG(INDI::Logger::DBG_SESSION, "Cooler on.");
coolerEnabled = true;
}
else if (!enable && coolerEnabled == true)
{
coolerEnabled = false;
if (sim == false)
SetQHYCCDParam(camhandle, CONTROL_MANULPWM, 0);
CoolerSP.s = IPS_IDLE;
CoolerS[0].s = ISS_OFF;
CoolerS[1].s = ISS_ON;
IDSetSwitch(&CoolerSP, NULL);
CoolerNP.s = IPS_IDLE;
IDSetNumber(&CoolerNP, NULL);
TemperatureNP.s = IPS_IDLE;
IDSetNumber(&TemperatureNP, NULL);
DEBUG(INDI::Logger::DBG_SESSION, "Cooler off.");
}
}
示例4: IDSetSwitch
bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
int index = 0;
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
// Focus Motion
if (!strcmp(name, FocusMotionSP.name))
{
// If speed is "halt"
if (FocusSpeedN[0].value == 0)
{
FocusMotionSP.s = IPS_IDLE;
IDSetSwitch(&FocusMotionSP, nullptr);
return false;
}
int last_motion = IUFindOnSwitchIndex(&FocusMotionSP);
if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0)
return false;
index = IUFindOnSwitchIndex(&FocusMotionSP);
// If same direction and we're busy, stop
if (last_motion == index && FocusMotionSP.s == IPS_BUSY)
{
IUResetSwitch(&FocusMotionSP);
FocusMotionSP.s = IPS_IDLE;
setFocuserSpeedMode(PortFD, 0);
IDSetSwitch(&FocusMotionSP, nullptr);
return true;
}
if (!isSimulation() && setFocuserMotion(PortFD, index) < 0)
{
FocusMotionSP.s = IPS_ALERT;
IDSetSwitch(&FocusMotionSP, "Error setting focuser speed.");
return false;
}
FocusMotionSP.s = IPS_BUSY;
// with a timer
if (FocusTimerNP.np[0].value > 0)
{
FocusTimerNP.s = IPS_BUSY;
if (isDebug())
IDLog("Starting Focus Timer BUSY\n");
IEAddTimer(50, LX200Generic::updateFocusHelper, this);
}
IDSetSwitch(&FocusMotionSP, nullptr);
return true;
}
}
return LX200Generic::ISNewSwitch(dev, name, states, names, n);
}
示例5: LOG_DEBUG
bool FocusMaster::AbortFocuser()
{
uint8_t command[MAX_FM_BUF] = {0};
command[0] = 0x30;
command[1] = 0x30;
LOG_DEBUG("Aborting Focuser...");
bool rc = sendCommand(command);
if (rc)
{
if (FullMotionSP.s == IPS_BUSY)
{
IUResetSwitch(&FullMotionSP);
FullMotionSP.s = IPS_IDLE;
IDSetSwitch(&FullMotionSP, nullptr);
}
if (FocusMotionSP.s == IPS_BUSY)
{
IUResetSwitch(&FocusMotionSP);
FocusMotionSP.s = IPS_IDLE;
IDSetSwitch(&FocusMotionSP, nullptr);
}
}
return rc;
}
示例6: IDSetNumber
void ASIEAF::GetFocusParams()
{
if (readPosition())
IDSetNumber(&FocusAbsPosNP, nullptr);
if (readReverse())
IDSetSwitch(&FocusReverseSP, nullptr);
if (readBeep())
IDSetSwitch(&BeepSP, nullptr);
}
示例7: readU32
/************************************************************************************
*
* ***********************************************************************************/
bool ScopeDome::SetupParms()
{
targetAz = 0;
readU32(GetImpPerTurn, stepsPerTurn);
LOGF_INFO("Steps per turn read as %d", stepsPerTurn);
StepsPerRevolutionN[0].value = stepsPerTurn;
StepsPerRevolutionNP.s = IPS_OK;
IDSetNumber(&StepsPerRevolutionNP, nullptr);
readS32(GetHomeSensorPosition, homePosition);
LOGF_INFO("Home position read as %d", homePosition);
if (UpdatePosition())
IDSetNumber(&DomeAbsPosNP, nullptr);
if (UpdateShutterStatus())
IDSetSwitch(&DomeShutterSP, nullptr);
UpdateSensorStatus();
UpdateRelayStatus();
if (InitPark())
{
// If loading parking data is successful, we just set the default parking
// values.
SetAxis1ParkDefault(0);
}
else
{
// Otherwise, we set all parking data to default in case no parking data is
// found.
SetAxis1Park(0);
SetAxis1ParkDefault(0);
}
uint8_t calibrationNeeded = false;
readU8(IsFullSystemCalReq, calibrationNeeded);
CalibrationNeededS[0].s = calibrationNeeded ? ISS_ON : ISS_OFF;
CalibrationNeededSP.s = IPS_OK;
IDSetSwitch(&CalibrationNeededSP, nullptr);
uint16_t fwVersion;
readU16(GetVersionFirmware, fwVersion);
FirmwareVersionsN[0].value = fwVersion / 100.0;
uint8_t fwVersionRotary;
readU8(GetVersionFirmwareRotary, fwVersionRotary);
FirmwareVersionsN[1].value = (fwVersionRotary + 9) / 10.0;
FirmwareVersionsNP.s = IPS_OK;
IDSetNumber(&FirmwareVersionsNP, nullptr);
return true;
}
示例8: IUUpdateSwitch
bool INDI::Focuser::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
if(strcmp(dev,getDeviceName())==0)
{
if (!strcmp(PresetGotoSP.name, name))
{
IUUpdateSwitch(&PresetGotoSP, states, names, n);
int index = IUFindOnSwitchIndex(&PresetGotoSP);
if (PresetN[index].value < FocusAbsPosN[0].min)
{
PresetGotoSP.s = IPS_ALERT;
IDSetSwitch(&PresetGotoSP, NULL);
DEBUGFDEVICE(dev, INDI::Logger::DBG_ERROR, "Requested position out of bound. Focus minimum position is %g", FocusAbsPosN[0].min);
return false;
}
else if (PresetN[index].value > FocusAbsPosN[0].max)
{
PresetGotoSP.s = IPS_ALERT;
IDSetSwitch(&PresetGotoSP, NULL);
DEBUGFDEVICE(dev, INDI::Logger::DBG_ERROR, "Requested position out of bound. Focus maximum position is %g", FocusAbsPosN[0].max);
return false;
}
int rc = MoveAbsFocuser(PresetN[index].value);
if (rc >= 0)
{
PresetGotoSP.s = IPS_OK;
DEBUGF(INDI::Logger::DBG_SESSION, "Moving to Preset %d with position %g.", index+1, PresetN[index].value);
IDSetSwitch(&PresetGotoSP, NULL);
return true;
}
PresetGotoSP.s = IPS_ALERT;
IDSetSwitch(&PresetGotoSP, NULL);
return false;
}
if (strstr(name, "FOCUS_"))
return processFocuserSwitch(dev, name, states, names, n);
}
controller->ISNewSwitch(dev, name, states, names, n);
// Nobody has claimed this, so, ignore it
return DefaultDevice::ISNewSwitch(dev,name,states,names,n);
}
示例9: EAFSetBeep
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);
}
示例10: IUFindOnSwitchIndex
bool DSICCD::ISNewSwitch (const char *dev, const char *name,
ISState *states, char *names[], int n)
{
int index=0;
if(strcmp(dev,getDeviceName())==0)
{
/* Vdd on/off switch for DSI III exposure control (gs) */
if (!strcmp(name,VddExpSP.name))
{
if (IUUpdateSwitch(&VddExpSP, states, names, n) < 0)
return false;
index = IUFindOnSwitchIndex(&VddExpSP);
if (index == 0)
dsi->setVddOn(true);
else
dsi->setVddOn(false);
VddExpSP.s = IPS_OK;
IDSetSwitch (&VddExpSP,
index == 0 ? "Vdd mode is ON" : "Vdd mode is OFF" );
return true;
}
}
return INDI::CCD::ISNewSwitch (dev, name, states, names, n);
}
示例11: IUUpdateNumber
bool ASICCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
ASI_ERROR_CODE errCode = ASI_SUCCESS;
if(!strcmp(dev,getDeviceName()))
{
if (!strcmp(name, ControlNP.name))
{
double oldValues[ControlNP.nnp];
for (int i=0; i < ControlNP.nnp; i++)
oldValues[i] = ControlN[i].value;
IUUpdateNumber(&ControlNP, values, names, n);
for (int i=0; i < ControlNP.nnp; i++)
{
ASI_BOOL nAuto = *((ASI_BOOL *) ControlN[i].aux1);
ASI_CONTROL_TYPE nType = *((ASI_CONTROL_TYPE *) ControlN[i].aux0);
// If value didn't change or if USB bandwidth control is to change, then only continue if ExposureRequest < 250 ms
if (ControlN[i].value == oldValues[i] || (nType == ASI_BANDWIDTHOVERLOAD && ExposureRequest > 0.25))
continue;
if ( (errCode = ASISetControlValue(m_camInfo->CameraID, nType, ControlN[i].value, ASI_FALSE)) != ASI_SUCCESS)
{
DEBUGF(INDI::Logger::DBG_ERROR, "ASISetControlValue (%s=%g) error (%d)", ControlN[i].name, ControlN[i].value, errCode);
ControlNP.s = IPS_ALERT;
for (int i=0; i < ControlNP.nnp; i++)
ControlN[i].value = oldValues[i];
IDSetNumber(&ControlNP, NULL);
return false;
}
// If it was set to nAuto value to turn it off
if (nAuto)
{
for (int j=0; j < ControlSP.nsp; j++)
{
ASI_CONTROL_TYPE swType = *((ASI_CONTROL_TYPE *) ControlS[j].aux);
if (swType == nType)
{
ControlS[j].s = ISS_OFF;
break;
}
}
IDSetSwitch(&ControlSP, NULL);
}
}
ControlNP.s = IPS_OK;
IDSetNumber(&ControlNP, NULL);
return true;
}
}
return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
示例12: IUFindOnSwitchIndex
bool INDI::LightBoxInterface::processLightBoxSwitch(const char *dev, const char *name, ISState *states, char *names[],
int n)
{
if (strcmp(dev, device->getDeviceName()) == 0)
{
// Light
if (!strcmp(LightSP.name, name))
{
int prevIndex = IUFindOnSwitchIndex(&LightSP);
IUUpdateSwitch(&LightSP, states, names, n);
bool rc = EnableLightBox(LightS[FLAT_LIGHT_ON].s == ISS_ON ? true : false);
LightSP.s = rc ? IPS_OK : IPS_ALERT;
if (!rc)
{
IUResetSwitch(&LightSP);
LightS[prevIndex].s = ISS_ON;
}
IDSetSwitch(&LightSP, nullptr);
return true;
}
}
return false;
}
示例13: getImageType
bool ASICCD::StartStreaming()
{
ASI_IMG_TYPE type = getImageType();
if (type != ASI_IMG_Y8 && type != ASI_IMG_RGB24)
{
IUResetSwitch(&VideoFormatSP);
ISwitch *vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_Y8");
if (vf == NULL)
vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_RAW8");
if (vf)
{
vf->s = ISS_ON;
DEBUGF(INDI::Logger::DBG_DEBUG, "Switching to %s video format.", vf->label);
PrimaryCCD.setBPP(8);
UpdateCCDFrame(PrimaryCCD.getSubX(), PrimaryCCD.getSubY(), PrimaryCCD.getSubW(), PrimaryCCD.getSubH());
IDSetSwitch(&VideoFormatSP, NULL);
}
else
{
DEBUG(INDI::Logger::DBG_ERROR, "No 8 bit video format found, cannot start stream.");
return false;
}
}
ASIStartVideoCapture(m_camInfo->CameraID);
pthread_mutex_lock(&condMutex);
streamPredicate = 1;
pthread_mutex_unlock(&condMutex);
pthread_cond_signal(&cv);
return true;
}
示例14: while
bool MaxDomeII::Abort()
{
int error=0;
int nRetry = 3;
while (nRetry)
{
error = Abort_Azimuth_MaxDomeII(PortFD);
handle_driver_error(&error, &nRetry);
}
while (nRetry)
{
error = Abort_Shutter_MaxDomeII(PortFD);
handle_driver_error(&error, &nRetry);
}
DomeAbsPosNP.s = IPS_IDLE;
IDSetNumber(&DomeAbsPosNP, NULL);
// If we abort while in the middle of opening/closing shutter, alert.
if (DomeShutterSP.s == IPS_BUSY)
{
DomeShutterSP.s = IPS_ALERT;
IDSetSwitch(&DomeShutterSP, "Shutter operation aborted.");
return false;
}
return true;
}
示例15: IUUpdateSwitch
/********************************************************************************************
** Client is asking us to update a switch
*********************************************************************************************/
bool RainDetector::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
if (strcmp(name, RainSP.name) == 0)
{
IUUpdateSwitch(&RainSP, states, names, n);
if (RainS[0].s == ISS_ON)
{
RainL[0].s = IPS_ALERT;
RainLP.s = IPS_ALERT;
IDSetLight(&RainLP, "Alert! Alert! Rain detected!");
}
else
{
RainL[0].s = IPS_IDLE;
RainLP.s = IPS_OK;
IDSetLight(&RainLP, "Rain threat passed. The skies are clear.");
}
RainSP.s = IPS_OK;
IDSetSwitch(&RainSP, nullptr);
return true;
}
}
return INDI::DefaultDevice::ISNewSwitch(dev, name, states, names, n);
}