Commit c81e4c9e authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 自动风环 PLC写加热 无效

parent 4032422a
......@@ -47,6 +47,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Client\FeedbackHeatServiceClient.cs" />
......
......@@ -161,7 +161,7 @@ namespace FLY.FeedbackRenZiJia.Server
public FeedbackHeat()
{
PLCep = Misc.StringConverter.ToIPEndPoint("192.168.251.9:502");
PLCep = Misc.StringConverter.ToIPEndPoint("192.168.50.60:502");
Load();
if (IsClient)
plc = new PLCLink(PLCep);
......@@ -169,8 +169,11 @@ namespace FLY.FeedbackRenZiJia.Server
plc = new HMI();
plc.PropertyChanged += new PropertyChangedEventHandler(hmi_PropertyChanged);
Misc.BindingOperations.SetBinding(plc, "HasElectricity", this, "HasElectricity");
Misc.BindingOperations.SetBinding(plc, "HasFan", this, "HasFan");
HasCheckFilmVelocity = plc.HasElectricity;
HasFan = plc.HasFan;
InitBuf();
......@@ -238,7 +241,7 @@ namespace FLY.FeedbackRenZiJia.Server
mHeatCheck.Init(mHeatCell);
mHeatCheck.PropertyChanged += new PropertyChangedEventHandler(mHeatCheck_PropertyChanged);
Misc.BindingOperations.SetBinding(plc, "HasElectricity", mHeatCheck, "HasElectricity");
Misc.BindingOperations.SetBinding(this, "HasElectricity", mHeatCheck, "HasElectricity");
Misc.BindingOperations.SetBinding(this, "HasCheck", mHeatCheck, "Has");
Misc.BindingOperations.SetBinding(mHeatCheck, "Enable", this, "CheckEnable", Misc.BindingOperations.BindingMode.TwoWay);
Misc.BindingOperations.SetBinding(mHeatCheck, "CheckNo", this, "CheckNo");
......@@ -398,25 +401,36 @@ namespace FLY.FeedbackRenZiJia.Server
mSnapShotBuf.Init(NBolts, ChannelCnt);
}
void hmi_PropertyChanged(object sender, PropertyChangedEventArgs e)
void hmi_PropertyChanged(object s, PropertyChangedEventArgs _e)
{
if (e.PropertyName == "Errno")
{
if (plc.Errno == -1)
{
IsConnectedWithPLC = false;
}
else
{
IsConnectedWithPLC = true;
//刚成功连接上
//重新复制数据到 PLC
RecoverPLC();
}
}
FObjBase.PollModule.Current.Dispatcher.Invoke(
new PropertyChangedEventHandler(
(sender, e)=> {
if (e.PropertyName == "Errno")
{
if (plc.Errno == -1)
{
IsConnectedWithPLC = false;
}
else
{
IsConnectedWithPLC = true;
//刚成功连接上
//重新复制数据到 PLC
RecoverPLC();
}
}
else if (e.PropertyName == "HasElectricity")
{
HasElectricity = plc.HasElectricity;
}
else if (e.PropertyName == "HasFan")
{
HasFan = plc.HasFan;
}
}), s, _e);
}
List<FlyData_FeedbackHeat> test_data = new List<FlyData_FeedbackHeat>();
int test_index = 0;
public int TestIndex
......
......@@ -288,6 +288,7 @@ namespace FLY.FeedbackRenZiJia.Server
UInt16[] buf1 = new UInt16[cnt1];
Array.Copy(buf, offset, buf1, 0, cnt1);
RegWrite rw = new RegWrite(PLCAddressArea.Register, addr+offset, buf1);
writes.Add(rw);
offset += cnt1;
cnt -= cnt1;
......
......@@ -257,16 +257,16 @@ namespace FLY.Modbus.WithThread
}
//强制令读时,推送数据
rw.dr.isPlcValueChanged = true;
object plc_value = rw.dr.ToPLCObj(rw.val);
switch (rw.dr.dataArea)
{
case PLCAddressArea.Coil:
if (!Client.Do_0F((UInt16)rw.dr.addr, new bool[] {(bool)rw.dr.plcValue}))
if (!Client.Do_0F((UInt16)rw.dr.addr, new bool[] {(bool)plc_value }))
return false;
break;
default:
//case PLCAddressArea.Register:
if (!Client.Do_10((UInt16)rw.dr.addr, (UInt16[])rw.dr.plcValue))
if (!Client.Do_10((UInt16)rw.dr.addr, (UInt16[])plc_value))
return false;
break;
}
......
<?xml version="1.0" encoding="utf-8"?>
<PLCGroup>
<Devices>
<PLCDevice EP="127.168.50.2:502" />
<PLCDevice EP="127.168.50.1:502" />
<PLCDevice EP="127.168.50.3:502" />
<PLCDevice EP="192.168.1.1:502" />
<PLCDevice EP="192.168.1.1:502" />
<PLCDevice EP="192.168.1.1:502" />
</Devices>
<Variables>
<PLCVariable DeviceIndex="1" Mode="0" Addr="970" Type="bool" Scale="1" OwnerName="Items[0]" PropertyName="AlarmIsOn" />
......
No preview for this file type
[POU_PlusSign]
1=1
2=1
17=1
18=0
19=0
20=1
[Comm_Param]
Type=4
Port=3
Timeout=2000
ip=192.168.1.1
[POU_PlusSign]
1=1
2=1
17=1
18=0
19=0
20=1
[Comm_Param]
Type=0
Port=3
Timeout=2000
[POU_PlusSign]
1=1
2=1
17=1
18=0
19=0
20=1
[Comm_Param]
Type=4
Port=3
Timeout=2000
ip=192.168.1.1
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment