90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Project.Dialog
|
|
{
|
|
public partial class fXbeeSetting : Form
|
|
{
|
|
public fXbeeSetting()
|
|
{
|
|
InitializeComponent();
|
|
PUB.logxbee.RaiseMsg += Log_RaiseMsgcal;
|
|
}
|
|
private void fXbeeSetting_Load(object sender, EventArgs e)
|
|
{
|
|
this.tbPortName.Items.Clear();
|
|
foreach (var item in System.IO.Ports.SerialPort.GetPortNames())
|
|
{
|
|
this.tbPortName.Items.Add(item);
|
|
}
|
|
|
|
this.tbPortName.Text = PUB.setting.Port_XBE;
|
|
this.tbBaud.Text = PUB.setting.Baud_XBE.ToString();
|
|
}
|
|
private void Log_RaiseMsgcal(DateTime LogTime, string TypeStr, string Message)
|
|
{
|
|
showlog(rtXbee, LogTime, TypeStr, Message);
|
|
}
|
|
void showlog(arCtl.LogTextBox rtRx, DateTime LogTime, string TypeStr, string Message)
|
|
{
|
|
if (rtRx.Visible)
|
|
{
|
|
rtRx.AddMsg(LogTime, TypeStr, Message);
|
|
}
|
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (PUB.XBE.IsOpen)
|
|
PUB.XBE.Close();
|
|
else
|
|
{
|
|
PUB.XBE.PortName = tbPortName.Text;
|
|
PUB.XBE.Open();
|
|
}
|
|
}
|
|
|
|
private void fXbeeSetting_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
PUB.logxbee.RaiseMsg -= Log_RaiseMsgcal;
|
|
}
|
|
|
|
private void btpand_Click(object sender, EventArgs e)
|
|
{
|
|
var cmds = new string[] {
|
|
"+++",
|
|
$"ATID{tbpanid.Text}\r" ,
|
|
$"ATCN"};
|
|
|
|
}
|
|
|
|
private void btch_Click(object sender, EventArgs e)
|
|
{
|
|
var cmds = new string[] {
|
|
"+++",
|
|
$"ATCH{tbch.Text}\r" ,
|
|
$"ATCN"};
|
|
}
|
|
|
|
private void btmy_Click(object sender, EventArgs e)
|
|
{
|
|
var cmds = new string[] {
|
|
"+++",
|
|
$"ATMY{tbmy.Text}\r" ,
|
|
$"ATCN"};
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
//read all(id,ch,my)
|
|
|
|
}
|
|
}
|
|
}
|