diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index 876586d..baf2532 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -119,7 +119,7 @@ namespace MCRun }; WorkbenchSingleton.InitializeWorkbench(); - PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc, "127.0.0.1", 9600); + PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc, "127.0.0.1", 12); ICSharpCode.Core.LoggingService.Debug("starting workbench..."); Form frmMain = WorkbenchSingleton.Workbench as Form; diff --git a/Mesnac.PlcUtils/PlcBusiness.cs b/Mesnac.PlcUtils/PlcBusiness.cs index 13eba51..0dbb021 100644 --- a/Mesnac.PlcUtils/PlcBusiness.cs +++ b/Mesnac.PlcUtils/PlcBusiness.cs @@ -33,7 +33,7 @@ namespace Mesnac.PlcUtils string str = System.Environment.CurrentDirectory; str = str + "\\Mesnac.PlcUtils.dll"; Assembly assembly = Assembly.LoadFile(str); // 加载程序集(EXE 或 DLL) - string AssemName = "JSSD.PolarBind.Plc.Impl." + plcType.GetDescription(); + string AssemName = "Mesnac.PlcUtils.Impl." + plcType.GetDescription(); var obj = assembly.CreateInstance(AssemName, true); plcInstance = obj as IPlc; if (plcInstance == null) @@ -71,7 +71,14 @@ namespace Mesnac.PlcUtils public bool readBoolValue(string address) { - return plcInstance.readBoolByAddress(address); + if(plcInstance != null) + { + return plcInstance.readBoolByAddress(address); + } + else + { + return false; + } } }