Browse Source

增加PCM控制类,调试界面增加PCM相关按钮。

pc 3 years ago
parent
commit
1549a97788

BIN
exe/apps/Tps_LQ_Transmitter/Tps_LQ_Transmitter.dll


BIN
exe/apps/Tps_LQ_Transmitter/Tps_LQ_Transmitter.pdb


BIN
exe/apps/Tps_LQ_Transmitter/config/测试#常温测试#9B发射机-N9030A.xlsx


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


+ 51 - 1
tps/TpsLabStudio/DebuggingForm.Designer.cs

@@ -120,6 +120,9 @@ namespace Tps_LQ_Transmitter
             this.labelX30 = new DevComponents.DotNetBar.LabelX();
             this.labelX31 = new DevComponents.DotNetBar.LabelX();
             this.labelX32 = new DevComponents.DotNetBar.LabelX();
+            this.btnPcmSetting = new DevComponents.DotNetBar.ButtonX();
+            this.txtbPcmSend = new DevComponents.DotNetBar.Controls.TextBoxX();
+            this.btnPcmSendx = new DevComponents.DotNetBar.ButtonX();
             this.SuspendLayout();
             // 
             // btnPowCh_1
@@ -1415,11 +1418,55 @@ namespace Tps_LQ_Transmitter
             this.labelX32.TabIndex = 3;
             this.labelX32.Text = "A";
             // 
+            // btnPcmSetting
+            // 
+            this.btnPcmSetting.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
+            this.btnPcmSetting.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
+            this.btnPcmSetting.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnPcmSetting.Location = new System.Drawing.Point(308, 524);
+            this.btnPcmSetting.Name = "btnPcmSetting";
+            this.btnPcmSetting.Size = new System.Drawing.Size(98, 48);
+            this.btnPcmSetting.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
+            this.btnPcmSetting.TabIndex = 7;
+            this.btnPcmSetting.Text = "设置";
+            this.btnPcmSetting.Click += new System.EventHandler(this.btnPcmSetting_Click);
+            // 
+            // txtbPcmSend
+            // 
+            // 
+            // 
+            // 
+            this.txtbPcmSend.Border.Class = "TextBoxBorder";
+            this.txtbPcmSend.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
+            this.txtbPcmSend.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.txtbPcmSend.Location = new System.Drawing.Point(593, 533);
+            this.txtbPcmSend.Name = "txtbPcmSend";
+            this.txtbPcmSend.PreventEnterBeep = true;
+            this.txtbPcmSend.Size = new System.Drawing.Size(314, 31);
+            this.txtbPcmSend.TabIndex = 9;
+            this.txtbPcmSend.Text = "11 22 33 44 55";
+            // 
+            // btnPcmSendx
+            // 
+            this.btnPcmSendx.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
+            this.btnPcmSendx.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
+            this.btnPcmSendx.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnPcmSendx.Location = new System.Drawing.Point(1003, 524);
+            this.btnPcmSendx.Name = "btnPcmSendx";
+            this.btnPcmSendx.Size = new System.Drawing.Size(98, 48);
+            this.btnPcmSendx.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
+            this.btnPcmSendx.TabIndex = 10;
+            this.btnPcmSendx.Text = "发送";
+            this.btnPcmSendx.Click += new System.EventHandler(this.btnPcmSendx_Click);
+            // 
             // DebuggingForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1904, 1041);
+            this.ClientSize = new System.Drawing.Size(1604, 881);
+            this.Controls.Add(this.btnPcmSendx);
+            this.Controls.Add(this.txtbPcmSend);
+            this.Controls.Add(this.btnPcmSetting);
             this.Controls.Add(this.btnOther);
             this.Controls.Add(this.txtbMsg);
             this.Controls.Add(this.led8);
@@ -1611,5 +1658,8 @@ namespace Tps_LQ_Transmitter
         private DevComponents.DotNetBar.LabelX labelX30;
         private DevComponents.DotNetBar.LabelX labelX31;
         private DevComponents.DotNetBar.LabelX labelX32;
+        private DevComponents.DotNetBar.ButtonX btnPcmSetting;
+        private DevComponents.DotNetBar.Controls.TextBoxX txtbPcmSend;
+        private DevComponents.DotNetBar.ButtonX btnPcmSendx;
     }
 }

+ 28 - 0
tps/TpsLabStudio/DebuggingForm.cs

@@ -10,6 +10,7 @@ using System.Windows.Forms;
 using System.IO.Ports;
 using Tps_LQ_Transmitter.com;
 using System.Threading;
+using System.Text.RegularExpressions;
 
 namespace Tps_LQ_Transmitter
 {
@@ -21,6 +22,7 @@ namespace Tps_LQ_Transmitter
         DioControlClass dio = new DioControlClass();
         PcGpio gpio = new PcGpio();
         RainwormPower power = new RainwormPower();
+        PcmControl pcm = new PcmControl();
 
         public DebuggingForm()
         {
@@ -641,5 +643,31 @@ namespace Tps_LQ_Transmitter
 
         #endregion
 
+       
+
+       
+
+        private void btnPcmSendx_Click(object sender, EventArgs e)
+        {
+            string str = txtbPcmSend.Text;
+            if (str!="" && str!=null)
+            {
+                string[] sArray = Regex.Split(str, " ", RegexOptions.IgnoreCase);
+                byte[] bytx = new byte[sArray.Length];
+                for (int i = 0; i < sArray.Length; i++)
+                {
+                    bytx[i] = Convert.ToByte(sArray[i], 16);
+                }
+                txtbMsg.Text = pcm.DataSend(bytx).ToString();
+            }
+           
+
+            
+        }
+
+        private void btnPcmSetting_Click(object sender, EventArgs e)
+        {
+            pcm.Setting("UART","ODD",230400);
+        }
     }
 }

+ 1 - 0
tps/TpsLabStudio/TpsLabStudio.csproj

@@ -105,6 +105,7 @@
     <Compile Include="com\MsgType.cs" />
     <Compile Include="com\MySerial.cs" />
     <Compile Include="com\PcGpio.cs" />
+    <Compile Include="com\PcmControl.cs" />
     <Compile Include="com\RainwormPower.cs" />
     <Compile Include="com\SerialPort.cs" />
     <Compile Include="com\TestMessage.cs" />

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

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

+ 187 - 0
tps/TpsLabStudio/com/PcmControl.cs

@@ -0,0 +1,187 @@
+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>
+    /// PCM控制与数据发送类
+    /// </summary>
+    class PcmControl:MySerial
+    {
+        SerialPort serial = null;
+        public PcmControl()
+        {
+            serial = new SerialPort();
+            serial.PortName = "COM5";     //DIO控制板与JSY模块都是RS485通信共用计算机的串口COM6
+            serial.BaudRate = 115200;
+            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>
+        /// PCM读写方法
+        /// </summary>
+        /// <param name="data">数据</param>
+        /// <param name="delay">延时</param>
+        /// <returns></returns>
+        public byte[] WriteRead(byte[] data, int delay = 50)
+        {
+            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(data, 0, data.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>
+        /// PCM设置命令发送
+        /// </summary>
+        /// <param name="mode">"UART"/"HDLC"</param>
+        /// <param name="choice">"ODD"/"EVEN"/"NONE"/"FALL"/"RISE"</param>
+        /// <param name="baudrate">波特率</param>
+        /// <returns>结果</returns>
+        public bool Setting(string mode,string choice,int baudrate )
+        {
+            int u = 0;
+            if (mode=="UART")
+            {
+                u = u | 0x01;
+            }
+            else if (mode == "HDLC")
+            {
+                u = u | 0x41;
+            }
+
+            if (choice == "ODD")//奇校验
+            {
+                u = u | 0x02;
+            }
+            else if (choice == "EVEN")//偶校验
+            { 
+                u = u | 0x04;
+            }
+            else if (choice == "NONE")//无校验
+            {
+                u = u | 0x00;
+            }
+            else if (choice == "FALL")//下降沿
+            {
+                u = u | 0x08;
+            }
+            else if (choice == "RISE")//上升沿
+            {
+                u = u | 0x00;
+            }
+            int d =((50000000 / baudrate) + 2);
+            bool bolrd = false;
+            byte[] byst = { 0xF0, 0x0F, 0x02, 0x00, 0x00, 0x03, 0x00, 0xDB, 0x01 };
+            byst[8] = (byte)u;
+            byst[6] = (byte)((d & 0x0000ff00) >> 8);
+            byst[7] = (byte)(d & 0x000000ff);
+            byte[] byrd  = WriteRead(byst);
+            if (byrd.Length>= byst.Length)
+            {
+                bolrd = true;
+            }
+            return bolrd;
+        }
+        public bool UartSendSetting()
+        {
+            bool bolrd = false;
+            byte[] byst = { 0xF0, 0x0F, 0x02, 0x00, 0x00, 0x03, 0x00, 0xDB, 0x01 };
+            byte[] byrd = new byte[10];
+            byte[] byrdx = { 0xF0, 0x0F, 0x02, 0x00, 0x00, 0x03, 0x00, 0xDB, 0x01 ,0x24};
+            byrd=WriteRead(byst);
+            if (byrd.Length >= 10)
+            {
+                bolrd = true;
+                for (int i = 0; i < byrdx.Length; i++)
+                {
+                    if (byrd[i] != byrdx[i])
+                        bolrd = false;
+                }
+            }
+            return bolrd;
+        }
+
+        public bool HdlcSendSetting()
+        {
+            bool bolrd = false;
+            byte[] byst = { 0xF0, 0x0F, 0x02, 0x00, 0x00, 0x03, 0x00, 0x0D, 0x41 };
+            byte[] byrd = new byte[10];
+            byte[] byrdx = { 0xF0, 0x0F, 0x02, 0x00, 0x00, 0x03, 0x00, 0x0D, 0x41, 0xB2 };
+            byrd = WriteRead(byst);
+            if (byrd.Length >= 10)
+            {
+                bolrd = true;
+                for (int i = 0; i < byrdx.Length; i++)
+                {
+                    if (byrd[i] != byrdx[i])
+                        bolrd = false;
+                }
+            }
+            return bolrd;
+        }
+        public bool DataSend(byte[] data)
+        {
+            bool bolrd = false;
+            if (data!=null && data.Length>0)
+            {
+                byte[] sd = new byte[data.Length + 6];
+                sd[0] = 0xF0;
+                sd[1] = 0x0F;
+                sd[2] = 0x03;
+                sd[3] = 0x00;
+                sd[4] = 0x00;
+                sd[5] = (byte)data.Length;
+                for (int i = 0; i < data.Length; i++)
+                {
+                    sd[6 + i] = data[i];
+                }
+                byte[] byrd = WriteRead(sd);
+                if (byrd.Length >= sd.Length)
+                {
+                    bolrd = true;
+                }
+            }
+            return bolrd;
+        }
+    }
+}

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


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


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

@@ -1 +1 @@
-99037fa790915259ff09d7556e9cb339c78ffcd1
+60fbec6b54fa85610b87ef640925469373f3f35d

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

@@ -138,3 +138,24 @@ D:\code\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.CoreComp
 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
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\aa.PNG
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#9B发射机-N9030A.xlsx
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#YZH16A发射机-N9030A.xlsx
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\测试#常温测试#发射机_FSU-26.xlsx
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\test.png
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\bundle.config
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\ModulationMode.xlsx
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\config\串口控制.xlsx
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\Tps_LQ_Transmitter.dll
+D:\lqCode\TpsLabStudio_LTS\exe\apps\Tps_LQ_Transmitter\Tps_LQ_Transmitter.pdb
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.AssemblyReference.cache
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.DebuggingForm.resources
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.FrmMain.resources
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.Properties.Resources.resources
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.views.FrmDevice.resources
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.views.FrmMsg.resources
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.GenerateResource.cache
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.CoreCompileInputs.cache
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\TpsLabStudio.csproj.CopyComplete
+D:\lqCode\TpsLabStudio_LTS\tps\TpsLabStudio\obj\Debug\Tps_LQ_Transmitter.dll
+D:\lqCode\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