• 大小: 1.00M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-30
  • 语言: C#
  • 标签: 通信  C#  

资源简介

C#OPT光源通信

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using CSharp_OPTControllerAPI;

namespace OPTController__ExampleCSharp._2008
{
    public partial class Form1 : Form
    {
        public enum OPT_COMMUNICATION_MODEL : int
        {
            COMMUNICATION_BY_COM
            COMMUNICATION_BY_SN
            COMMUNICATION_BY_IP
        }

        private OPT_COMMUNICATION_MODEL model = 0;
        private String serialPortName;
        private String IPAddr;
        private String SN;
        private OPTControllerAPI OPTController = null;

        public Form1()
        {
            OPTController = new OPTControllerAPI();
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            textBox_COMName.Text = ““;
            textBox_ChannelIndex.Text = “0“;
            textBox_Intensity.Text = “255“;
        }

        private void button_Open_Click(object sender EventArgs e)
        {
            serialPortName = textBox_COMName.Text;
            SN = textBox_SN.Text;
            IPAddr = textBox_IP.Text;
            long lRet = -1;
            if (“Connect“ == button_Open.Text)
            {
                switch (model)
                {
                    case OPT_COMMUNICATION_MODEL.COMMUNICATION_BY_COM:
                        {
                            if (““ == serialPortName)
                            {
                                textBox_Status.Text = “Serial name can not be empty“;
                                return;
                            }

                            lRet = OPTController.InitSerialPort(serialPortName);
                            if (0 != lRet)
                            {
                                textBox_Status.Text = “Failed to initialize serial port“;
                                return;
                            }
                            else
                            {
                                textBox_Status.Text = “Succeed“;
                            }
                        }
                        break;
                    case OPT_COMMUNICATION_MODEL.COMMUNICATION_BY_SN:
                        {
                            if (““ == SN)
                            {
                                textBox_Status.Text = “SN can not be empty“;
                                return;
                            }

                            lRet = OPTController.CreateEthernetConnectionBySN(SN);
                            if (0 != lRet)
                            {
                                textBox_Status.Text = “Failed to create Ethernet connection by SN“;
                                return;
                            }
                      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     70144  2020-08-22 08:58  OPTController_ExampleCSharp.2008\.vs\OPTController__ExampleCSharp.2008\v14\.suo

     文件       9062  2017-11-18 15:53  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Form1.cs

     文件      18856  2015-03-13 08:31  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Form1.Designer.cs

     文件       5814  2015-03-13 08:31  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Form1.resx

     文件      45938  2018-08-04 11:03  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\OPTControllerAPI.cs

     文件       7557  2014-12-03 16:16  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\OPTController__ExampleCSharp.2008.csproj

     文件        547  2014-11-19 15:16  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\OPTController__ExampleCSharp.2008.csproj.user

     文件        526  2014-10-13 15:40  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Program.cs

     文件       1588  2014-12-03 16:04  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Properties\AssemblyInfo.cs

     文件       2897  2014-10-13 15:40  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Properties\Resources.Designer.cs

     文件       5612  2014-10-13 15:40  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Properties\Resources.resx

     文件       1119  2014-10-13 15:40  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Properties\Settings.Designer.cs

     文件        249  2014-10-13 15:40  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008\Properties\Settings.settings

     文件       1697  2014-12-03 16:16  OPTController_ExampleCSharp.2008\Backup\OPTController__ExampleCSharp.2008.sln

     文件     340480  2018-08-04 10:23  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Debug\OPTController.dll

     文件      33792  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Debug\OPTController__ExampleCSharp.2008.exe

     文件      60928  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Debug\OPTController__ExampleCSharp.2008.pdb

     文件      14328  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Debug\OPTController__ExampleCSharp.2008.vshost.exe

     文件        490  2009-06-11 05:14  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Debug\OPTController__ExampleCSharp.2008.vshost.exe.manifest

     文件     340480  2018-08-04 10:23  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Release\OPTController.dll

     文件      32256  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Release\OPTController__ExampleCSharp.2008.exe

     文件      52736  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Release\OPTController__ExampleCSharp.2008.pdb

     文件      14328  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Release\OPTController__ExampleCSharp.2008.vshost.exe

     文件        490  2009-06-11 05:14  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x64\Release\OPTController__ExampleCSharp.2008.vshost.exe.manifest

     文件     679936  2018-08-04 10:23  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Debug\OPTController.dll

     文件      34816  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Debug\OPTController__ExampleCSharp.2008.exe

     文件      60928  2018-08-04 11:05  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Debug\OPTController__ExampleCSharp.2008.pdb

     文件      14848  2018-08-04 10:56  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Debug\OPTController__ExampleCSharp.2008.vshost.exe

     文件        490  2009-06-11 05:14  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Debug\OPTController__ExampleCSharp.2008.vshost.exe.manifest

     文件     679936  2018-08-04 10:23  OPTController_ExampleCSharp.2008\OPTController__ExampleCSharp.2008\bin\x86\Release\OPTController.dll

............此处省略79个文件信息

评论

共有 条评论