少しだけコーディングしてみた。 実際始めると、いろいろ出てくる。 まず、最初想定していたパラメータを書き込んだファイルを編集するソフト、とりあえずは必要なさそう。 保存したい情報は、COMポート番号と周波数の情報なので、編集ソフトなんか作らなくても、テキストエディタで直接編集できる。
大抵の部分は以前に作成しているけど、全く忘れてしまっているので思い出しながら・・というか、前のソースを解読しながら修正しているような状態。
とりあえず作成したソース。 デバッグしてないので、たぶんバグだらけ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
namespace FT991ACon22 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //state variables int st_mode; // 0:CW, 1:SSB, 2:FM int st_preamp; // 0:IPO, 1:AMP1, 2:AMP2 bool st_att, st_fast, st_bk_in; // true:ON, false:OFF int st_band; // 0:1.9, 1:3.5, 2:7, 3:10, 4:14, 5:18, 6:21, 7:24, 8:28, 9:50, 10:144, 11:430 //write to serialport private void spwrite(string command) { try { serialPort1.WriteLine(command); } catch (TimeoutException) //need to set write timeout property of serialport { MessageBox.Show("Timeout"); } } //read from serialport private string spread() { string buff = ""; try { buff = serialPort1.ReadLine(); } catch (TimeoutException) //need to set read timeout property of serialport { MessageBox.Show("Timeout"); } return buff; } private void Form1_Load(object sender, EventArgs e) { //SerialPort Open try { serialPort1.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); Application.Exit(); } //check connection spwrite("ID"); if(spread() != "0570") { MessageBox.Show("Can't connect FT-991A"); Application.Exit(); } serialPort1.NewLine = ";"; //Get initial status of FT-991A } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { serialPort1.Close(); } } } |
シリアルポートがなかったり、FT-991Aと通信できない場合は、エラーメッセージが出てプログラムが終了する。 パラメータファイルをテキストエディタで修正して再起動するという仕様。
状態変数は、とりあえず頻繁に変更したいものだけ。
外観はこんな感じ。 以前作成したものと、ほぼ同じだけどFT8の切り替えは削除した。 FT8は、WSJT-Xの方でコントロールするので、FT8用のパラメータをクリック一つで設定するプログラムを別に作成する予定。