|
@@ -96,11 +96,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
/// </summary>
|
|
|
private async void Reset()
|
|
|
{
|
|
|
- PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "0");
|
|
|
+ PLCConnectionFactory.CreatePLCCont().ResetPLC("1.00", VarType.Bit, "0");
|
|
|
await Task.Delay(1000);
|
|
|
- PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "1");
|
|
|
+ PLCConnectionFactory.CreatePLCCont().ResetPLC("1.00", VarType.Bit, "1");
|
|
|
await Task.Delay(1000);
|
|
|
- bool isResult=PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "0");
|
|
|
+ bool isResult=PLCConnectionFactory.CreatePLCCont().ResetPLC("1.00", VarType.Bit, "0");
|
|
|
if(isResult)
|
|
|
{
|
|
|
MessageBox.Show("复位成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
@@ -793,7 +793,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
switch (plcAddType)
|
|
|
{
|
|
|
case "bool":
|
|
|
- string readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
+ string readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
///实时值记录
|
|
|
|
|
|
item.RealValue = readResult;
|
|
@@ -939,7 +939,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
if (callback.Result == ButtonResult.OK)
|
|
|
{
|
|
|
string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
|
|
|
- bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Bit, plcRealValue);
|
|
|
+ bool writeResult = PLCConnectionFactory.CreatePLCCont().WritePlcObject(plcAddress, VarType.Bit, plcRealValue);
|
|
|
///实时值记录
|
|
|
item.RealValue = plcRealValue;
|
|
|
item.TestTime = DateTime.Now;
|
|
@@ -971,7 +971,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
if (callback.Result == ButtonResult.OK)
|
|
|
{
|
|
|
string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
|
|
|
- bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Word, plcRealValue);
|
|
|
+ bool writeResult = PLCConnectionFactory.CreatePLCCont().WritePlcObject(plcAddress, VarType.Word, plcRealValue);
|
|
|
///实时值记录
|
|
|
item.RealValue = plcRealValue;
|
|
|
item.TestTime = DateTime.Now;
|
|
@@ -1116,7 +1116,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}));
|
|
|
//先延时,在读取,避免读取传感器刚开始的数据
|
|
|
await Task.Delay(1000);
|
|
|
- readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
+ readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
if (readResult == item.PlcValue)
|
|
|
{
|
|
|
break;
|
|
@@ -1125,7 +1125,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
});
|
|
|
//可能有多个条件判定的,第二次时间到了直接跳出延时,直接读取,不用在延时20s
|
|
|
- readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
+ readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
ProVisibility = Visibility.Hidden;
|
|
|
///实时值记录
|
|
|
item.RealValue = readResult;
|
|
@@ -1155,7 +1155,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
ProVisibility = Visibility.Visible;
|
|
|
}));
|
|
|
|
|
|
- readResult2 = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
|
|
|
+ readResult2 = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Word);
|
|
|
if (readResult2 == item.PlcValue)
|
|
|
{
|
|
|
break;
|
|
@@ -1164,7 +1164,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
});
|
|
|
//可能有多个条件判定的,第二次直接跳出延时,直接读取
|
|
|
- readResult2 = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
|
|
|
+ readResult2 = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Word);
|
|
|
ProVisibility = Visibility.Hidden;
|
|
|
///实时值记录
|
|
|
item.RealValue = readResult2;
|