/* * rigmatric.c - Copyright (C) 2000 Stephane Fillod * This program generates the supported rig matrix in HTML format. * The code is rather ugly since this is only a try out. * * * $Id: rigmatrix.c,v 1.9 2001-03-01 21:23:32 f4cfe Exp $ * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include #include #include #include #include #include #include #include int create_png_range(const freq_range_t rx_range_list[], const freq_range_t tx_range_list[], int num); int print_caps_sum(const struct rig_caps *caps, void *data) { printf("%s%s%s", caps->model_name,caps->mfg_name,caps->version ); switch (caps->status) { case RIG_STATUS_ALPHA: printf("Alpha"); break; case RIG_STATUS_UNTESTED: printf("Untested"); break; case RIG_STATUS_BETA: printf("Beta"); break; case RIG_STATUS_STABLE: printf("Stable"); break; case RIG_STATUS_BUGGY: printf("Buggy"); break; case RIG_STATUS_NEW: printf("New"); break; default: printf("Unknown"); } printf(""); switch (caps->rig_type) { case RIG_TYPE_TRANSCEIVER: printf("Transceiver"); break; case RIG_TYPE_HANDHELD: printf("Handheld"); break; case RIG_TYPE_MOBILE: printf("Mobile"); break; case RIG_TYPE_RECEIVER: printf("Receiver"); break; case RIG_TYPE_PCRECEIVER: printf("PC Receiver"); break; case RIG_TYPE_SCANNER: printf("Scanner"); break; case RIG_TYPE_COMPUTER: printf("Computer"); break; case RIG_TYPE_OTHER: printf("Other"); break; default: printf("Unknown"); } printf("range" "parms" "caps" "func" "levels" "set levels" "\n", caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model, caps->rig_model ); return 1; /* !=0, we want them all ! */ } /* * IO params et al. */ int print_caps_parms(const struct rig_caps *caps, void *data) { printf("%s", caps->rig_model, caps->model_name); switch (caps->ptt_type) { case RIG_PTT_RIG: printf("rig"); break; case RIG_PTT_PARALLEL: printf("parallel"); break; case RIG_PTT_SERIAL_RTS: case RIG_PTT_SERIAL_DTR: printf("serial"); break; case RIG_PTT_NONE: printf("None"); break; default: printf("Unknown"); } printf(""); switch (caps->dcd_type) { case RIG_DCD_RIG: printf("rig"); break; case RIG_DCD_PARALLEL: printf("parallel"); break; case RIG_DCD_SERIAL_CTS: case RIG_DCD_SERIAL_DSR: printf("serial"); break; case RIG_DCD_NONE: printf("None"); break; default: printf("Unknown"); } printf(""); switch (caps->port_type) { case RIG_PORT_SERIAL: printf("serial"); break; case RIG_PORT_DEVICE: printf("device"); break; case RIG_PORT_NETWORK: printf("network"); break; case RIG_PORT_NONE: printf("None"); break; default: printf("Unknown"); } printf("%d%d%d%c%d%s", caps->serial_rate_min, caps->serial_rate_max, caps->serial_data_bits, caps->serial_parity==RIG_PARITY_NONE?'N': (caps->serial_parity==RIG_PARITY_ODD?'O':'E'), caps->serial_stop_bits, caps->serial_handshake==RIG_HANDSHAKE_NONE?"none": (caps->serial_handshake==RIG_HANDSHAKE_XONXOFF?"XONXOFF":"CTS/RTS") ); printf("%dms%dms%dms%d\n", caps->write_delay, caps->post_write_delay, caps->timeout, caps->retry); return 1; } /* used by print_caps_caps and print_caps_level */ #define print_yn(fn) printf("%c", (fn) ? 'Y':'N') /* * backend functions definied * * TODO: add new API calls! */ int print_caps_caps(const struct rig_caps *caps, void *data) { printf("%s", caps->rig_model, caps->model_name); /* targetable_vfo is not a function, but a boolean */ print_yn(caps->targetable_vfo); print_yn(caps->set_freq); print_yn(caps->get_freq); print_yn(caps->set_mode); print_yn(caps->get_mode); print_yn(caps->set_vfo); print_yn(caps->get_vfo); print_yn(caps->set_ptt); print_yn(caps->get_ptt); print_yn(caps->get_dcd); print_yn(caps->set_rptr_shift); print_yn(caps->get_rptr_shift); print_yn(caps->set_rptr_offs); print_yn(caps->get_rptr_offs); print_yn(caps->set_split_freq); print_yn(caps->get_split_freq); print_yn(caps->set_split); print_yn(caps->get_split); print_yn(caps->set_ts); print_yn(caps->get_ts); print_yn(caps->set_ctcss); print_yn(caps->get_ctcss); print_yn(caps->set_dcs); print_yn(caps->get_dcs); print_yn(caps->set_poweron); print_yn(caps->set_poweroff); print_yn(caps->set_trn); print_yn(caps->set_trn); print_yn(caps->decode_event); printf("\n"); return 1; } /* * Get/Set level abilities */ int print_caps_level(const struct rig_caps *caps, void *data) { setting_t level; if (!data) return 0; level = (*(int*)data)? caps->has_set_level : caps->has_get_level; printf("%s", (*(int*)data)? "set":"get", caps->rig_model, caps->model_name); print_yn(level & RIG_LEVEL_PREAMP); print_yn(level & RIG_LEVEL_ATT); #if 0 print_yn(level & RIG_LEVEL_ANT); /* deprecated */ #endif print_yn(level & RIG_LEVEL_AF); print_yn(level & RIG_LEVEL_RF); print_yn(level & RIG_LEVEL_SQL); print_yn(level & RIG_LEVEL_IF); print_yn(level & RIG_LEVEL_APF); print_yn(level & RIG_LEVEL_NR); print_yn(level & RIG_LEVEL_PBT_IN); print_yn(level & RIG_LEVEL_PBT_OUT); print_yn(level & RIG_LEVEL_CWPITCH); print_yn(level & RIG_LEVEL_RFPOWER); print_yn(level & RIG_LEVEL_MICGAIN); print_yn(level & RIG_LEVEL_KEYSPD); print_yn(level & RIG_LEVEL_NOTCHF); print_yn(level & RIG_LEVEL_COMP); print_yn(level & RIG_LEVEL_AGC); print_yn(level & RIG_LEVEL_BKINDL); print_yn(level & RIG_LEVEL_BALANCE); #if 0 print_yn(level & RIG_LEVEL_ANN); /* deprecated */ #endif /* get only levels */ print_yn(level & RIG_LEVEL_SWR); print_yn(level & RIG_LEVEL_ALC); print_yn(level & RIG_LEVEL_SQLSTAT); print_yn(level & RIG_LEVEL_STRENGTH); printf("\n"); return 1; } /* * Get/Set func abilities */ int print_caps_func(const struct rig_caps *caps, void *data) { setting_t func; if (!data) return 0; func = (*(int*)data)? caps->has_set_func : caps->has_get_func; printf("%s", (*(int*)data)? "set":"get", caps->rig_model, caps->model_name); print_yn(func & RIG_FUNC_FAGC); print_yn(func & RIG_FUNC_NB); print_yn(func & RIG_FUNC_COMP); print_yn(func & RIG_FUNC_VOX); print_yn(func & RIG_FUNC_TONE); print_yn(func & RIG_FUNC_TSQL); print_yn(func & RIG_FUNC_SBKIN); print_yn(func & RIG_FUNC_FBKIN); print_yn(func & RIG_FUNC_ANF); print_yn(func & RIG_FUNC_NR); print_yn(func & RIG_FUNC_AIP); print_yn(func & RIG_FUNC_APF); print_yn(func & RIG_FUNC_MON); print_yn(func & RIG_FUNC_MN); print_yn(func & RIG_FUNC_RNF); printf("\n"); return 1; } /* * inlined PNG graphics * * FIXME: default output pics is for region2: add region 1 too! */ int print_caps_range(const struct rig_caps *caps, void *data) { create_png_range(caps->rx_range_list2, caps->tx_range_list2, caps->rig_model); printf("%s" "", caps->rig_model, caps->model_name, caps->rig_model); return 1; } #define RANGE_WIDTH 600 #define RANGE_HEIGHT 16 #define RANGE_MIDHEIGHT (RANGE_HEIGHT/2) #define RX_R 0 #define RX_G 255 #define RX_B 255 #define TX_R 0 #define TX_G 0 #define TX_B 255 #define HF_H 10 #define VHF_H 30 #define UHF_H 50 #define IM_LGD 21 static void draw_range(const freq_range_t range_list[], gdImagePtr im_rng, int h1, int h2, int rgb) { int i; for (i=0; i= RANGE_WIDTH) end_pix = RANGE_WIDTH-1; start_pix += IM_LGD; end_pix += IM_LGD; gdImageFilledRectangle(im_rng, start_pix, HF_H+h1, end_pix, HF_H+h2, rgb); } /* * VHF */ start_pix = range_list[i].start; end_pix = range_list[i].end; if ((range_list[i].start > MHz(30) && range_list[i].start < MHz(300)) || (range_list[i].start < MHz(30) && range_list[i].end > MHz(30))) { start_pix = (start_pix-MHz(30)) / MHz(300) * RANGE_WIDTH; end_pix = (end_pix-MHz(30)) / MHz(300) * RANGE_WIDTH; if (start_pix < 0) start_pix = 0; if (end_pix >= RANGE_WIDTH) end_pix = RANGE_WIDTH-1; start_pix += IM_LGD; end_pix += IM_LGD; gdImageFilledRectangle(im_rng, start_pix, VHF_H+h1, end_pix, VHF_H+h2, rgb); } /* * UHF */ start_pix = range_list[i].start; end_pix = range_list[i].end; if ((range_list[i].start > MHz(300) && range_list[i].start < GHz(3)) || (range_list[i].start < MHz(300) && range_list[i].end > MHz(300))) { start_pix = (start_pix-MHz(300)) / GHz(3) * RANGE_WIDTH; end_pix = (end_pix-MHz(300)) / GHz(3) * RANGE_WIDTH; if (start_pix < 0) start_pix = 0; if (end_pix >= RANGE_WIDTH) end_pix = RANGE_WIDTH-1; start_pix += IM_LGD; end_pix += IM_LGD; gdImageFilledRectangle(im_rng, start_pix, UHF_H+h1, end_pix, UHF_H+h2, rgb); } } } int create_png_range(const freq_range_t rx_range_list[], const freq_range_t tx_range_list[], int num) { FILE *out; /* Input and output images */ gdImagePtr im_rng; char rng_fname[128]; /* Color indexes */ int white, black; int rx_rgb,tx_rgb; /* Create output image, x by y pixels. */ im_rng = gdImageCreate(RANGE_WIDTH+IM_LGD, UHF_H+RANGE_HEIGHT); /* First color allocated is background. */ white = gdImageColorAllocate(im_rng, 255, 255, 255); black = gdImageColorAllocate(im_rng, 0, 0, 0); #if 0 /* Set transparent color. */ gdImageColorTransparent(im_rng, white); #endif /* Try to load demoin.png and paste part of it into the output image. */ tx_rgb = gdImageColorAllocate(im_rng, TX_R, TX_G, TX_B); rx_rgb = gdImageColorAllocate(im_rng, RX_R, RX_G, RX_B); draw_range(rx_range_list, im_rng, 0, RANGE_MIDHEIGHT-1, rx_rgb); draw_range(tx_range_list, im_rng, RANGE_MIDHEIGHT, RANGE_HEIGHT-1, tx_rgb); gdImageRectangle(im_rng, IM_LGD, HF_H, IM_LGD+RANGE_WIDTH-1, HF_H+RANGE_HEIGHT-1, black); gdImageRectangle(im_rng, IM_LGD, VHF_H, IM_LGD+RANGE_WIDTH-1, VHF_H+RANGE_HEIGHT-1, black); gdImageRectangle(im_rng, IM_LGD, UHF_H, IM_LGD+RANGE_WIDTH-1, UHF_H+RANGE_HEIGHT-1, black); /* gdImageStringUp */ gdImageString(im_rng, gdFontSmall, 1, HF_H+1, (unsigned char *) "HF", black); gdImageString(im_rng, gdFontSmall, 1, VHF_H+1, (unsigned char *) "VHF", black); gdImageString(im_rng, gdFontSmall, 1, UHF_H+1, (unsigned char *) "UHF", black); /* Make output image interlaced (allows "fade in" in some viewers, and in the latest web browsers) */ gdImageInterlace(im_rng, 1); sprintf(rng_fname, "range%d.png", num); out = fopen(rng_fname, "wb"); /* Write PNG */ gdImagePng(im_rng, out); fclose(out); gdImageDestroy(im_rng); return 0; } int main (int argc, char *argv[]) { int status; time_t gentime; int set_or_get; status = rig_load_backend("icom"); if (status != RIG_OK ) { printf("rig_load_backend: error = %s \n", rigerror(status)); exit(3); } status = rig_load_backend("ft747"); if (status != RIG_OK ) { printf("rig_load_backend: ft747 error = %s \n", rigerror(status)); exit(3); } status = rig_load_backend("ft847"); if (status != RIG_OK ) { printf("rig_load_backend: ft847 error = %s \n", rigerror(status)); exit(3); } status = rig_load_backend("kenwood"); if (status != RIG_OK ) { printf("rig_load_backend: kenwood error = %s \n", rigerror(status)); exit(3); } status = rig_load_backend("aor"); if (status != RIG_OK ) { printf("rig_load_backend: aor error = %s \n", rigerror(status)); exit(3); } rig_load_backend("winradio"); /* may not be compiled ... */ rig_load_backend("dummy"); printf(""); printf("" "" "" "" "" "" "\n"); status = rig_list_foreach(print_caps_sum,NULL); printf("
ModelMfgVers.StatusTypeFreq. rangeParametersCapabilitiesHas funcGet levelSet level
\n"); printf("

"); printf("\n"); printf("" "" "" "\n"); status = rig_list_foreach(print_caps_parms,NULL); printf("
ModelPTTDCDPortSpeed minSpeed maxParm.HandshakeWrite delayPost delayTimeoutRetry
\n"); printf("

"); printf("\n"); printf("\n"); status = rig_list_foreach(print_caps_range,NULL); printf("
ModelFreq. range
\n"); printf("

"); printf("\n"); printf("" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "\n"); status = rig_list_foreach(print_caps_caps,NULL); printf("
ModelTarget VFOSet freqGet freqSet modeGet modeSet VFOGet VFOSet PTTGet PTTGet DCDSet rptr shiftGet rptr shiftSet rptr offsGet rptr offsSet split frqGet split frqSet splitGet splitSet tsGet tsSet CTCSSGet CTCSSSet DCSGet DCSSet PowerONSet PowerOFFSet trnGet trnDecode
\n"); printf("

"); printf("Has set func"); printf("\n"); printf("" "" "" "" "" "" "" "" "" "\n"); set_or_get = 1; status = rig_list_foreach(print_caps_func,&set_or_get); printf("
ModelFAGCNBCOMPVOXTONETSQLSBKINFBKINANFNRAIPAPFMONMNRNF
\n"); printf("

"); printf("Has get func"); printf("\n"); printf("" "" "" "" "" "" "" "" "" "\n"); set_or_get = 0; status = rig_list_foreach(print_caps_func,&set_or_get); printf("
ModelFAGCNBCOMPVOXTONETSQLSBKINFBKINANFNRAIPAPFMONMNRNF
\n"); printf("

"); printf("Set level"); printf("\n"); printf("" "" "" "" "" "" "" "" "" "" "" "" "" "\n"); set_or_get = 1; status = rig_list_foreach(print_caps_level,&set_or_get); printf("
ModelPampAttAFRFSQLIFAPFNRPBT INPBT OUTCW pitchRF PowerMic gainKey speedNotchCompAGCBKin delayBalSWRALCSQL statSMeter
\n"); printf("

"); printf("Get level"); printf("\n"); printf("" "" "" "" "" "" "" "" "" "" "" "" "" "" "\n"); set_or_get = 0; status = rig_list_foreach(print_caps_level,&set_or_get); printf("
ModelPreampAttAntAFRFSQLIFAPFNRPBT INPBT OUTCW pitchRF PowerMic gainKey speedNotchCompAGCBKin delayBalAnnSWRALCSQL statSMeter
\n"); printf("

"); time(&gentime); printf("Rigmatrix generated %s by %s\n",ctime(&gentime), getenv("USER")); printf("\n"); return 0; }