@ -32,9 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HslCommunication">
<HintPath>..\HighWayIot.Library\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@ -62,5 +59,10 @@
<Folder Include="Impl\" />
</ItemGroup>
<PackageReference Include="HslCommunication">
<Version>12.1.3</Version>
</PackageReference>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@ -36,14 +36,15 @@ namespace HighWayIot.Plc
SocketKeepAliveTime = -1,
IsPersistentConnection = true,
};
plc.ConnectServer();
}
catch (Exception ex)
{
logHelper.Error("初始化PLC服务器发生错误!", ex);
string s = IsConnect ? "正常" : "异常";
logHelper.Info($"PLC连接:{s}");
return plc;
@ -55,6 +56,7 @@ namespace HighWayIot.Plc
get
if (MelsecInstance == null) return false;
var result = MelsecInstance.ReadPlcType();
logHelper.Info($"PLC型号:{result.Content}");
return result.IsSuccess;
@ -36,7 +36,6 @@
<StartupObject />
<Reference Include="HslCommunication, Version=12.1.3.0, Culture=neutral, PublicKeyToken=3d72ad3b6b5ec0e3" />
@ -313,6 +312,10 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<ItemGroup />
@ -6,6 +6,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using HighWayIot.Plc;
namespace HighWayIot.Winform
@ -30,6 +31,8 @@ namespace HighWayIot.Winform
//Console.OutputEncoding = System.Text.Encoding.UTF8;
//Console.InputEncoding = System.Text.Encoding.UTF8;
AllocConsole();//调用系统API,调用控制台窗口
// 设置控制台编码为系统默认编码(解决乱码问题)
Application.EnableVisualStyles();