Преглед изворни кода

2021-12-29-增加“调试界面”;增加DIO控制与JSY模拟采集的类;增加内部电源控制类;增加计算机GPIO控制类

pc пре 3 година
родитељ
комит
6083903bd0

BIN
exe/apps/Tps_LQ_Transmitter/SeeSharpTools.JY.GUI.dll


Разлика између датотеке није приказан због своје велике величине
+ 8058 - 0
exe/apps/Tps_LQ_Transmitter/SeeSharpTools.JY.GUI.xml


BIN
exe/apps/Tps_LQ_Transmitter/Tps_LQ_Transmitter.dll


BIN
exe/apps/Tps_LQ_Transmitter/Tps_LQ_Transmitter.pdb



BIN
tps/TpsLabStudio/.vs/TpsLabStudio/v16/.suo


Разлика између датотеке није приказан због своје велике величине
+ 1615 - 0
tps/TpsLabStudio/DebuggingForm.Designer.cs


+ 645 - 0
tps/TpsLabStudio/DebuggingForm.cs

@@ -0,0 +1,645 @@
+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;
+using System.IO.Ports;
+using Tps_LQ_Transmitter.com;
+using System.Threading;
+
+namespace Tps_LQ_Transmitter
+{
+    /// <summary>
+    /// 调试界面
+    /// </summary>
+    public partial class DebuggingForm : Form
+    {
+        DioControlClass dio = new DioControlClass();
+        PcGpio gpio = new PcGpio();
+        RainwormPower power = new RainwormPower();
+
+        public DebuggingForm()
+        {
+            InitializeComponent();
+            gpio.InitSetOut();
+            Thread.Sleep(100);
+            gpio.SwitchControl(0);
+            for (int i = 1; i <= 8; i++)
+            {
+                dio.SupplySwitch(i, DioControlClass.State.OFF);//将所有供电开关关闭
+            }
+            power.powerOnoff(RainwormPower.State.OFF);
+            
+        }
+        private void DebuggingForm_FormClosed(object sender, FormClosedEventArgs e)
+        {
+            dio.portClose();
+            power.portClose();
+            
+            
+        }
+
+
+        #region 8路供电开关控制(+28V)代码
+        private void btnPowCh_1_Click(object sender, EventArgs e)
+        {
+            if (led1.Value == false)
+            {
+                dio.SupplySwitch(1, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(1, DioControlClass.State.OFF);
+            }
+            led1.Value = !led1.Value;
+        }
+
+        private void btnPowCh_2_Click(object sender, EventArgs e)
+        {
+           
+            if (led2.Value == false)
+            {
+                dio.SupplySwitch(2, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(2, DioControlClass.State.OFF);
+            }
+            led2.Value = !led2.Value;
+        }
+
+        private void btnPowCh_3_Click(object sender, EventArgs e)
+        {
+            if (led3.Value == false)
+            {
+                dio.SupplySwitch(3, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(3, DioControlClass.State.OFF);
+            }
+            led3.Value = !led3.Value;
+        }
+
+        private void btnPowCh_4_Click(object sender, EventArgs e)
+        {
+            if (led4.Value == false)
+            {
+                dio.SupplySwitch(4, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(4, DioControlClass.State.OFF);
+            }
+            led4.Value = !led4.Value;
+        }
+
+        private void btnPowCh_5_Click(object sender, EventArgs e)
+        {
+            if (led5.Value == false)
+            {
+                dio.SupplySwitch(5, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(5, DioControlClass.State.OFF);
+            }
+            led5.Value = !led5.Value;
+        }
+
+        private void btnPowCh_6_Click(object sender, EventArgs e)
+        {
+            if (led6.Value == false)
+            {
+                dio.SupplySwitch(6, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(6, DioControlClass.State.OFF);
+            }
+            led6.Value = !led6.Value;
+        }
+
+        private void btnPowCh_7_Click(object sender, EventArgs e)
+        {
+            if (led7.Value == false)
+            {
+                dio.SupplySwitch(7, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(7, DioControlClass.State.OFF);
+            }
+            led7.Value = !led7.Value;
+        }
+
+        private void btnPowCh_8_Click(object sender, EventArgs e)
+        {
+            if (led8.Value == false)
+            {
+                dio.SupplySwitch(8, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.SupplySwitch(8, DioControlClass.State.OFF);
+            }
+            led8.Value = !led8.Value;
+        }
+        #endregion
+
+
+        /// <summary>
+        /// byte[]数据转字符串输出
+        /// </summary>
+        /// <param name="data">byte[]数据</param>
+        /// <returns>字符串</returns>
+        public string BytesToHexString(byte[] data)
+        {
+            if (data == null)
+                return "";
+
+            StringBuilder sb = new StringBuilder(100);
+            for (int i = 0; i < data.Length; i++)
+            {
+                sb.Append("0x" + data[i].ToString("X2") + " ");
+            }
+            return sb.ToString();
+        }
+
+        #region JSY电压电流模拟量采集模块读取代码
+        /// <summary>
+        /// 点击"读取"按钮执行模拟量(电压、电流)采集
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnOther_Click(object sender, EventArgs e)
+        {
+            double[] dblv = new double[8];
+            double[] dblc = new double[8];
+            double[] dblp = new double[8];
+            string st="";
+            dblv = dio.ReadAllVolt();
+            dblc = dio.ReadAllCurr();
+            dblp = dio.ReadAllPower();
+            txtbVoltCh_1.Text = dblv[0].ToString();
+            txtbCurrCh_1.Text = dblc[0].ToString();
+            
+            txtbVoltCh_2.Text = dblv[1].ToString();
+            txtbCurrCh_2.Text = dblc[1].ToString();
+            
+            txtbVoltCh_3.Text = dblv[2].ToString();
+            txtbCurrCh_3.Text = dblc[2].ToString();
+            
+            txtbVoltCh_4.Text = dblv[3].ToString();
+            txtbCurrCh_4.Text = dblc[3].ToString();
+            
+            txtbVoltCh_5.Text = dblv[4].ToString();
+            txtbCurrCh_5.Text = dblc[4].ToString();
+            
+            txtbVoltCh_6.Text = dblv[5].ToString();
+            txtbCurrCh_6.Text = dblc[5].ToString();
+            
+            txtbVoltCh_7.Text = dblv[6].ToString();
+            txtbCurrCh_7.Text = dblc[6].ToString();
+            
+            txtbVoltCh_8.Text = dblv[7].ToString();
+            txtbCurrCh_8.Text = dblc[7].ToString();
+            for (int i = 0; i < 8; i++)
+            {
+                st += dblp[0].ToString()+";";
+            }
+            txtbMsg.Text ="供电功率:"+ st;
+        }
+        #endregion
+
+        #region 射频开关2控制(一分二)代码[衰减器/陷波器]
+        //此处是切换衰减器与陷波器的一分二开关控制代码[off为衰减器/ON为陷波器]
+        private void chkAyCh_1_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_1.Checked== true)
+            {
+                //chkAyCh_1.Checked = true;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(1);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }          
+        }
+
+        private void chkAyCh_2_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_2.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                //chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(2);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_3_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_3.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                //chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(3);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_4_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_4.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                //chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(4);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_5_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_5.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                //chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(5);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_6_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_6.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                //chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(6);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_7_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_7.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                //chkAyCh_7.Checked = false;
+                chkAyCh_8.Checked = false;
+                gpio.SwitchControl(7);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+
+        private void chkAyCh_8_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkAyCh_8.Checked == true)
+            {
+                chkAyCh_1.Checked = false;
+                chkAyCh_2.Checked = false;
+                chkAyCh_3.Checked = false;
+                chkAyCh_4.Checked = false;
+                chkAyCh_5.Checked = false;
+                chkAyCh_6.Checked = false;
+                chkAyCh_7.Checked = false;
+                //chkAyCh_8.Checked = false;
+                gpio.SwitchControl(8);
+            }
+            else
+            {
+                gpio.SwitchControl(0);
+            }
+        }
+        #endregion
+
+
+        #region 射频开关1控制(一分八)代码
+        private void chkStCh_1_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_1.Checked == true)
+            {
+                //chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(1, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(1,DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_2_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_2.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                //chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(2, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(2, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_3_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_3.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                //chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(3, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(3, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_4_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_4.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                //chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(4, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(4, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_5_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_5.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                //chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(5, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(5, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_6_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_6.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                //chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(6, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(6, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_7_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_7.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                //chkStCh_7.Checked = false;
+                chkStCh_8.Checked = false;
+                dio.OneToEight(7, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(7, DioControlClass.State.OFF);
+            }
+        }
+
+        private void chkStCh_8_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkStCh_8.Checked == true)
+            {
+                chkStCh_1.Checked = false;
+                chkStCh_2.Checked = false;
+                chkStCh_3.Checked = false;
+                chkStCh_4.Checked = false;
+                chkStCh_5.Checked = false;
+                chkStCh_6.Checked = false;
+                chkStCh_7.Checked = false;
+                //chkStCh_8.Checked = false;
+                dio.OneToEight(8, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToEight(8, DioControlClass.State.OFF);
+            }
+        }
+        #endregion
+
+
+        #region 射频开关3控制(一分四)代码
+        private void chkBxCh_1_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkBxCh_1.Checked == true)
+            {
+                //chkBxCh_1.Checked = false;
+                chkBxCh_2.Checked = false;
+                chkBxCh_3.Checked = false;
+                chkBxCh_4.Checked = false;
+                dio.OneToFour(1, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToFour(1, DioControlClass.State.OFF);
+            }
+        }
+        private void chkBxCh_2_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkBxCh_2.Checked == true)
+            {
+                chkBxCh_1.Checked = false;
+                //chkBxCh_2.Checked = false;
+                chkBxCh_3.Checked = false;
+                chkBxCh_4.Checked = false;
+                dio.OneToFour(2, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToFour(2, DioControlClass.State.OFF);
+            }
+        }
+        private void chkBxCh_3_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkBxCh_3.Checked == true)
+            {
+                chkBxCh_1.Checked = false;
+                chkBxCh_2.Checked = false;
+                //chkBxCh_3.Checked = false;
+                chkBxCh_4.Checked = false;
+                dio.OneToFour(3, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToFour(3, DioControlClass.State.OFF);
+            }
+        }
+        private void chkBxCh_4_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkBxCh_4.Checked == true)
+            {
+                chkBxCh_1.Checked = false;
+                chkBxCh_2.Checked = false;
+                chkBxCh_3.Checked = false;
+                //chkBxCh_4.Checked = false;
+                dio.OneToFour(4, DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToFour(4, DioControlClass.State.OFF);
+            }
+        }
+        #endregion
+
+        #region 射频开关4(一分二)代码[调制解调通道切换]
+        private void chkCzCh_CheckedChanged(object sender, EventArgs e)
+        {
+            if (chkCzCh.Checked == true)
+            {
+                dio.OneToTwo(DioControlClass.State.ON);
+            }
+            else
+            {
+                dio.OneToTwo(DioControlClass.State.OFF);
+            }
+        }
+        #endregion
+
+
+        #region 内部电压控制代码
+        private void ChkPowerOnOff_CheckedChanged(object sender, EventArgs e)
+        {
+            if (ChkPowerOnOff.Checked == true)
+            {
+                power.powerOnoff(RainwormPower.State.ON);
+            }
+            else
+            {
+                power.powerOnoff(RainwormPower.State.OFF);
+            }
+        }
+
+        private void btnPowerSetting_Click(object sender, EventArgs e)
+        {
+            power.powerSetting(Convert.ToDouble(txtbVoltSetValue.Text),Convert.ToDouble(txtbCurrSetValue.Text));
+        }
+
+        #endregion
+
+    }
+}

+ 120 - 0
tps/TpsLabStudio/DebuggingForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 42 - 26
tps/TpsLabStudio/FrmMain.Designer.cs

@@ -29,9 +29,9 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            DevComponents.DotNetBar.Layout.BorderPattern borderPattern1 = new DevComponents.DotNetBar.Layout.BorderPattern();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            DevComponents.DotNetBar.Layout.BorderPattern borderPattern2 = new DevComponents.DotNetBar.Layout.BorderPattern();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();
             this.advTree1 = new DevComponents.AdvTree.AdvTree();
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
@@ -84,6 +84,7 @@
             this.BtnLoadManualData = new DevComponents.DotNetBar.ButtonX();
             this.BtnSaveManualData = new DevComponents.DotNetBar.ButtonX();
             this.tabManualData = new DevComponents.DotNetBar.SuperTabItem();
+            this.btnDebugging = new DevComponents.DotNetBar.ButtonX();
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
@@ -427,8 +428,8 @@
             // 
             // layoutGroup1
             // 
-            borderPattern1.Bottom = DevComponents.DotNetBar.Layout.LinePattern.Dot;
-            this.layoutGroup1.CaptionStyle.BorderPattern = borderPattern1;
+            borderPattern2.Bottom = DevComponents.DotNetBar.Layout.LinePattern.Dot;
+            this.layoutGroup1.CaptionStyle.BorderPattern = borderPattern2;
             this.layoutGroup1.CaptionStyle.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.layoutGroup1.CaptionStyle.TextColor = System.Drawing.Color.Navy;
             this.layoutGroup1.Height = 208;
@@ -663,8 +664,8 @@
             this.superTabControl1.ControlBox.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
             this.superTabControl1.ControlBox.MenuBox,
             this.superTabControl1.ControlBox.CloseBox});
-            this.superTabControl1.Controls.Add(this.superTabControlPanel1);
             this.superTabControl1.Controls.Add(this.superTabControlPanel2);
+            this.superTabControl1.Controls.Add(this.superTabControlPanel1);
             this.superTabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.superTabControl1.Location = new System.Drawing.Point(0, 0);
             this.superTabControl1.Margin = new System.Windows.Forms.Padding(2);
@@ -698,14 +699,14 @@
             this.dgvTestData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
             this.dgvTestData.BackgroundColor = System.Drawing.Color.Azure;
             this.dgvTestData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
-            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
-            this.dgvTestData.DefaultCellStyle = dataGridViewCellStyle1;
+            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.dgvTestData.DefaultCellStyle = dataGridViewCellStyle4;
             this.dgvTestData.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dgvTestData.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(208)))), ((int)(((byte)(215)))), ((int)(((byte)(229)))));
             this.dgvTestData.Location = new System.Drawing.Point(0, 0);
@@ -730,10 +731,10 @@
             this.superTabControlPanel2.Controls.Add(this.dgvManualData);
             this.superTabControlPanel2.Controls.Add(this.panelEx1);
             this.superTabControlPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.superTabControlPanel2.Location = new System.Drawing.Point(0, 25);
+            this.superTabControlPanel2.Location = new System.Drawing.Point(0, 28);
             this.superTabControlPanel2.Margin = new System.Windows.Forms.Padding(2);
             this.superTabControlPanel2.Name = "superTabControlPanel2";
-            this.superTabControlPanel2.Size = new System.Drawing.Size(617, 554);
+            this.superTabControlPanel2.Size = new System.Drawing.Size(536, 550);
             this.superTabControlPanel2.TabIndex = 0;
             this.superTabControlPanel2.TabItem = this.tabManualData;
             // 
@@ -744,14 +745,14 @@
             this.dgvManualData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
             this.dgvManualData.BackgroundColor = System.Drawing.Color.Azure;
             this.dgvManualData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
-            dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
-            this.dgvManualData.DefaultCellStyle = dataGridViewCellStyle2;
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.dgvManualData.DefaultCellStyle = dataGridViewCellStyle3;
             this.dgvManualData.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dgvManualData.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(208)))), ((int)(((byte)(215)))), ((int)(((byte)(229)))));
             this.dgvManualData.Location = new System.Drawing.Point(0, 54);
@@ -761,13 +762,14 @@
             this.dgvManualData.RowHeadersVisible = false;
             this.dgvManualData.RowHeadersWidth = 51;
             this.dgvManualData.RowTemplate.Height = 27;
-            this.dgvManualData.Size = new System.Drawing.Size(617, 500);
+            this.dgvManualData.Size = new System.Drawing.Size(536, 496);
             this.dgvManualData.TabIndex = 4;
             // 
             // panelEx1
             // 
             this.panelEx1.CanvasColor = System.Drawing.SystemColors.Control;
             this.panelEx1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
+            this.panelEx1.Controls.Add(this.btnDebugging);
             this.panelEx1.Controls.Add(this.BtnLoadManualData);
             this.panelEx1.Controls.Add(this.BtnSaveManualData);
             this.panelEx1.DisabledBackColor = System.Drawing.Color.Empty;
@@ -775,7 +777,7 @@
             this.panelEx1.Location = new System.Drawing.Point(0, 0);
             this.panelEx1.Margin = new System.Windows.Forms.Padding(2);
             this.panelEx1.Name = "panelEx1";
-            this.panelEx1.Size = new System.Drawing.Size(617, 54);
+            this.panelEx1.Size = new System.Drawing.Size(536, 54);
             this.panelEx1.Style.Alignment = System.Drawing.StringAlignment.Center;
             this.panelEx1.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
             this.panelEx1.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
@@ -818,6 +820,19 @@
             this.tabManualData.Name = "tabManualData";
             this.tabManualData.Text = "手动测试数据";
             // 
+            // btnDebugging
+            // 
+            this.btnDebugging.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
+            this.btnDebugging.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.btnDebugging.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
+            this.btnDebugging.Location = new System.Drawing.Point(455, 12);
+            this.btnDebugging.Name = "btnDebugging";
+            this.btnDebugging.Size = new System.Drawing.Size(69, 30);
+            this.btnDebugging.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
+            this.btnDebugging.TabIndex = 1;
+            this.btnDebugging.Text = "调试界面";
+            this.btnDebugging.Click += new System.EventHandler(this.btnDebugging_Click);
+            // 
             // FrmMain
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -901,6 +916,7 @@
         private DevComponents.DotNetBar.Controls.DataGridViewX dgvTestData;
         private DevComponents.DotNetBar.ButtonX BtnLoadManualData;
         private DevComponents.DotNetBar.ButtonX BtnSaveManualData;
+        private DevComponents.DotNetBar.ButtonX btnDebugging;
     }
 }
 

+ 6 - 0
tps/TpsLabStudio/FrmMain.cs

@@ -691,5 +691,11 @@ namespace Tps_LQ_Transmitter
         {
 
         }
+
+        private void btnDebugging_Click(object sender, EventArgs e)
+        {
+            DebuggingForm debuggingForm = new DebuggingForm();
+            debuggingForm.Show();
+        }
     }
 }

+ 16 - 0
tps/TpsLabStudio/TpsLabStudio.csproj

@@ -70,6 +70,9 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>Libs\NationalInstruments.VisaNS.dll</HintPath>
     </Reference>
+    <Reference Include="SeeSharpTools.JY.GUI">
+      <HintPath>..\..\..\..\SeeSharpTools\Bin\SeeSharpTools.JY.GUI.dll</HintPath>
+    </Reference>
     <Reference Include="Spire.License, Version=1.3.8.40, Culture=neutral, PublicKeyToken=b1144360237c8b3f, processorArchitecture=MSIL">
       <HintPath>packages\FreeSpire.XLS.10.10.0\lib\net40\Spire.License.dll</HintPath>
     </Reference>
@@ -97,12 +100,22 @@
     <Compile Include="Common\VisaResource.cs" />
     <Compile Include="com\BaseModelStruct.cs" />
     <Compile Include="com\DeviceNode.cs" />
+    <Compile Include="com\DioControlClass.cs" />
     <Compile Include="com\FileNode.cs" />
     <Compile Include="com\MsgType.cs" />
+    <Compile Include="com\MySerial.cs" />
+    <Compile Include="com\PcGpio.cs" />
+    <Compile Include="com\RainwormPower.cs" />
     <Compile Include="com\SerialPort.cs" />
     <Compile Include="com\TestMessage.cs" />
     <Compile Include="com\TestNode.cs" />
     <Compile Include="com\TestParameters.cs" />
+    <Compile Include="DebuggingForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="DebuggingForm.designer.cs">
+      <DependentUpon>DebuggingForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="FrmMain.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -134,6 +147,9 @@
     <Compile Include="views\FrmMsg.Designer.cs">
       <DependentUpon>FrmMsg.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="DebuggingForm.resx">
+      <DependentUpon>DebuggingForm.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FrmMain.resx">
       <DependentUpon>FrmMain.cs</DependentUpon>
     </EmbeddedResource>

+ 1 - 1
tps/TpsLabStudio/TpsLabStudio.csproj.user

@@ -5,6 +5,6 @@
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
     <StartAction>Program</StartAction>
-    <StartProgram>F:\Project\Launch\code\TpsLabStudio_LTS\exe\JGWorks.exe</StartProgram>
+    <StartProgram>D:\code\TpsLabStudio_LTS\exe\JGWorks.exe</StartProgram>
   </PropertyGroup>
 </Project>

+ 463 - 0
tps/TpsLabStudio/com/DioControlClass.cs

@@ -0,0 +1,463 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO.Ports;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace Tps_LQ_Transmitter.com
+{
+    /// <summary>
+    /// DIO控制板与JSY电压电流模拟量采集模块 控制类。
+    /// [DIO控制板与JSY模块都是RS485通信共用计算机的串口COM6]。
+    /// </summary>
+    class DioControlClass:MySerial
+    {
+        SerialPort serial = null;
+        public enum State {ON,OFF};
+        public DioControlClass()
+        {
+            serial = new SerialPort();
+            serial.PortName = "COM6";     //DIO控制板与JSY模块都是RS485通信共用计算机的串口COM6
+            serial.BaudRate = 9600;
+            serial.DataBits = 8;
+            serial.StopBits = StopBits.One;//停止位设置为com_stop的值
+            serial.Parity = Parity.None;//获取奇偶校验选项的值
+            serial.ReadTimeout = 1000;    //读取等待时间1000
+            serial.RtsEnable = true;
+            if (!serial.IsOpen)
+            {
+                serial.Open();
+            }
+            
+        }
+        public override void portClose()
+        {
+            serial.Close();
+        }
+
+        #region DIO
+
+        /// <summary>
+        /// DIO输出控制
+        /// </summary>
+        /// <param name="ch">控制通道号0-16</param>
+        /// <param name="st">控制状态ON/OFF</param>
+        public void DioOutput(int ch, State st)
+        {
+            byte[] byCh = { 0x7E, 0x7E, 0x01, 0x01, 0x00, 0x01, 0x0D, 0x0A };
+            byCh[4] = (byte)ch;
+            if (st== State.ON)
+            { 
+                byCh[5] = 0x01;
+            }
+            else
+            {
+                byCh[5] = 0x00;
+            }
+            if (serial.IsOpen==true)
+            {
+                serial.Write(byCh, 0, byCh.Length);
+                Thread.Sleep(50);
+            }
+        }
+        /// <summary>
+        /// 供电开关
+        /// </summary>
+        /// <param name="ch"></param>
+        /// <param name="st"></param>
+        public void SupplySwitch(int ch, State st)
+        {
+            if (ch>=1&&ch<=8)
+            {
+                ch = ch - 1;
+                DioOutput(ch, st);
+            }
+            else
+            {
+                MessageBox.Show("超出通道号范围", "提示");
+            }
+        }
+
+        /// <summary>
+        /// 一分八射频开关控制
+        /// </summary>
+        /// <param name="ch"></param>
+        /// <param name="st"></param>
+        public void OneToEight(int ch,State st)
+        {
+            int chPlay = 16;
+            switch (ch)
+            {
+                case 1:
+                    chPlay = 16;
+                    break;
+                case 2:
+                    chPlay = 17;
+                    break;
+                case 3:
+                    chPlay = 18;
+                    break;
+                case 4:
+                    chPlay = 19;
+                    break;
+                case 5:
+                    chPlay = 20;
+                    break;
+                case 6:
+                    chPlay = 21;
+                    break;
+                case 7:
+                    chPlay = 22;
+                    break;
+                case 8:
+                    chPlay = 23;
+                    break;
+                default:
+                    break;
+            }
+            for (int i = 0; i < 8; i++)
+            {
+                DioOutput(16+i, State.OFF);
+                Thread.Sleep(5);
+            }
+            DioOutput(chPlay, st);
+        }
+
+        /// <summary>
+        /// 一分四射频开关控制
+        /// </summary>
+        /// <param name="ch"></param>
+        /// <param name="st"></param>
+        public void OneToFour(int ch, State st)
+        {
+            int chPlay = 11;
+            switch (ch)
+            {
+                case 1:
+                    chPlay = 11;
+                    break;
+                case 2:
+                    chPlay = 12;
+                    break;
+                case 3:
+                    chPlay = 13;
+                    break;
+                case 4:
+                    chPlay = 14;
+                    break;              
+                default:
+                    break;
+            }
+            for (int i = 0; i < 4; i++)
+            {
+                DioOutput(11 + i, State.OFF);
+                Thread.Sleep(5);
+            }
+            DioOutput(chPlay, st);
+        }
+        /// <summary>
+        /// 一分二射频开关控制(多模解调模块切换)
+        /// </summary>
+        /// <param name="st"></param>
+        public void OneToTwo( State st)
+        {
+            int chPlay = 15;
+            DioOutput(chPlay, st);
+        }
+        #endregion
+
+        #region JSY
+
+        /// <summary>
+        /// JSY电压电流模拟量采集查询
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns>采集数据byte[]</returns>
+        public byte[] QueryJSY(byte[] data,int delay=150)
+        {
+            if (data == null)
+                return null;
+
+            //先读空
+            if (serial.BytesToRead > 0)
+                serial.DiscardInBuffer();
+
+            byte[] crc = crc16(data);
+            byte[] newarray = new byte[data.Length + 2];
+            Array.Copy(data, newarray, data.Length);
+            newarray[data.Length] = crc[0];
+            newarray[data.Length + 1] = crc[1];
+
+            serial.Write(newarray, 0, newarray.Length);
+            Thread.Sleep(delay);
+            if (serial.BytesToRead > 0)
+            {
+                byte[] dat = new byte[serial.BytesToRead];
+                serial.Read(dat, 0, dat.Length);
+                return dat;
+            }
+            else
+            {
+                return null;
+            }
+        }
+        /// <summary>
+        ///  JSY模块单通道电压(V)读取
+        /// </summary>
+        /// <param name="ch">通道号</param>
+        /// <returns>电压值</returns>
+        public double ReadVolt(int ch)
+        {
+            double volt=0;
+            byte[] command = {0x01,0x03,0x00,0x70,0x00,0x01};
+            byte[] rddat = new byte[7];
+            byte[] dat = new byte[5];
+            switch (ch)
+            {
+                case 1:
+                    command[3] = 0x70;
+                    break;
+                case 2:
+                    command[3] = 0x71;
+                    break;
+                case 3:
+                    command[3] = 0x72;
+                    break;
+                case 4:
+                    command[3] = 0x73;
+                    break;
+                case 5:
+                    command[3] = 0x74;
+                    break;
+                case 6:
+                    command[3] = 0x75;
+                    break;
+                case 7:
+                    command[3] = 0x76;
+                    break;
+                case 8:
+                    command[3] = 0x77;
+                    break;
+                default:
+                    command[3] = 0x70;
+                    break;
+            }
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 5; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval=crc16(dat);
+
+            if (rddat[5]== crcval[0] && rddat[6] == crcval[1])
+            {
+                ushort dat1=(ushort)((rddat[3] << 8) + rddat[4]);
+                volt = dat1 / 100.0;
+
+            }
+            return volt;
+        }
+
+        /// <summary>
+        /// JSY模块8个通道电压(V)同时读取
+        /// </summary>
+        /// <returns>电压值数组double[]</returns>
+        public double[] ReadAllVolt()
+        {
+            double[] volt = new double[8];
+            byte[] command = { 0x01, 0x03, 0x00, 0x70, 0x00, 0x08 };
+            byte[] rddat = new byte[21];
+            byte[] dat = new byte[19];
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 19; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval = crc16(dat);
+
+            if (rddat[19] == crcval[0] && rddat[20] == crcval[1])
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    ushort dat1 = (ushort)((rddat[3 + 2 * i] << 8) + rddat[4 + 2 * i]);
+                    volt[i] = dat1 / 100.0;
+                }
+            }
+            return volt;
+        }
+
+
+        /// <summary>
+        /// JSY模块单通道电流(A)读取
+        /// </summary>
+        /// <param name="ch">通道号</param>
+        /// <returns>电流值</returns>
+        public double ReadCurr(int ch)
+        {
+            double curr = 0;
+            byte[] command = { 0x01, 0x03, 0x00, 0x78, 0x00, 0x01 };
+            byte[] rddat = new byte[7];
+            byte[] dat = new byte[5];
+            switch (ch)
+            {
+                case 1:
+                    command[3] = 0x78;
+                    break;
+                case 2:
+                    command[3] = 0x79;
+                    break;
+                case 3:
+                    command[3] = 0x7A;
+                    break;
+                case 4:
+                    command[3] = 0x7B;
+                    break;
+                case 5:
+                    command[3] = 0x7C;
+                    break;
+                case 6:
+                    command[3] = 0x7D;
+                    break;
+                case 7:
+                    command[3] = 0x7E;
+                    break;
+                case 8:
+                    command[3] = 0x7F;
+                    break;
+                default:
+                    command[3] = 0x78;
+                    break;
+            }
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 5; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval = crc16(dat);
+
+            if (rddat[5] == crcval[0] && rddat[6] == crcval[1])
+            {
+                ushort dat1 = (ushort)((rddat[3] << 8) + rddat[4]);
+                curr = dat1 / 1000.0;
+
+            }
+            return curr;
+        }
+        /// <summary>
+        /// JSY模块8个通道电流(A)同时读取
+        /// </summary>
+        /// <returns>电流值数组double[]</returns>
+        public double[] ReadAllCurr()
+        {
+            double[] curr = new double[8];
+            byte[] command = { 0x01, 0x03, 0x00, 0x78, 0x00, 0x08 };
+            byte[] rddat = new byte[21];
+            byte[] dat = new byte[19];
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 19; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval = crc16(dat);
+
+            if (rddat[19] == crcval[0] && rddat[20] == crcval[1])
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    ushort dat1 = (ushort)((rddat[3 + 2 * i] << 8) + rddat[4 + 2 * i]);
+                    curr[i] = dat1 / 1000.0;
+                }
+            }
+            return curr;
+        }
+
+
+        /// <summary>
+        /// JSY模块单通道供电功率(W)读取
+        /// </summary>
+        /// <param name="ch">通道号</param>
+        /// <returns>电流值</returns>
+        public double ReadPower(int ch)
+        {
+            double power = 0;
+            byte[] command = { 0x01, 0x03, 0x00, 0x80, 0x00, 0x01 };
+            byte[] rddat = new byte[7];
+            byte[] dat = new byte[5];
+            switch (ch)
+            {
+                case 1:
+                    command[3] = 0x80;
+                    break;
+                case 2:
+                    command[3] = 0x81;
+                    break;
+                case 3:
+                    command[3] = 0x82;
+                    break;
+                case 4:
+                    command[3] = 0x83;
+                    break;
+                case 5:
+                    command[3] = 0x84;
+                    break;
+                case 6:
+                    command[3] = 0x85;
+                    break;
+                case 7:
+                    command[3] = 0x86;
+                    break;
+                case 8:
+                    command[3] = 0x87;
+                    break;
+                default:
+                    command[3] = 0x80;
+                    break;
+            }
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 5; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval = crc16(dat);
+
+            if (rddat[5] == crcval[0] && rddat[6] == crcval[1])
+            {
+                ushort dat1 = (ushort)((rddat[3] << 8) + rddat[4]);
+                power = dat1 / 1.0;
+
+            }
+            return power;
+        }
+        /// <summary>
+        /// JSY模块8个通道的供电功率(W)同时读取
+        /// </summary>
+        /// <returns>电流值数组double[]</returns>
+        public double[] ReadAllPower()
+        {
+            double[] power = new double[8];
+            byte[] command = { 0x01, 0x03, 0x00, 0x80, 0x00, 0x08 };
+            byte[] rddat = new byte[21];
+            byte[] dat = new byte[19];
+            rddat = QueryJSY(command);
+            for (int i = 0; i < 19; i++)
+            {
+                dat[i] = rddat[i];
+            }
+            byte[] crcval = crc16(dat);
+
+            if (rddat[19] == crcval[0] && rddat[20] == crcval[1])
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    ushort dat1 = (ushort)((rddat[3 + 2 * i] << 8) + rddat[4 + 2 * i]);
+                    power[i] = dat1 / 1.0;
+                }
+            }
+            return power;
+        }
+        #endregion
+    }
+}

+ 117 - 0
tps/TpsLabStudio/com/MySerial.cs

@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.IO.Ports;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Tps_LQ_Transmitter.com
+{
+    public class MySerial
+    {
+        SerialPort serial;
+        public bool IsOpen
+        {
+            get
+            {
+                if (serial == null)
+                    return false;
+
+                return serial.IsOpen;
+            }
+        }
+
+        public MySerial()
+        {
+
+        }
+        public virtual void portClose()
+        {         
+        }
+        public bool Init(string com)
+        {
+            serial = new SerialPort();
+            serial.PortName = com;     //端口号设置为com_port的值
+            serial.BaudRate = 9600;
+            serial.DataBits = 8;
+            serial.StopBits = StopBits.One;//停止位设置为com_stop的值
+            serial.Parity = Parity.None;//获取奇偶校验选项的值
+            serial.ReadTimeout = 1000;    //读取等待时间1000
+                                          // serial.ReceivedBytesThreshold = 1;
+                                          // serial.DataReceived += Serial_DataReceived;
+            serial.Open();
+            return serial.IsOpen;
+        }
+        /// <summary>
+        /// 串口COM先写后读方法;
+        /// 写入的时候会自动在后面添加modbus-CRC16检验
+        /// </summary>
+        /// <param name="data">写入的数据</param>
+        /// <returns>返回的数据</returns>
+        public virtual byte[] writeAndRead(byte[] data)
+        {
+            if (data == null)
+                return null;
+
+            //先读空
+            if (serial.BytesToRead > 0)
+                serial.DiscardInBuffer();
+
+            byte[] crc = crc16(data);
+            byte[] newarray = new byte[data.Length + 2];
+            Array.Copy(data, newarray, data.Length);
+            newarray[data.Length] = crc[0];
+            newarray[data.Length + 1] = crc[1];
+
+            serial.Write(newarray, 0, newarray.Length);
+            Thread.Sleep(150);
+            if(serial.BytesToRead > 0)
+            {
+                byte[] dat = new byte[serial.BytesToRead];
+                serial.Read(dat, 0, dat.Length);
+                return dat;
+            }
+            else
+            {
+                return null;
+            }        
+        }
+        /// <summary>
+        /// modbus_CRC16校验
+        /// </summary>
+        /// <param name="data">需要校验的byte[]型数据</param>
+        /// <returns>校验后数据(高位在后,低位在前)</returns>
+        public byte[] crc16(byte[] data)
+        {
+            byte[] crc = new byte[2];
+
+            UInt16 wCrc = 0xFFFF;
+            for (int i = 0; i < data.Length; i++)
+            {
+                wCrc ^= Convert.ToUInt16(data[i]);
+                for (int j = 0; j < 8; j++)
+                {
+                    if ((wCrc & 0x0001)==1)
+                    {
+                        wCrc >>= 1;
+                        wCrc ^= 0xA001;//异或多项式
+                    }
+                    else
+                    {
+                        wCrc >>= 1;
+                    }
+                }
+            }
+            crc[1] = (byte)((wCrc & 0xFF00) >> 8);//高位在后
+            crc[0] = (byte)(wCrc & 0x00FF);       //低位在前
+
+            return crc;
+        }
+
+        private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
+        {
+            
+        }
+    }
+}

+ 161 - 0
tps/TpsLabStudio/com/PcGpio.cs

@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace Tps_LQ_Transmitter.com
+{
+    /// <summary>
+    /// 计算机后面板GPIO的控制类,用于控制八路一分二射频开关,该开关主要作用是切换衰减器与陷波器,ON为陷波器接通,OFF为衰减器接通。
+    /// 启用端口2,4,6,8,10,12,14,16八个端口,其他未使用。
+    /// </summary>
+    class PcGpio
+    {
+        [DllImport("inpout32.dll", CallingConvention = CallingConvention.Winapi)]
+        public extern static void Out32(ushort add, ushort dat);
+        [DllImport("inpout32.dll", CallingConvention = CallingConvention.Winapi)]
+        public extern static ushort Inp32(ushort add);
+
+        /// <summary>
+        /// 初始化PC机后方所有的端口设置为输出端口
+        /// </summary>
+        public void InitSetOut()
+        {
+            ushort dwPortVal;
+            Out32(0xF040, (0xFF));
+            Out32((0xF043), (0x06));   //GPIO1 ~GPIO8
+            Out32((0xF044), (0x40));   //address
+            Out32((0xF045), (0x00));   // 0 = Output
+            Out32((0xF042), (0x48));
+            for (int i = 0; i < 100; i++)
+            {
+                dwPortVal = Inp32(0xF040);
+                if (dwPortVal == 0x42){break;}  else{Thread.Sleep(1);}
+            }
+
+            Out32(0xF040, (0xFF));
+            Out32((0xF043), (0x07));   //GPIO9 ~GPIO16
+            Out32((0xF044), (0x40));   //address
+            Out32((0xF045), (0x00));   // 0 = Output
+            Out32((0xF042), (0x48));
+            for (int i = 0; i < 100; i++)
+            {
+                dwPortVal = Inp32(0xF040);
+                if (dwPortVal == 0x42) { break; } else { Thread.Sleep(1); }
+            }
+        }
+
+        /// <summary>
+        /// 向端口写入高低电平信号
+        /// </summary>
+        /// <param name="dat">dat[0]为GPIO1-8,dat[1]为GPIO9-16</param>
+        public void WriteOut(ushort[] dat)
+        {
+            ushort dwPortVal;
+            Out32(0xF040, (0xFF));
+            Out32((0xF043), (0x02));   //GPIO1 ~GPIO8
+            Out32((0xF044), (0x40));   //address
+            Out32((0xF045), (dat[0]));   // 0 = Output
+            Out32((0xF042), (0x48));
+            for (int i = 0; i < 100; i++)
+            {
+                dwPortVal = Inp32(0xF040);
+                if (dwPortVal == 0x42) { break; } else { Thread.Sleep(1); }
+            }
+
+            Out32(0xF040, (0xFF));
+            Out32((0xF043), (0x03));   //GPIO9 ~GPIO16
+            Out32((0xF044), (0x40));   //address
+            Out32((0xF045), (dat[1]));   // 0 = Output
+            Out32((0xF042), (0x48));
+            for (int i = 0; i < 100; i++)
+            {
+                dwPortVal = Inp32(0xF040);
+                if (dwPortVal == 0x42) { break; } else { Thread.Sleep(1); }
+            }
+        }
+
+        /// <summary>
+        /// 开关控制,通道号为0则开关全部端口,1-8则为有效闭合其中一个“一分二”开关
+        /// </summary>
+        /// <param name="ch">通道号</param>
+        public void SwitchControl(int ch)
+        {
+            ushort[] dat = new ushort[2];
+            int chPlay = ch;
+            switch (ch)
+            {
+                case 1:
+                    chPlay = 7;
+                    break;
+                case 2:
+                    chPlay = 5;
+                    break;
+                case 3:
+                    chPlay = 3;
+                    break;
+                case 4:
+                    chPlay = 1;
+                    break;
+                case 5:
+                    chPlay = 8;
+                    break;
+                case 6:
+                    chPlay = 6;
+                    break;
+                case 7:
+                    chPlay = 4;
+                    break;
+                case 8:
+                    chPlay = 2;
+                    break;
+                default:
+                    chPlay = ch;
+                    break;
+            }
+            switch (chPlay)
+            {
+                case 1:
+                    dat[0] = 0x02;
+                    dat[1] = 0x00;
+                    break;
+                case 2:
+                    dat[0] = 0x08;
+                    dat[1] = 0x00;
+                    break;
+                case 3:
+                    dat[0] = 0x20;
+                    dat[1] = 0x00;
+                    break;
+                case 4:
+                    dat[0] = 0x80;
+                    dat[1] = 0x00;
+                    break;
+                case 5:
+                    dat[0] = 0x00;
+                    dat[1] = 0x02;
+                    break;
+                case 6:
+                    dat[0] = 0x00;
+                    dat[1] = 0x08;
+                    break;
+                case 7:
+                    dat[0] = 0x00;
+                    dat[1] = 0x20;
+                    break;
+                case 8:
+                    dat[0] = 0x00;
+                    dat[1] = 0x80;
+                    break;
+                default:
+                    dat[0] = 0x00;
+                    dat[1] = 0x00;
+                    break;
+            }
+            WriteOut(dat);
+        }
+    }
+}

+ 112 - 0
tps/TpsLabStudio/com/RainwormPower.cs

@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO.Ports;
+using System.Threading;
+
+
+namespace Tps_LQ_Transmitter.com
+{
+    /// <summary>
+    /// 蚯蚓直流程控电源控制类
+    /// [使用计算机串口COM4通信]
+    /// </summary>
+    class RainwormPower:MySerial
+    {
+        SerialPort serial = null;
+
+        public enum State { ON, OFF };
+        public RainwormPower()
+        {
+            serial = new SerialPort();
+            serial.PortName = "COM4";     //使用计算机串口COM4通信
+            serial.BaudRate = 9600;
+            serial.DataBits = 8;
+            serial.StopBits = StopBits.One;//停止位设置为com_stop的值
+            serial.Parity = Parity.None;//获取奇偶校验选项的值
+            serial.ReadTimeout = 1000;    //读取等待时间1000
+            serial.RtsEnable = true;
+            if (!serial.IsOpen)
+            {
+                serial.Open();
+            }
+        }
+        public override void portClose()
+        {
+            serial.Close();
+        }
+        /// <summary>
+        /// 电源控制与查询读写
+        /// </summary>
+        /// <param name="data">询问命令</param>
+        /// <param name="delay">延时mS</param>
+        /// <returns>返回数据byte[]</returns>
+        public byte[] powerWriteRead(byte[] data,int delay=100)
+        {
+            if (data == null)
+                return null;
+
+            //先读空
+            if (serial.BytesToRead > 0)
+                serial.DiscardInBuffer();
+
+            byte[] crc = crc16(data);
+            byte[] newarray = new byte[data.Length + 2];
+            Array.Copy(data, newarray, data.Length);
+            newarray[data.Length] = crc[0];
+            newarray[data.Length + 1] = crc[1];
+
+            serial.Write(newarray, 0, newarray.Length);
+            Thread.Sleep(delay);
+            if (serial.BytesToRead > 0)
+            {
+                byte[] dat = new byte[serial.BytesToRead];
+                serial.Read(dat, 0, dat.Length);
+                return dat;
+            }
+            else
+            {
+                return null;
+            }
+        }
+        /// <summary>
+        /// 电源输出ON/OFF
+        /// </summary>
+        /// <param name="st">输出状态ON/OFF</param>
+        public void powerOnoff(State st)
+        {
+            byte[] byOn = { 0x00, 0x10, 0x10, 0x04, 0x00, 0x01, 0x02, 0x00, 0x01 };
+            byte[] byOFF = { 0x00, 0x10, 0x10, 0x04, 0x00, 0x01, 0x02, 0x00, 0x00 };
+            if (st==State.ON)
+            {
+                powerWriteRead(byOn);
+            }
+            else
+            {
+                powerWriteRead(byOFF);
+            }
+        }
+
+        /// <summary>
+        /// 电源输出电压与限流电流设置
+        /// </summary>
+        /// <param name="volt">电压值</param>
+        /// <param name="curr">电流值</param>
+        public void powerSetting(double volt,double curr)
+        {
+            int vt, ct;
+            byte[] byVolt = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00 };
+            byte[] byCurr = { 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00 };
+            vt = (int) (volt * 100);
+            byVolt[7] = (byte)((vt & 0xFF00)>>8);
+            byVolt[8] = (byte)(vt & 0x00FF);
+            ct = (int)(curr * 100);
+            byCurr[7] = (byte)((ct & 0xFF00) >> 8);
+            byCurr[8] = (byte)(ct & 0x00FF);
+            powerWriteRead(byCurr);
+            powerWriteRead(byVolt);
+        }
+    }
+}

BIN
tps/TpsLabStudio/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 1 - 1
tps/TpsLabStudio/obj/Debug/TpsLabStudio.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-9ebfaff07920ad6e3fad75fdc2295c1e6c2548b0
+99037fa790915259ff09d7556e9cb339c78ffcd1

+ 21 - 0
tps/TpsLabStudio/obj/Debug/TpsLabStudio.csproj.FileListAbsolute.txt

@@ -117,3 +117,24 @@ D:\000Code\0.TpsLabStudio_LTS_1112\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\T
 D:\000Code\0.TpsLabStudio_LTS_1112\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.pdb
 D:\000Code\0.TpsLabStudio_LTS_1112\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#YZH16A发射机-N9030A.xlsx
 D:\000Code\0.TpsLabStudio_LTS_1112\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.AssemblyReference.cache
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\aa.PNG
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#9B发射机-N9030A.xlsx
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#YZH16A发射机-N9030A.xlsx
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#发射机_FSU-26.xlsx
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\test.png
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\bundle.config
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\ModulationMode.xlsx
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\串口控制.xlsx
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\Tps_LQ_Transmitter.dll
+D:\code\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\Tps_LQ_Transmitter.pdb
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.AssemblyReference.cache
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.DebuggingForm.resources
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.FrmMain.resources
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.Properties.Resources.resources
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.views.FrmDevice.resources
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.views.FrmMsg.resources
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.GenerateResource.cache
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.CoreCompileInputs.cache
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.CopyComplete
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.dll
+D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.pdb

BIN
tps/TpsLabStudio/obj/Debug/TpsLabStudio.csproj.GenerateResource.cache


BIN
tps/TpsLabStudio/obj/Debug/Tps_LQ_Transmitter.dll


BIN
tps/TpsLabStudio/obj/Debug/Tps_LQ_Transmitter.pdb