* \brief Set the azimuth and elevation of the rotator. * * \param rot The #ROT handle. * \param azimuth The azimuth to set in decimal degrees. * \param elevation The elevation to set in decimal degrees. * * Sets the azimuth and elevation of the rotator. * * \b Note: A given rotator may be capable of setting only the azimuth or * only the elevation or both. The rotator backend will ignore
| 749 | * \sa rot_get_position() |
| 750 | */ |
| 751 | int HAMLIB_API rot_set_position(ROT *rot, |
| 752 | azimuth_t azimuth, |
| 753 | elevation_t elevation) |
| 754 | { |
| 755 | const struct rot_caps *caps; |
| 756 | const struct rot_state *rs; |
| 757 | |
| 758 | rot_debug(RIG_DEBUG_VERBOSE, "%s called az=%.02f el=%.02f\n", __func__, azimuth, |
| 759 | elevation); |
| 760 | |
| 761 | if (CHECK_ROT_ARG(rot)) |
| 762 | { |
| 763 | return -RIG_EINVAL; |
| 764 | } |
| 765 | |
| 766 | caps = rot->caps; |
| 767 | rs = ROTSTATE(rot); |
| 768 | |
| 769 | azimuth += rs->az_offset; |
| 770 | elevation += rs->el_offset; |
| 771 | |
| 772 | rot_debug(RIG_DEBUG_VERBOSE, "%s: south_zero=%d \n", __func__, rs->south_zero); |
| 773 | |
| 774 | if (rs->south_zero) |
| 775 | { |
| 776 | azimuth += azimuth >= 180 ? -180 : 180; |
| 777 | rot_debug(RIG_DEBUG_TRACE, "%s: south adj to az=%.2f\n", __func__, azimuth); |
| 778 | } |
| 779 | |
| 780 | if (azimuth < rs->min_az |
| 781 | || azimuth > rs->max_az |
| 782 | || elevation < rs->min_el |
| 783 | || elevation > rs->max_el) |
| 784 | { |
| 785 | rot_debug(RIG_DEBUG_TRACE, |
| 786 | "%s: range problem az=%.02f(min=%.02f,max=%.02f), el=%02f(min=%.02f,max=%02f)\n", |
| 787 | __func__, azimuth, rs->min_az, rs->max_az, elevation, rs->min_el, rs->max_el); |
| 788 | return -RIG_ELIMIT; |
| 789 | } |
| 790 | |
| 791 | if (caps->set_position == NULL) |
| 792 | { |
| 793 | return -RIG_ENAVAIL; |
| 794 | } |
| 795 | |
| 796 | return caps->set_position(rot, azimuth, elevation); |
| 797 | } |
| 798 | |
| 799 | |
| 800 | /** |
no outgoing calls
no test coverage detected