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

资源简介

简单实现C#读取atlas拧紧枪数据

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ElectricComponentVB;

namespace AtlasTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void AtlasData()
        {
            byte[] atlasReceiveBytes = new byte[501];
            IPEndPoint atlasEndPoint = new IPEndPoint(IPAddress.Parse(“192.168.30.59“) 4545);
            Socket atlasSocket = new Socket(AddressFamily.InterNetwork SocketType.Stream ProtocolType.Tcp);
            atlasSocket.Connect(atlasEndPoint);
            atlasSocket.Send(Encoding.ASCII.GetBytes(“00200001001         “ + Convert.ToChar(0)));

            atlasReceiveBytes = new byte[501];

            atlasSocket.Receive(atlasReceiveBytes);

            atlasSocket.Send(Encoding.ASCII.GetBytes(“00300064000         0000000000“ + Convert.ToChar(0)));
            atlasReceiveBytes = new byte[501];
            atlasSocket.Receive(atlasReceiveBytes);

            string currentTorque = (Convert.ToDouble(Encoding.Default.GetString(atlasReceiveBytes).Substring(82 6)) / 1000).ToString(“0.00“);
            string currentAngle = (Convert.ToDouble(Encoding.Default.GetString(atlasReceiveBytes).Substring(90 5)) / 10).ToString(“0“);
            txtTorque.Text = currentTorque;
            txtAngle.Text = currentAngle;
            try
            {
                atlasSocket.Close();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                atlasSocket = null;
            }

        }

        private void button1_Click(object sender EventArgs e)
        {
            AtlasData();
            //AtlasPMResult atlas = new AtlasPMResult(“192.168.30.59“);
            
        }
    }
}

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

    ..A..H.     45056  2021-01-19 15:46  AtlasTest\.vs\AtlasTest\v14\.suo

     文件        189  2021-01-13 12:25  AtlasTest\AtlasTest\App.config

     文件       4153  2021-01-13 13:12  AtlasTest\AtlasTest\AtlasTest.csproj

     文件       9728  2021-01-13 14:23  AtlasTest\AtlasTest\bin\Debug\AtlasTest.exe

     文件        189  2021-01-13 12:25  AtlasTest\AtlasTest\bin\Debug\AtlasTest.exe.config

     文件      19968  2021-01-13 14:23  AtlasTest\AtlasTest\bin\Debug\AtlasTest.pdb

     文件      22696  2021-01-19 15:05  AtlasTest\AtlasTest\bin\Debug\AtlasTest.vshost.exe

     文件        189  2021-01-13 12:25  AtlasTest\AtlasTest\bin\Debug\AtlasTest.vshost.exe.config

     文件        490  2019-03-19 12:46  AtlasTest\AtlasTest\bin\Debug\AtlasTest.vshost.exe.manifest

     文件      24064  2020-05-05 14:44  AtlasTest\AtlasTest\bin\Debug\ElectricComponentVB.dll

     文件      64150  2020-12-16 21:45  AtlasTest\AtlasTest\bin\Debug\ElectricComponentVB.pdb

     文件       1268  2020-05-05 14:44  AtlasTest\AtlasTest\bin\Debug\ElectricComponentVB.xml

     文件       2062  2021-01-13 14:23  AtlasTest\AtlasTest\Form1.cs

     文件       4017  2021-01-13 12:36  AtlasTest\AtlasTest\Form1.Designer.cs

     文件       5817  2021-01-13 12:36  AtlasTest\AtlasTest\Form1.resx

     文件        829  2021-01-19 15:05  AtlasTest\AtlasTest\obj\Debug\AtlasTest.csproj.FileListAbsolute.txt

     文件       1012  2021-01-13 13:02  AtlasTest\AtlasTest\obj\Debug\AtlasTest.csproj.GenerateResource.Cache

     文件       9123  2021-01-13 13:31  AtlasTest\AtlasTest\obj\Debug\AtlasTest.csprojResolveAssemblyReference.cache

     文件       9728  2021-01-13 14:23  AtlasTest\AtlasTest\obj\Debug\AtlasTest.exe

     文件        180  2021-01-13 13:31  AtlasTest\AtlasTest\obj\Debug\AtlasTest.Form1.resources

     文件      19968  2021-01-13 14:23  AtlasTest\AtlasTest\obj\Debug\AtlasTest.pdb

     文件        180  2021-01-13 13:31  AtlasTest\AtlasTest\obj\Debug\AtlasTest.Properties.Resources.resources

     文件       1464  2021-01-19 15:05  AtlasTest\AtlasTest\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7230  2021-01-13 13:10  AtlasTest\AtlasTest\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2021-01-13 12:25  AtlasTest\AtlasTest\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2021-01-13 12:25  AtlasTest\AtlasTest\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2021-01-13 12:25  AtlasTest\AtlasTest\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        521  2021-01-13 12:25  AtlasTest\AtlasTest\Program.cs

     文件       1326  2021-01-13 12:25  AtlasTest\AtlasTest\Properties\AssemblyInfo.cs

     文件       2831  2021-01-13 12:25  AtlasTest\AtlasTest\Properties\Resources.Designer.cs

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

评论

共有 条评论