File indexing completed on 2025-02-16 06:40:21
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 0006 INDI Guide Interface 0007 */ 0008 0009 #include "indiguider.h" 0010 0011 namespace ISD 0012 { 0013 0014 Guider::Guider(GenericDevice *parent) : ConcreteDevice(parent) 0015 { 0016 } 0017 0018 void Guider::setDECSwap(bool enable) 0019 { 0020 swapDEC = enable; 0021 } 0022 0023 bool Guider::doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs) 0024 { 0025 bool raOK = doPulse(ra_dir, ra_msecs); 0026 bool decOK = doPulse(dec_dir, dec_msecs); 0027 return (raOK && decOK); 0028 } 0029 0030 bool Guider::doPulse(GuideDirection dir, int msecs) 0031 { 0032 auto raPulse = getNumber("TELESCOPE_TIMED_GUIDE_WE"); 0033 auto decPulse = getNumber("TELESCOPE_TIMED_GUIDE_NS"); 0034 INDI::PropertyView<INumber> *npulse = nullptr; 0035 INDI::WidgetView<INumber> *dirPulse = nullptr; 0036 0037 if (!raPulse || !decPulse) 0038 return false; 0039 0040 if (dir == RA_INC_DIR || dir == RA_DEC_DIR) 0041 { 0042 raPulse->at(0)->setValue(0); 0043 raPulse->at(1)->setValue(0); 0044 } 0045 else 0046 { 0047 decPulse->at(0)->setValue(0); 0048 decPulse->at(1)->setValue(0); 0049 } 0050 0051 switch (dir) 0052 { 0053 case RA_INC_DIR: 0054 npulse = raPulse; 0055 dirPulse = npulse->findWidgetByName("TIMED_GUIDE_W"); 0056 break; 0057 0058 case RA_DEC_DIR: 0059 npulse = raPulse; 0060 dirPulse = npulse->findWidgetByName("TIMED_GUIDE_E"); 0061 break; 0062 0063 case DEC_INC_DIR: 0064 npulse = decPulse; 0065 dirPulse = npulse->findWidgetByName(swapDEC ? "TIMED_GUIDE_S" : "TIMED_GUIDE_N"); 0066 break; 0067 0068 case DEC_DEC_DIR: 0069 npulse = decPulse; 0070 dirPulse = npulse->findWidgetByName(swapDEC ? "TIMED_GUIDE_N" : "TIMED_GUIDE_S"); 0071 break; 0072 0073 default: 0074 return false; 0075 } 0076 0077 if (!dirPulse) 0078 return false; 0079 0080 dirPulse->setValue(msecs); 0081 0082 sendNewProperty(npulse); 0083 0084 return true; 0085 } 0086 }