You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

10148 lines
247 KiB

//=================================================================
// CATCommands.cs
//=================================================================
// Copyright (C) 2012 Bob Tracy
//
// 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.
//
// You may contact the author via email at: k5kdn@arrl.net
//=================================================================
using System;
using System.Reflection;
using System.Diagnostics;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections.Generic;
namespace PowerSDR
{
/// <summary>
/// Summary description for CATCommands.
/// </summary>
public class CATCommands
{
#region Variable Definitions
private Console console;
private CATParser parser;
private string separator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
private Band[] BandList;
private int LastBandIndex;
private ASCIIEncoding AE = new ASCIIEncoding();
private string lastFR = "0";
private string lastFT = "0";
// public static Mutex CATmut = new Mutex();
private bool verbose = false;
public bool Verbose
{
get { return verbose; }
set { verbose = value; }
}
#endregion Variable Definitions
#region Constructors
public CATCommands()
{
}
public CATCommands(Console c,CATParser p)
{
console = c;
parser = p;
MakeBandList();
}
#endregion Constructors
// Commands getting this far have been checked for a valid prefix, a correct suffix length,
// and a terminator. All we need to do in this class is to decide what kind of command
// (read or set) and execute it. Only read commands generate answers.
#region Standard CAT Methods A-F
// Sets or reads the Audio Gain control
public string AG(string s)
{
if(s.Length == parser.nSet) // if the length of the parameter legal for setting this prefix
{
int raw = Convert.ToInt32(s.Substring(1));
int af = (int) Math.Round(raw/2.55,0); // scale 255:100 (Kenwood vs SDR)
console.AF = af; // Set the console control
return "";
}
else if(s.Length == parser.nGet) // if this is a read command
{
int af = (int) Math.Round(console.AF/0.392,0);
// return AddLeadingZeros(console.AF); // Get the console setting
return AddLeadingZeros(af);
}
else
{
return parser.Error1; // return a ?
}
}
public string AI(string s)
{
return ZZAI(s);
// if(console.SetupForm.AllowFreqBroadcast)
// {
// if(s.Length == parser.nSet)
// {
// if(s == "0")
// console.KWAutoInformation = false;
// else
// console.KWAutoInformation = true;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// if(console.KWAutoInformation)
// return "1";
// else
// return "0";
// }
// else
// return parser.Error1;
// }
// else
// return parser.Error1;
}
// Moves one band down from the currently selected band
// write only
public string BD()
{
// BandDown();
// return "";
return ZZBD();
}
// Moves one band up from the currently selected band
// write only
public string BU()
{
// BandUp();
// return "";
return ZZBU();
}
//Reads or sets the CTCSS frequency
public string CN(string s)
{
return ZZTB(s);
}
//Reads or sets the CTCSS enable button
public string CT(string s)
{
return ZZTA(s);
}
//Moves the VFO A frequency by the step size set on the console
public string DN()
{
// int step = console.StepSize;
// double[] wheel_tune_list;
// wheel_tune_list = new double[13]; // initialize wheel tuning list array
// wheel_tune_list[0] = 0.000001;
// wheel_tune_list[1] = 0.000010;
// wheel_tune_list[2] = 0.000050;
// wheel_tune_list[3] = 0.000100;
// wheel_tune_list[4] = 0.000250;
// wheel_tune_list[5] = 0.000500;
// wheel_tune_list[6] = 0.001000;
// wheel_tune_list[7] = 0.005000;
// wheel_tune_list[8] = 0.009000;
// wheel_tune_list[9] = 0.010000;
// wheel_tune_list[10] = 0.100000;
// wheel_tune_list[11] = 1.000000;
// wheel_tune_list[12] = 10.000000;
//
// console.VFOAFreq = console.VFOAFreq - wheel_tune_list[step];
// return "";
return ZZSA();
}
// Sets or reads the frequency of VFO A
public string FA(string s)
{
// if(s.Length == parser.nSet)
// {
// s = s.Insert(5,separator); //reinsert the global numeric separator
// console.VFOAFreq = double.Parse(s);
// return "";
// }
// else if(s.Length == parser.nGet)
// return StrVFOFreq("A");
// else
// return parser.Error1;
return ZZFA(s);
}
// Sets or reads the frequency of VFO B
public string FB(string s)
{
// if(s.Length == parser.nSet)
// {
// s = s.Insert(5,separator);
// console.VFOBFreq = double.Parse(s);
// return "";
// }
// else if(s.Length == parser.nGet)
// return StrVFOFreq("B");
// else
// return parser.Error1;
return ZZFB(s);
}
// Sets VFO A to control rx
// this is a dummy command to keep other software happy
// since the SDR-1000 always uses VFO A for rx
public string FR(string s)
{
if(s.Length == parser.nSet)
{
return "";
}
else if(s.Length == parser.nGet)
return "0";
else
return parser.Error1;
}
// Sets or reads VFO B to control tx
// another "happiness" command
public string FT(string s)
{
// if(s.Length == parser.nSet)
// {
// if(s == "1")
// {
// console.VFOSplit = true;
// }
// else if(s == "0")
// {
// console.VFOSplit = false;
// }
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// return ZZSP(s);
// }
// else
// return parser.Error1;
return ZZSP(s);
}
// Sets or reads the DSP filter width
//OBSOLETE
public string FW(string s)
{
if(s.Length == parser.nSet)
{
console.RX1Filter = String2Filter(s);
return "";
}
else if(s.Length == parser.nGet)
return Filter2String(console.RX1Filter);
else
return parser.Error1;
}
#endregion Standard CAT Methods A-F
#region Standard CAT Methods G-M
// Sets or reads the AGC constant
// this is a wrapper that calls ZZGT
public string GT(string s)
{
if(ZZGT(s).Length > 0)
return ZZGT(s).PadLeft(3,'0'); //Added padleft fix 4/2/2007 BT
else
return "";
}
// Reads the transceiver ID number
// this needs changing when 3rd party folks on line.
public string ID()
{
string id;
switch(console.CATRigType)
{
case 900:
id = "900"; //SDR-1000
break;
case 13:
id = "013"; //TS-50S
break;
case 19:
id = "019"; //TS-2000
break;
case 20:
id = "020"; //TS-480
break;
default:
id = "019";
break;
}
return(id);
}
// Reads the transceiver status
// needs work in the split area
public string IF()
{
string rtn = "";
string rit = "0";
string xit = "0";
string incr;
string tx = "0";
string tempmode = "";
int ITValue = 0;
//string temp;
// Get the rit/xit status
if(console.RITOn)
rit = "1";
else if(console.XITOn)
xit = "1";
// Get the incremental tuning value for whichever control is selected
if(rit == "1")
ITValue = console.RITValue;
else if(xit == "1")
ITValue = console.XITValue;
// Format the IT value
if(ITValue < 0)
incr = "-"+Convert.ToString(Math.Abs(ITValue)).PadLeft(5,'0');
else
incr = "+"+Convert.ToString(Math.Abs(ITValue)).PadLeft(5,'0');
// Get the rx - tx status
if(console.MOX)
tx = "1";
// Get the step size
int step = console.TuneStepIndex;
string stepsize = Step2String(step);
// Get the vfo split status
string split = "0";
bool retval = console.VFOSplit;
if(retval)
split = "1";
//Get the mode
// temp = Mode2KString(console.RX1DSPMode); //possible fix for SAM problem
// if(temp == parser.Error1)
// temp = " ";
string f = ZZFA("");
if(f.Length > 11)
{
f = f.Substring(f.Length-11,11);
}
rtn += f;
// rtn += StrVFOFreq("A"); // VFO A frequency 11 bytes
rtn += stepsize; // Console step frequency 4 bytes
rtn += incr; // incremental tuning value 6 bytes
rtn += rit; // RIT status 1 byte
rtn += xit; // XIT status 1 byte
rtn += "000"; // dummy for memory bank 3 bytes
rtn += tx; // tx-rx status 1 byte
// rtn += temp;
// rtn += Mode2KString(console.RX1DSPMode); // current mode 1 bytes
tempmode = Mode2KString(console.RX1DSPMode);
if(tempmode == "?;")
rtn += "2";
else
rtn += tempmode;
rtn += "0"; // dummy for FR/FT 1 byte
rtn += "0"; // dummy for scan status 1 byte
rtn += split; // VFO Split status 1 byte
rtn += "0000"; // dummy for the balance 4 bytes
return rtn; // total bytes 35
// // Initalize the command word
// string cmd_string = "";
// string temp;
//
// // Get VFOA's frequency (P1 - 11 bytes)
// if(console.VFOSplit)
// cmd_string += StrVFOFreq("B");
// else
// cmd_string += StrVFOFreq("A");
//
// // Get the step size index (P2 - 4 bytes)
// cmd_string += ZZST();
//
// // Determine which incremental tuning control is active
// // and get the value for the active control
// string rit = "0";
// string xit = "0";
// int ITValue = 0;
//
// if(console.RITOn)
// rit = "1";
// else if(console.XITOn)
// xit = "1";
//
// if(rit == "1")
// ITValue = console.RITValue;
// else if(xit == "1")
// ITValue = console.XITValue;
//
// // Add the ITValue to the command string (P3 - 6 bytes
// if(ITValue < 0)
// cmd_string += "-"+Convert.ToString(Math.Abs(ITValue)).PadLeft(5,'0');
// else
// cmd_string += "+"+Convert.ToString(Math.Abs(ITValue)).PadLeft(5,'0');
//
// // Add the RIT/XIT status bits (P4 and P5, one byte each)
// cmd_string += rit+xit;
//
// // Skip the memory channel stuff, the SDR1K doesn't use banks and channels per se
// // (P6 - 1 byte, P7 - 2 bytes)
// cmd_string += "000";
//
// // Set the current MOX state (P8 - 1 byte)(what the heck is this for?)
// if(console.MOX)
// cmd_string += "1";
// else
// cmd_string += "0";
//
// // Get the SDR mode. (P9 - 1 byte)
// temp = Mode2KString(console.RX1DSPMode);
// if(temp.Length == 1) // if the answer is not an error message ?;
// cmd_string += temp;
// else
// cmd_string += " "; // return a blank if it's an error
//
// // Set the FR/FT commands which determines the transmit and receive
// // VFO's. VFO A = 0, VFO B = 1. (P10 - 1 byte)
// if(console.VFOSplit)
// cmd_string += "1";
// else
// cmd_string += "0";
//
//
// // Set the Scan code to 0
// // The Scan code might be implemented but the frequency range would
// // have to be manually entered. (P11 - 1 byte)
// cmd_string += "0";
//
// // Set the Split operation code (P12 - 1 byte)
// cmd_string += ZZSP("");
//
// // Set the remaining CTCSS tone and shift bits to 0 (P13 - P15, 4 bytes)
// cmd_string += "0000";
//
// return cmd_string;
}
//Sets or reads the CWX CW speed
public string KS(string s)
{
// int cws = 0;
// // Make sure we have an instance of the form
// if(console.CWXForm == null || console.CWXForm.IsDisposed)
// {
// try
// {
// console.CWXForm = new CWX(console);
// }
// catch
// {
// return parser.Error1;
// }
// }
// if(s.Length == parser.nSet)
// {
// cws = Convert.ToInt32(s);
// cws = Math.Max(1, cws);
// cws = Math.Min(99, cws);
// console.CWXForm.WPM = cws;
// return "";
//
// }
// else if(s.Length == parser.nGet)
// {
// return AddLeadingZeros(console.CWXForm.WPM);
// }
// else
// return parser.Error1;
return ZZKS(s);
}
//Sends text data to CWX for conversion to Morse
public string KY(string s)
{
// Make sure we have an instance of the form
if(console.cwxForm == null || console.cwxForm.IsDisposed)
{
try
{
console.cwxForm = new CWX(console);
}
catch
{
return parser.Error1;
}
}
// Make sure we are in a cw mode.
switch(console.RX1DSPMode)
{
case DSPMode.AM:
case DSPMode.DRM:
case DSPMode.DSB:
case DSPMode.FM:
case DSPMode.SAM:
case DSPMode.SPEC:
case DSPMode.LSB:
case DSPMode.USB:
if(console.RX1Band >= Band.B160M && console.RX1Band <= Band.B40M)
console.RX1DSPMode = DSPMode.CWL;
else
console.RX1DSPMode = DSPMode.CWU;
break;
case DSPMode.CWL:
case DSPMode.CWU:
break;
default:
console.RX1DSPMode = DSPMode.CWU;
break;
}
if(s.Length == parser.nSet)
{
string trms = "";
byte[] msg;
string x = s.Trim();
if(x.Length == 0)
trms = " ";
else
trms = s.TrimEnd();
if(trms.Length > 1)
{
msg = AE.GetBytes(trms);
return console.cwxForm.RemoteMessage(msg);
}
else
{
char ss = Convert.ToChar(trms);
return console.cwxForm.RemoteMessage(ss);
}
}
else if(s.Length == parser.nGet)
{
int ch = console.cwxForm.Characters2Send;
if(ch < 72)
return "0";
else
return "1";
}
else
return parser.Error1;
}
// Sets or reads the transceiver mode
public string MD(string s)
{
if(s.Length == parser.nSet)
{
if(Convert.ToInt32(s) > 0 && Convert.ToInt32(s) <= 9)
{
KString2Mode(s);
return "";
}
else
return parser.Error1;
}
else if(s.Length == parser.nGet)
{
return Mode2KString(console.RX1DSPMode);
}
else
return parser.Error1;
}
// Sets or reads the Mic Gain thumbwheel
public string MG(string s)
{
int n;
if(s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
n = Math.Max(0, n);
n = Math.Min(100, n);
int mg = (int) Math.Round(n/1.43,0); // scale 100:70 (Kenwood vs SDR)
s = AddLeadingZeros(mg);
return ZZMG(s);
}
else if(s.Length == parser.nGet)
{
s = ZZMG("");
n = Convert.ToInt32(s);
int mg = (int) Math.Round(n/.7,0);
s = AddLeadingZeros(mg);
return s;
}
else
return parser.Error1;
}
// Sets or reads the Monitor status
public string MO(string s)
{
// if(s.Length == parser.nSet)
// {
// if(s == "0")
// console.MON = false;
// else if(s == "1")
// console.MON = true;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// bool retval = console.MON;
// if(retval)
// return "1";
// else
// return "0";
// }
// else
// return parser.Error1;
return ZZMO(s);
}
#endregion Standard CAT Methods G-M
#region Standard CAT Methods N-Q
// Sets or reads the Noise Blanker 1 status
public string NB(string s)
{
// if(s.Length == parser.nSet && (s == "0" || s == "1"))
// {
// console.CATNB1 = Convert.ToInt32(s);
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// return console.CATNB1.ToString();
// }
// else
// {
// return parser.Error1;
// }
return ZZNA(s);
}
// Sets or reads the Automatic Notch Filter status
public string NT(string s)
{
// if(s.Length == parser.nSet && (s == "0" || s == "1"))
// {
// console.CATANF = Convert.ToInt32(s);
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// return console.CATANF.ToString();
// }
// else
// {
// return parser.Error1;
// }
return ZZNT(s);
}
//Sets or reads the FM repeater offset frequency
public string OF(string s)
{
return ZZOT(s);
}
//Sets or reads the repeater offset direction
public string OS(string s)
{
return ZZOS(s);
}
// Sets or reads the PA output thumbwheel
public string PC(string s)
{
// int pwr = 0;
//
// if(s.Length == parser.nSet)
// {
// pwr = Convert.ToInt32(s);
// console.PWR = pwr;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// return AddLeadingZeros(console.PWR);
// }
// else
// {
// return parser.Error1;
// }
return ZZPC(s);
}
// Sets or reads the Speech Compressor status
//Reactivated 10/21/2012 for HRD compatibility BT
public string PR(string s)
{
if (s.Length == parser.nGet)
{
return "0";
}
else
{
return parser.Error1;
}
}
// Sets or reads the console power on/off status
public string PS(string s)
{
// if(s.Length == parser.nSet)
// {
// if(s == "0")
// console.PowerOn = false;
// else if(s == "1")
// console.PowerOn = true;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// bool pwr = console.PowerOn;
// if(pwr)
// return "1";
// else
// return "0";
// }
// else
// {
// return parser.Error1;
// }
return ZZPS(s);
}
// Sets the Quick Memory with the current contents of VFO A
public string QI()
{
// console.CATMemoryQS();
// return "";
return ZZQS();
}
#endregion Standard CAT Methods N-Q
#region Standard CAT Methods R-Z
// Clears the RIT value
// write only
public string RC()
{
// console.RITValue = 0;
// return "";
return ZZRC();
}
//Decrements RIT
public string RD(string s)
{
return ZZRD(s);
}
// Sets or reads the RIT status (on/off)
public string RT(string s)
{
// if(s.Length == parser.nSet)
// {
// if(s == "0")
// console.RITOn = false;
// else if(s == "1")
// console.RITOn = true;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// bool rit = console.RITOn;
// if(rit)
// return "1";
// else
// return "0";
// }
// else
// {
// return parser.Error1;
// }
return ZZRT(s);
}
//Increments RIT
public string RU(string s)
{
return ZZRU(s);
}
// Sets or reads the transceiver receive mode status
// write only but spec shows an answer parameter for a read???
public string RX(string s)
{
console.CATPTT = false;
return "";
//return ZZTX("0");
}
// Sets or reads the variable DSP filter high side
public string SH(string s)
{
if(s.Length == parser.nSet)
{
SetFilter(s, "SH");
return "";
}
else if(s.Length == parser.nGet)
{
switch(console.RX1DSPMode)
{
case DSPMode.AM:
case DSPMode.CWU:
case DSPMode.DRM:
case DSPMode.DSB:
case DSPMode.FM:
case DSPMode.SAM:
case DSPMode.USB:
case DSPMode.DIGU: // ke9ns add
return Frequency2Code(console.RX1FilterHigh,"SH");
case DSPMode.CWL:
case DSPMode.LSB:
case DSPMode.DIGL: // ke9ns add
return Frequency2Code(console.RX1FilterLow,"SH");
default:
return Frequency2Code(console.RX1FilterHigh,"SH");
}
}
else
{
return parser.Error1;
}
}
// Sets or reads the variable DSP filter low side
public string SL(string s)
{
if(s.Length == parser.nSet)
{
SetFilter(s, "SL");
return "";
}
else if(s.Length == parser.nGet)
{
switch(console.RX1DSPMode)
{
case DSPMode.AM:
case DSPMode.CWU:
case DSPMode.DRM:
case DSPMode.DSB:
case DSPMode.FM:
case DSPMode.SAM:
case DSPMode.USB:
case DSPMode.DIGU: // ke9ns add
return Frequency2Code(console.RX1FilterLow,"SL");
case DSPMode.CWL:
case DSPMode.LSB:
case DSPMode.DIGL: // ke9ns add
return Frequency2Code(console.RX1FilterHigh,"SL");
default:
return Frequency2Code(console.RX1FilterLow,"SL");
}
}
else
{
return parser.Error1;
}
}
// Reads the S Meter value
public string SM(string s)
{
int sm = 0;
double sx = 0.0;
if(s == "0" || s == "2") // read the main transceiver s meter
{
float num = 0f;
if(console.PowerOn) num = DttSP.CalculateRXMeter(0, 0,DttSP.MeterType.SIGNAL_STRENGTH);
num = num+console.MultiMeterCalOffset+console.PreampOffset;
num = Math.Max(-140, num);
num = Math.Min(-10, num);
sx = (num+127)/6;
if(sx < 0) sx = 0;
if(sx <= 9.0F)
{
sm = Math.Abs((int)(sx * 1.6667));
}
else
{
double over_s9 = num + 73;
sm = 15 + (int) over_s9;
}
if(sm < 0) sm = 0;
if(sm > 30) sm = 30;
return sm.ToString().PadLeft(5,'0');
}
else
{
return parser.Error1;
}
}
// Sets or reads the Squelch value
public string SQ(string s)
{
string rx = s.Substring(0,1);
double level = 0.0;
//Will need code to select receiver when n Receivers enabled.
//for now, ignore rx number.
if(s.Length == parser.nSet)
//convert to a double and add the scale factor (160 = 255)
{
level = Convert.ToDouble(s.Substring(1));
level = Math.Max(0, level); // lower bound
level = Math.Min(255, level); // upper bound
level = level*0.62745; // scale factor
console.Squelch = Convert.ToInt32(Math.Round(level,0));
return "";
}
else if(s.Length == parser.nGet)
{
return rx+AddLeadingZeros(console.Squelch).Substring(1);
}
else
{
return parser.Error1;
}
}
// Sets the transmitter on, write only
// will eventually need eiter Commander change or ZZ code
// since it is not CAT compliant as it is
public string TX(string s)
{
console.CATPTT = true;
return "";
//return ZZTX("1");
}
//Moves the VFO A frequency up by the step size set on the console
public string UP()
{
// int step = console.StepSize;
// double[] wheel_tune_list;
// wheel_tune_list = new double[13]; // initialize wheel tuning list array
// wheel_tune_list[0] = 0.000001;
// wheel_tune_list[1] = 0.000010;
// wheel_tune_list[2] = 0.000050;
// wheel_tune_list[3] = 0.000100;
// wheel_tune_list[4] = 0.000250;
// wheel_tune_list[5] = 0.000500;
// wheel_tune_list[6] = 0.001000;
// wheel_tune_list[7] = 0.005000;
// wheel_tune_list[8] = 0.009000;
// wheel_tune_list[9] = 0.010000;
// wheel_tune_list[10] = 0.100000;
// wheel_tune_list[11] = 1.000000;
// wheel_tune_list[12] = 10.000000;
//
// console.VFOAFreq = console.VFOAFreq + wheel_tune_list[step];
// return "";
return ZZSB();
}
// Sets or reads the transceiver XIT status (on/off)
public string XT(string s)
{
// if(s.Length == parser.nSet)
// {
// if(s == "0")
// console.XITOn = false;
// else
// if(s == "1")
// console.XITOn = true;
// return "";
// }
// else if(s.Length == parser.nGet)
// {
// bool xit = console.XITOn;
// if(xit)
// return "1";
// else
// return "0";
// }
// else
// {
// return parser.Error1;
// }
return ZZXS(s);
}
#endregion Standard CAT Methods R-Z
#region Extended CAT Methods ZZA-ZZF
//Sets or reads the console step size (also see zzst(read only)
public string ZZAC(string s)
{
int step = 0;
if (s.Length == parser.nSet)
{
step = Convert.ToInt32(s);
if (step >= 0 || step <= 14)
{
console.TuneStepIndex = step;
return "";
}
else
return parser.Error1;
}
else if (s.Length == parser.nGet)
{
step = console.TuneStepIndex;
return AddLeadingZeros(step);
}
else
return parser.Error1;
}
//Sets VFO A down nn Tune Steps
public string ZZAD(string s)
{
int step = 0;
if (s.Length == parser.nSet)
{
step = Convert.ToInt32(s);
if (step >= 0 || step <= 14)
{
console.VFOAFreq = console.CATVFOA - Step2Freq(step);
return "";
}
else
return parser.Error1;
}
else
return parser.Error1;
}
// Sets or reads the SDR-1000 Audio Gain control
public string ZZAG(string s)
{
int af = 0;
if(s.Length == parser.nSet) // if the length of the parameter legal for setting this prefix
{
af = Convert.ToInt32(s);
af = Math.Max(0, af);
af = Math.Min(100, af);
console.AF = af; // Set the console control
return "";
}
else if(s.Length == parser.nGet) // if this is a read command
{
return AddLeadingZeros(console.AF); // Get the console setting
}
else
{
return parser.Error1; // return a ?
}
}
public string ZZAI(string s)
{
if(console.setupForm.AllowFreqBroadcast)
{
if(s.Length == parser.nSet)
{
if(s == "0")
console.KWAutoInformation = false;
else
console.KWAutoInformation = true;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.KWAutoInformation)
return "1";
else
return "0";
}
else
return parser.Error1;
}
else
return parser.Error1;
}
//Sets or reads the AGC RF gain
public string ZZAR(string s)
{
int n = 0;
int x = 0;
string sign;
if(s != "")
{
n = Convert.ToInt32(s);
n = Math.Max(-20, n);
n = Math.Min(120, n);
}
if(s.Length == parser.nSet)
{
console.RF = n;
return "";
}
else if(s.Length == parser.nGet)
{
x = console.RF;
if(x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign+AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
//Sets or reads the RX2 AGC-T
public string ZZAS(string s)
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
int n = 0;
int x = 0;
string sign;
if (s != "")
{
n = Convert.ToInt32(s);
n = Math.Max(-20, n);
n = Math.Min(120, n);
}
if (s.Length == parser.nSet)
{
console.RX2RF = n;
return "";
}
else if (s.Length == parser.nGet)
{
x = console.RX2RF;
if (x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
return parser.Error1;
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
//Sets VFO A up nn Tune Steps
public string ZZAU(string s)
{
int step = 0;
if (s.Length == parser.nSet)
{
step = Convert.ToInt32(s);
if (step >= 0 || step <= 14)
{
console.VFOAFreq = console.CATVFOA + Step2Freq(step);
return "";
}
else
return parser.Error1;
}
else
return parser.Error1;
}
//Moves the RX2 bandswitch down one band
public string ZZBA()
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
console.CATRX2BandUpDown(-1);
return "";
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
//Moves the RX2 bandswitch up one band
public string ZZBB()
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
console.CATRX2BandUpDown(1);
return "";
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
//Moves the RX1 bandswitch down one band
public string ZZBD()
{
BandDown();
return "";
}
// Sets the Band Group (HF/VHF)
public string ZZBG(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
console.CATBandGroup = Convert.ToInt32(s);
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATBandGroup.ToString();
}
else
{
return parser.Error1;
}
}
// Sets or reads the BIN button status
public string ZZBI(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
console.CATBIN = Convert.ToInt32(s);
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATBIN.ToString();
}
else
{
return parser.Error1;
}
}
//Sets VFO B down nn Tune Steps
public string ZZBM(string s)
{
int step = 0;
if (s.Length == parser.nSet)
{
step = Convert.ToInt32(s);
if (step >= 0 || step <= 14)
{
console.VFOBFreq = console.CATVFOB - Step2Freq(step);
return "";
}
else
return parser.Error1;
}
else
return parser.Error1;
}
//Sets VFO B up nn Tune Steps
public string ZZBP(string s)
{
int step = 0;
if (s.Length == parser.nSet)
{
step = Convert.ToInt32(s);
if (step >= 0 || step <= 14)
{
console.VFOBFreq = console.CATVFOB + Step2Freq(step);
return "";
}
else
return parser.Error1;
}
else
return parser.Error1;
}
//Sets or reads the BCI Rejection button status
public string ZZBR(string s)
{
if(console.CurrentModel == Model.SDR1000)
{
int sx = 0;
if(s != "")
sx = Convert.ToInt32(s);
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
console.CATBCIReject = sx;
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATBCIReject.ToString();
}
else
{
return parser.Error1;
}
}
else
return parser.Error1;
}
//Sets or reads the current band setting
public string ZZBS(string s)
{
return GetBand(s);
}
//Sets or gets the current RX2 band setting
public string ZZBT(string s)
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
if (s.Length == parser.nGet)
{
return Band2String(console.RX2Band);
}
else if (s.Length == parser.nSet)
{
console.RX2Band = String2Band(s);
return "";
}
else
return parser.Error1;
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
//Moves the bandswitch up one band
public string ZZBU()
{
BandUp();
return "";
}
//Shuts down the console
public string ZZBY()
{
this.console.Close();
return "";
}
// Sets or reads the CW Break In Enabled checkbox
public string ZZCB(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
if(s == "1")
console.BreakInEnabled = true;
else
console.BreakInEnabled = false;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.BreakInEnabled)
return "1";
else
return "0";
}
else
{
return parser.Error1;
}
}
// Sets or reads the CW Break In Delay
public string ZZCD(string s)
{
int n = 0;
if(s != null && s != "")
n = Convert.ToInt32(s);
n = Math.Max(150, n);
n = Math.Min(5000, n);
if(s.Length == parser.nSet)
{
console.setupForm.BreakInDelay = n;
return "";
}
else if(s.Length == parser.nGet)
{
return AddLeadingZeros((int) console.setupForm.BreakInDelay);
}
else
{
return parser.Error1;
}
}
// Sets or reads the Show CW Frequency checkbox
public string ZZCF(string s)
{
switch(console.RX1DSPMode)
{
case DSPMode.CWL:
case DSPMode.CWU:
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
if(s == "1")
console.ShowCWTXFreq = true;
else
console.ShowCWTXFreq = false;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.ShowCWTXFreq)
return "1";
else
return "0";
}
else
{
return parser.Error1;
}
default:
return parser.Error1;
}
}
// Sets or reads the CW Iambic checkbox
public string ZZCI(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
if(s == "1")
console.CWIambic = true;
else
console.CWIambic = false;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.CWIambic)
return "1";
else
return "0";
}
else
{
return parser.Error1;
}
}
// Sets or reads the CW Pitch thumbwheel
public string ZZCL(string s)
{
int n = 0;
if(s != "")
n = Convert.ToInt32(s);
if(s.Length == parser.nSet)
{
console.setupForm.CATCWPitch = n;
return "";
}
else if(s.Length == parser.nGet)
{
return AddLeadingZeros(console.setupForm.CATCWPitch);
}
else
{
return parser.Error1;
}
}
// Sets or reads the CW Monitor Disable button status
public string ZZCM(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
if(s == "1")
console.CWSidetone = false;
else
console.CWSidetone = true;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.CWSidetone)
return "0";
else
return "1";
}
else
{
return parser.Error1;
}
}
// Sets or reads the compander button status
public string ZZCP(string s)
{
if(s.Length == parser.nSet)
{
if(s == "0")
console.CATCmpd = 0;
else if(s == "1")
console.CATCmpd = 1;
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATCmpd.ToString();
}
else
{
return parser.Error1;
}
}
// Sets or reads the CW Speed thumbwheel
public string ZZCS(string s)
{
int n = 1;
if(s != "")
n = Convert.ToInt32(s);
if(s.Length == parser.nSet)
{
console.CATCWSpeed = n;
return "";
}
else if(s.Length == parser.nGet)
{
return AddLeadingZeros(console.CATCWSpeed);
}
else
{
return parser.Error1;
}
}
//Reads or sets the compander threshold
public string ZZCT(string s)
{
int n = 0;
if(s != null && s != "")
n = Convert.ToInt32(s);
n = Math.Max(0, n);
n = Math.Min(10, n);
if(s.Length == parser.nSet)
{
console.CPDRVal = n;
return "";
}
else if(s.Length == parser.nGet)
{
return AddLeadingZeros((int) console.CPDRVal);
}
else
{
return parser.Error1;
}
}
// Reads the CPU Usage
public string ZZCU()
{
return console.CpuUsage.ToString("f").PadLeft(6,'0');
}
// Sets or reads the Display Average status
public string ZZDA(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
console.CATDisplayAvg = Convert.ToInt32(s);
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATDisplayAvg.ToString();
}
else
{
return parser.Error1;
}
}
//Sets or reads the Diversity Form Enable Button
public string ZZDE(string s)
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK && console.CATDiversityForm)
{
if (s.Length == parser.nSet)
{
if (s == "1")
{
console.CATDiversityEnable = true;
return "";
}
else if (s == "0")
{
console.CATDiversityEnable = false;
return "";
}
else
return parser.Error1;
}
else if (s.Length == parser.nGet)
{
if (console.CATDiversityEnable)
return "1";
else
return "0";
}
else
return parser.Error1;
}
else
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
parser.Verbose_Error_Code = 8;
else
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
//Opens or closes the Diversity Form
public string ZZDF(string s)
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
if (s.Length == parser.nSet)
{
if (s == "1")
{
console.CATDiversityForm = true;
return "";
}
else if (s == "0")
{
console.CATDiversityForm = false;
return "";
}
else
return parser.Error1;
}
else if (s.Length == parser.nGet)
{
if (console.CATDiversityForm)
return "1";
else
return "0";
}
else
return parser.Error1;
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
// Sets or reads the current display mode
public string ZZDM(string s)
{
int n = -1;
// PANADAPTER,
// PANAFALL,
// WATERFALL,
// PANASCOPE,
// SPECTRUM,
//SCOPE,
//PHASE,
//PHASE2,
// HISTOGRAM,
// OFF,
// CONTINUUM,
if (s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
switch(n)
{
case 0:
console.DisplayModeText = "Spectrum";
break;
case 1:
console.DisplayModeText = "Panadapter";
break;
case 2:
console.DisplayModeText = "Scope";
break;
case 3:
console.DisplayModeText = "Phase";
break;
case 4:
console.DisplayModeText = "Phase2";
break;
case 5:
console.DisplayModeText = "Waterfall";
break;
case 6:
console.DisplayModeText = "Histogram";
break;
case 7:
console.DisplayModeText = "Panafall";
break;
case 8:
console.DisplayModeText = "Panascope";
break;
case 9:
console.DisplayModeText = "Off";
break;
case 10:
console.DisplayModeText = "Continuum";
break;
}
// if(n > (int) DisplayMode.FIRST && n < (int) DisplayMode.LAST)
// Display.CurrentDisplayMode = (DisplayMode) n;
// else
// return parser.Error1;
//
return "";
}
else if(s.Length == parser.nGet)
{
return ((int) Display.CurrentDisplayMode).ToString();
}
else
{
return parser.Error1;
}
} // ZZDM
//Reads or sets the setup form Waterfall Low value
public string ZZDN(string s)
{
int n = 0;
int x = 0;
string sign;
if (s != "")
n = Convert.ToInt32(s);
if (s.Length == parser.nSet)
{
console.setupForm.CATWFLo = n;
return "";
}
else if (s.Length == parser.nGet)
{
x = console.setupForm.CATWFLo;
if (x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
//Reads or sets the setup form Waterfall High value
public string ZZDO(string s)
{
int n = 0;
int x = 0;
string sign;
if (s != "")
n = Convert.ToInt32(s);
if (s.Length == parser.nSet)
{
console.setupForm.CATWFHi = n;
return "";
}
else if (s.Length == parser.nGet)
{
x = console.setupForm.CATWFHi;
if (x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
//Reads or sets the setup form Spectrum Grid Max Value
public string ZZDP(string s)
{
int n = 0;
int x = 0;
string sign;
if (s != "")
n = Convert.ToInt32(s);
if (s.Length == parser.nSet)
{
console.setupForm.CATSGMax = n;
return "";
}
else if (s.Length == parser.nGet)
{
x = console.setupForm.CATSGMax;
if (x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
//Reads or sets the setup form Spectrum Grid Min Value
public string ZZDQ(string s)
{
int n = 0;
int x = 0;
string sign;
if (s != "")
n = Convert.ToInt32(s);
if (s.Length == parser.nSet)
{
console.setupForm.CATSGMin = n;
return "";
}
else if (s.Length == parser.nGet)
{
x = console.setupForm.CATSGMin;
if (x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
// Sets or reads the Spectrum Grid Step
public string ZZDR(string s)
{
if (s.Length == parser.nSet)
{
console.setupForm.CATSGStep = Convert.ToInt32(s);
return "";
}
else if (s.Length == parser.nGet)
{
return AddLeadingZeros(console.setupForm.CATSGStep);
}
else
{
return parser.Error1;
}
}
//Constructs the state word for DDUtil
//read only
public string ZZDU()
{
int old = parser.nAns;
string sep = ":";
string status = "";
parser.nAns = 1;
status += ZZSW("") + sep;
status += ZZSP("") + sep;
status += ZZTU("") + sep;
status += ZZTX("") + sep;
if (console.CurrentModel == Model.FLEX5000)
{
status += ZZOA("") + sep;
if (FWCEEPROM.RX2OK)
status += ZZOB("") + sep;
else
status += "0:";
status += ZZOC("") + sep;
if (FWCEEPROM.RX2OK)
status += ZZRS("") + sep;
else
status += "0:";
}
else
status += "0:0:0:0:";
if (FWCEEPROM.RX2OK)
status += ZZRT("") + sep;
else
status += "0:";
status += ZZDM("") + sep;
status += ZZGT("") + sep;
status += ZZMU("") + sep;
status += ZZXS("") + sep;
parser.nAns = 2;
status += ZZAC("") + sep;
status += ZZMD("") + sep;
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
status += ZZME("") + sep;
status += ZZFJ("") + sep;
}
else
status += "00:00:";
status += ZZFI("")+ sep;
parser.nAns = 3;
if (console.CurrentModel == Model.FLEX5000)
{
status += ZZOF("") + sep;
if (FWCEEPROM.RX2OK)
status += ZZBT("") + sep;
else
status += "000:";
}
else
status += "000:000:";
status += ZZPC("") + sep;
status += ZZBS("") + sep;
status += ZZAG("") + sep;
status += ZZKS("") + sep;
status += ZZTO("") + sep;
parser.nAns = 4;
if (console.CurrentModel == Model.FLEX5000 || console.CurrentModel == Model.FLEX3000)
status += ZZRV() + sep;
else
status += "0000:";
status += ZZSM("0") + sep;
parser.nAns = 5;
status += ZZRF("") + sep;
if (console.CurrentModel == Model.FLEX5000 || console.CurrentModel == Model.FLEX3000)
status += ZZTS() + sep;
else
status += "00000:";
status += ZZXF("") + sep;
parser.nAns = 6;
status += ZZCU() + sep;
parser.nAns = 11;
status += ZZFA("") + sep;
status += ZZFB("");
parser.nAns = old;
return status;
}
/// <summary>
/// Sets or reads the DX button status
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZDX(string s)
{
if(s.Length == parser.nSet)
{
console.CATPhoneDX = s;
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATPhoneDX;
}
else
return parser.Error1;
}
//Reads or sets the DX threshold
public string ZZDY(string s)
{
int n = 0;
if (s != null && s != "")
n = Convert.ToInt32(s);
n = Math.Max(0, n);
n = Math.Min(10, n);
if (s.Length == parser.nSet)
{
console.DXLevel = n;
return "";
}
else if (s.Length == parser.nGet)
{
return AddLeadingZeros((int)console.DXLevel);
}
else
{
return parser.Error1;
}
}
/// <summary>
/// Reads or sets the RX equalizer.
/// The CAT suffix string is 36 characters constant.
/// Each value in the string occupies exactly three characters
/// starting with the number of bands (003 or 010) followed by
/// the preamp setting (-12 to 015) followed by 3 or 10 three digit
/// EQ thumbwheel positions. If the number of bands is 3, the
/// last seven positions (21 characters) are all set to zero.
/// Example: 10 band ZZEA010-09009005000-04-07-09-05000005009;
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZEA(string s)
{
if(s.Length == parser.nSet)
{
int nb = Int32.Parse(s.Substring(0,3)); //Get the number of bands
int[] ans = new int[nb+1]; //Create the integer array
s = s.Remove(0,3); //Get rid of the band count
for(int x = 0; x <= nb;x++) //Parse the string into the array
{
ans[x] = Int32.Parse(s.Substring(0,3));
s = s.Remove(0,3); //Remove the last three used
}
console.eqForm.RXEQ = ans; //Send the array to the eq form
return "";
}
else if(s.Length == parser.nGet)
{
int[] eqarray = console.eqForm.RXEQ; //Get the equalizer array
int nb = console.eqForm.NumBands; //Get the number of bands in the array
int val; //Holds a temporary value
string ans = nb.ToString().PadLeft(3,'0'); //The return string with the number of bands added
for (int x = 0; x <= nb; x++) //Loop thru the array
{
if(eqarray[x] < 0)
{
val = Math.Abs(eqarray[x]); //If the value is negative, format the answer
ans += "-"+val.ToString().PadLeft(2,'0');
}
else
ans += eqarray[x].ToString().PadLeft(3,'0');
}
ans = ans.PadRight(36,'0'); //Add the padding if it's a 3 band eq
return ans;
}
else
return parser.Error1;
}
//Sets or reads the TX EQ settings
public string ZZEB(string s)
{
if(s.Length == parser.nSet)
{
int nb = Int32.Parse(s.Substring(0,3)); //Get the number of bands
int[] ans = new int[nb+1]; //Create the integer array
s = s.Remove(0,3); //Get rid of the band count
for(int x = 0; x <= nb;x++) //Parse the string into the array
{
ans[x] = Int32.Parse(s.Substring(0,3));
s = s.Remove(0,3); //Remove the last three used
}
console.eqForm.TXEQ = ans; //Send the array to the eq form
return "";
}
else if(s.Length == parser.nGet)
{
int[] eqarray = console.eqForm.TXEQ; //Get the equalizer array
int nb = console.eqForm.NumBands; //Get the number of bands in the array
int val; //Holds a temporary value
string ans = nb.ToString().PadLeft(3,'0'); //The return string with the number of bands added
for (int x = 0; x <= nb; x++) //Loop thru the array
{
if(eqarray[x] < 0)
{
val = Math.Abs(eqarray[x]); //If the value is negative, format the answer
ans += "-"+val.ToString().PadLeft(2,'0');
}
else
ans += eqarray[x].ToString().PadLeft(3,'0');
}
ans = ans.PadRight(36,'0'); //Add the padding if it's a 3 band eq
return ans;
}
else
return parser.Error1;
}
//Provides verbose CAT error reporting
public string ZZEM(string s)
{
if (s.Length == parser.nSet && (s == "1" || s == "0"))
{
if (s == "1")
parser.Verbose = true;
else
parser.Verbose = false;
return "";
}
else if (s.Length == parser.nGet)
{
if (parser.Verbose)
return "1";
else
return "0";
}
else
return parser.Error1;
}
//Sets or reads the RXEQ button statusl
public string ZZER(string s)
{
if(s.Length == parser.nSet && (s == "1" || s == "0"))
{
if(s == "1")
console.CATRXEQ = "1";
else if(s == "0")
console.CATRXEQ = "0";
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATRXEQ;
}
else
return parser.Error1;
}
//Sets or reads the TXEQ button status
public string ZZET(string s)
{
if(s.Length == parser.nSet && (s == "1" || s == "0"))
{
if(s == "1")
console.CATTXEQ = "1";
else if(s == "0")
console.CATTXEQ = "0";
return "";
}
else if(s.Length == parser.nGet)
{
return console.CATTXEQ;
}
else
return parser.Error1;
}
//Sets or reads VFO A frequency
public string ZZFA(string s)
{
if(s.Length == parser.nSet)
{
if(console.setupForm.RttyOffsetEnabledA &&
(console.RX1DSPMode == DSPMode.DIGU || console.RX1DSPMode == DSPMode.DIGL))
{
int f = int.Parse(s);
if(console.RX1DSPMode == DSPMode.DIGU)
f = f - Convert.ToInt32(console.setupForm.RttyOffsetHigh);
else if(console.RX1DSPMode == DSPMode.DIGL)
f = f + Convert.ToInt32(console.setupForm.RttyOffsetLow);
s = AddLeadingZeros(f);
s = s.Insert(5, separator);
}
else
s = s.Insert(5, separator);
console.VFOAFreq = double.Parse(s);
return "";
}
else if(s.Length == parser.nGet)
{
if(console.setupForm.RttyOffsetEnabledA &&
(console.RX1DSPMode == DSPMode.DIGU || console.RX1DSPMode == DSPMode.DIGL))
{
int f = Convert.ToInt32(Math.Round(console.CATVFOA, 6) * 1e6);
if(console.RX1DSPMode == DSPMode.DIGU)
f = f + Convert.ToInt32(console.setupForm.RttyOffsetHigh);
else if(console.RX1DSPMode == DSPMode.DIGL)
f = f - Convert.ToInt32(console.setupForm.RttyOffsetLow);
return AddLeadingZeros(f);
}
else
return StrVFOFreq("A");
}
else
return parser.Error1;
}
//Sets or reads VFO B frequency
public string ZZFB(string s)
{
if(s.Length == parser.nSet)
{
if(console.setupForm.RttyOffsetEnabledB &&
(console.RX1DSPMode == DSPMode.DIGU || console.RX1DSPMode == DSPMode.DIGL))
{
int f = int.Parse(s);
if(console.RX1DSPMode == DSPMode.DIGU)
f = f - Convert.ToInt32(console.setupForm.RttyOffsetHigh);
else if(console.RX1DSPMode == DSPMode.DIGL)
f = f + Convert.ToInt32(console.setupForm.RttyOffsetLow);
s = AddLeadingZeros(f);
s = s.Insert(5, separator);
}
else
s = s.Insert(5, separator);
console.VFOBFreq = double.Parse(s);
return "";
}
else if(s.Length == parser.nGet)
{
if(console.setupForm.RttyOffsetEnabledB &&
(console.RX1DSPMode == DSPMode.DIGU || console.RX1DSPMode == DSPMode.DIGL))
{
int f = Convert.ToInt32(Math.Round(console.CATVFOB, 6) * 1e6);
if(console.RX1DSPMode == DSPMode.DIGU)
f = f + Convert.ToInt32(console.setupForm.RttyOffsetHigh);
else if(console.RX1DSPMode == DSPMode.DIGL)
f = f - Convert.ToInt32(console.setupForm.RttyOffsetLow);
return AddLeadingZeros(f);
}
else
return StrVFOFreq("B");
}
else
return parser.Error1;
}
//Selects or reads the FM deviation radio button
public string ZZFD(string s)
{
if (s.Length == parser.nSet)
{
if (s == "1")
console.FMDeviation_Hz = 5000;
else
console.FMDeviation_Hz = 2500;
return "";
}
else if (s.Length == parser.nGet)
{
if (console.FMDeviation_Hz == 5000)
return "1";
else if (console.FMDeviation_Hz == 2500)
return "0";
else
return parser.Error1;
}
else
return parser.Error1;
}
//Sets or reads the current filter index number
public string ZZFI(string s)
{
int n = 0;
if(s != "")
n = Convert.ToInt32(s);
if(s.Length == parser.nSet)
{
if(n < (int) Filter.LAST)
console.RX1Filter = (Filter) n;
else
return parser.Error1;
return "";
}
else if(s.Length == parser.nGet)
{
return AddLeadingZeros((int) console.RX1Filter);
}
else
{
return parser.Error1;
}
}
//Sets or reads the current RX2 DSP filter
public string ZZFJ(string s)
{
if (console.CurrentModel == Model.FLEX5000 && FWCEEPROM.RX2OK)
{
int n = 0;
if (s != "")
n = Convert.ToInt32(s);
if (s.Length == parser.nSet)
{
if (n < (int)Filter.LAST)
console.RX2Filter = (Filter)n;
else
return parser.Error1;
return "";
}
else if (s.Length == parser.nGet)
{
return AddLeadingZeros((int)console.RX2Filter);
}
else
return parser.Error1;
}
else
{
parser.Verbose_Error_Code = 7;
return parser.Error1;
}
}
/// <summary>
/// Reads or sets the DSP Filter Low value
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZFL(string s)
{
string sign;
int n;
if(s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
n = Math.Min(9999, n);
n = Math.Max(-9999, n);
console.RX1FilterLow = n;
console.UpdateRX1Filters(n, console.RX1FilterHigh);
return "";
}
else if(s.Length == parser.nGet)
{
n = console.RX1FilterLow;
if(n < 0)
sign = "-";
else
sign = "+";
// we have to remove the leading zero and replace it with the sign.
return sign+AddLeadingZeros(Math.Abs(n)).Substring(1);
// return AddLeadingZeros((int) console.RX1FilterLow);
}
else
return parser.Error1;
}
/// <summary>
/// Reads or sets the RX1 DSP Filter High value
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZFH(string s)
{
string sign;
int n;
if(s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
n = Math.Min(9999, n);
n = Math.Max(-9999, n);
console.RX1FilterHigh = n;
console.UpdateRX1Filters(console.RX1FilterLow, n);
return "";
}
else if(s.Length == parser.nGet)
{
n = console.RX1FilterHigh;
if(n < 0)
sign = "-";
else
sign = "+";
// we have to remove the leading zero and replace it with the sign.
return sign+AddLeadingZeros(Math.Abs(n)).Substring(1);
}
else
return parser.Error1;
}
public string ZZFM()
{
string radio = console.CurrentModel.ToString();
if (radio == "SDR1000")
return "0";
else if (radio == "FLEX5000")
return "1";
else if (radio == "FLEX3000")
return "2";
else if (radio == "FLEX1500")
return "3";
else
{
return parser.Error1;
}
}
/// <summary>
/// Reads or sets the RX2 DSP Filter High value
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZFR(string s)
{
string sign;
int n;
if (s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
n = Math.Min(9999, n);
n = Math.Max(-9999, n);
console.RX2FilterHigh = n;
console.UpdateRX2Filters(console.RX2FilterLow, n);
return "";
}
else if (s.Length == parser.nGet)
{
n = console.RX2FilterHigh;
if (n < 0)
sign = "-";
else
sign = "+";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(n)).Substring(1);
}
else
return parser.Error1;
}
/// <summary>
/// Reads or sets the RX2 DSP Filter Low value
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public string ZZFS(string s)
{
string sign;
int n;
if (s.Length == parser.nSet)
{
n = Convert.ToInt32(s);
n = Math.Min(9999, n);
n = Math.Max(-9999, n);
console.RX2FilterLow = n;
console.UpdateRX2Filters(n, console.RX2FilterHigh);
return "";
}
else if (s.Length == parser.nGet)
{
n = console.RX2FilterLow;
if (n < 0)
sign = "-";
else
sign = "+";
// we have to remove the leading zero and replace it with the sign.
return sign + AddLeadingZeros(Math.Abs(n)).Substring(1);
}
else
return parser.Error1;
}
//Reads FlexWire single byte value commands
public string ZZFV(string s)
{
if(s.Length == parser.nGet)
{
String pattern = "^[a-fA-F0-9][a-fA-F0-9]$";
Regex sfxpattern = new Regex(pattern);
if(!sfxpattern.IsMatch(s))
return parser.Error1;
byte addr = byte.Parse(s, NumberStyles.HexNumber);
uint val;
FWC.FlexWire_ReadValue(addr, out val);
string ans = String.Format("{0:X2}", (byte)val);
return ans;
}
else
return parser.Error1;
}
//Reds FlexWire double byte value commands
public string ZZFW(String s)
{
if(s.Length == parser.nGet)
{
String pattern = "^[a-fA-F0-9][a-fA-F0-9]$";
Regex sfxpattern = new Regex(pattern);
if(!sfxpattern.IsMatch(s))
return parser.Error1;
byte addr = byte.Parse(s, NumberStyles.HexNumber);
uint val;
FWC.FlexWire_Read2Value(addr, out val);
string ans1 = String.Format("{0:X2}", val>>8);
string ans2 = String.Format("{0:X2}", (byte) val);
string ans = String.Concat(ans1,ans2);
return ans;
}
else
return parser.Error1;
}
//Sends FlexWire single byte value commands
public string ZZFX(string s)
{
if(s.Length == parser.nSet)
{
String pattern = "^[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]$";
Regex sfxpattern = new Regex(pattern);
if(!sfxpattern.IsMatch(s))
return parser.Error1;
byte addr = byte.Parse(s.Substring(0,2),NumberStyles.HexNumber);
byte val = byte.Parse(s.Substring(2,2),NumberStyles.HexNumber);
FWC.FlexWire_WriteValue(addr, val);
return "";
}
else
return parser.Error1;
}
//Sends FlexWire double byte value commands
public string ZZFY(String s)
{
if(s.Length == parser.nSet)
{
String pattern = "^[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]$";
Regex sfxpattern = new Regex(pattern);
if(!sfxpattern.IsMatch(s))
return parser.Error1;
byte addr = byte.Parse(s.Substring(0,2), NumberStyles.HexNumber);
byte val1 = byte.Parse(s.Substring(2,2), NumberStyles.HexNumber);
byte val2 = byte.Parse(s.Substring(4,2), NumberStyles.HexNumber);
FWC.FlexWire_Write2Value(addr, val1, val2);
return "";
}
else
return parser.Error1;
}
#endregion Extended CAT Methods ZZA-ZZF
#region Extended CAT Methods ZZG-ZZM
// Sets or reads the noise gate enable button status
public string ZZGE(string s)
{
if(s.Length == parser.nSet && (s == "0" || s == "1"))
{
if(s == "1")
console.NoiseGateEnabled = true;
else
console.NoiseGateEnabled = false;
return "";
}
else if(s.Length == parser.nGet)
{
if(console.NoiseGateEnabled)
return "1";
else
return "0";
}
else
{
return parser.Error1;
}
}
//Sets or reads the noise gate level control
public string ZZGL(string s)
{
int n = 0;
int x = 0;
string sign;
if(s != "")
{
n = Convert.ToInt32(s);
n = Math.Max(-160, n);
n = Math.Min(0, n);
}
if(s.Length == parser.nSet)
{
console.NoiseGate = n;
return "";
}
else if(s.Length == parser.nGet)
{
x = console.NoiseGate;
if(x >= 0)
sign = "+";
else
sign = "-";
// we have to remove the leading zero and replace it with the sign.
return sign+AddLeadingZeros(Math.Abs(x)).Substring(1);
}
else
{
return parser.Error1;
}
}
// Sets or reads the AGC constant
public string ZZGT(string s)
{
if(s.Length == parser.nSet)
{
if((Convert.ToInt32(s) > (int) AGCMode.FIRST && Convert.ToInt32(s) < (int) AGCMode.LAST))
console.RX1AGCMode = (AGCMode) Convert.ToInt32(s);
else
return parser.Error1;
return "";
}
else if(s.Length == parser.nGet)
{
return ((int) console.RX1AGCMode).ToString();
}
else
{
return parser.Error1;
}
}
// Sets or reads the Audio Buffer Size
public string ZZHA(string s)
{
if(s.Length == parser.nSet)
{
console.setupForm.AudioBufferSize = Index2Width(s);
return "";
}
else if (s.Length == parser.nGet)
{
return Width2Index(console.setupForm.AudioBufferSize);
}
else
return parser.Error1;
}
//Sets or reads the DSP Phone RX Buffer Size
public string ZZHR(string s)
{
if(s.Length == parser.nSet)
{
int width = Index2Width(s);
console.DSPBufPhoneRX = width;
console.setupForm.DSPPhoneRXBuffer = width;
return "";
}
else if(s.Length == parser.nGet)
{
return Width2Index(console.DSPBufPhoneRX);
}
else
return parser.Error1;
}
//Sets or reads the DSP Phone TX Buffer Size
public string ZZHT(string s)
{
if(s.Length == parser.nSet)
{
int width = Index2Width(s);
console.DSPBufPhoneTX = width;
console.setupForm.DSPPhoneTXBuffer = width;
return "";
}
else if(s.Length == parser.nGet)
{
return Width2Index(console.DSPBufPhoneTX);
}
else
return parser.Error1;
}
//Sets or reads the DSP CW RX Buffer Size
public string ZZHU(string s)
{
if(