调整通信逻辑
This commit is contained in:
commit
c5a02416fb
5 files changed
+48
-35
No files matched your search
@@ -283,7 +283,7 @@
|
|||||||
<value>运转</value>
|
<value>运转</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="AddTheMedicine" xml:space="preserve">
|
<data name="AddTheMedicine" xml:space="preserve">
|
||||||
<value>加药</value>
|
<value>加注</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="CallDistribution" xml:space="preserve">
|
<data name="CallDistribution" xml:space="preserve">
|
||||||
<value>呼叫输送</value>
|
<value>呼叫输送</value>
|
||||||
@@ -358,7 +358,7 @@
|
|||||||
<value>水源</value>
|
<value>水源</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Medicine" xml:space="preserve">
|
<data name="Medicine" xml:space="preserve">
|
||||||
<value>药</value>
|
<value>料</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Mixing" xml:space="preserve">
|
<data name="Mixing" xml:space="preserve">
|
||||||
<value>搅拌</value>
|
<value>搅拌</value>
|
||||||
|
|||||||
@@ -358,7 +358,7 @@
|
|||||||
<value>來源</value>
|
<value>來源</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Medicine" xml:space="preserve">
|
<data name="Medicine" xml:space="preserve">
|
||||||
<value>藥</value>
|
<value>料</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Mixing" xml:space="preserve">
|
<data name="Mixing" xml:space="preserve">
|
||||||
<value>攪拌</value>
|
<value>攪拌</value>
|
||||||
@@ -483,4 +483,10 @@
|
|||||||
<data name="Bottom" xml:space="preserve">
|
<data name="Bottom" xml:space="preserve">
|
||||||
<value>底</value>
|
<value>底</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="DyeingMachine" xml:space="preserve">
|
||||||
|
<value>染色機</value>
|
||||||
|
</data>
|
||||||
|
<data name="Receipt" xml:space="preserve">
|
||||||
|
<value>領料單</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -77,16 +77,19 @@
|
|||||||
<DataGridTextColumn Binding="{Binding DYELOT}" Width="0" MinWidth="0" MaxWidth="0"/>
|
<DataGridTextColumn Binding="{Binding DYELOT}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<TextBlock x:Name="log" HorizontalAlignment="Left" Margin="0,40,0,0" TextWrapping="Wrap" Width="600" FontSize="25" Background="White" Text="{Binding Sys_log}"/>
|
<TextBlock x:Name="log" HorizontalAlignment="Left" TextWrapping="Wrap" Width="600" FontSize="25" Background="White" Text="{Binding Sys_log}" Margin="0,40,0,0"/>
|
||||||
<TextBlock x:Name="name" HorizontalAlignment="Left" Margin="600,0,0,0" TextWrapping="Wrap" FontSize="24" Background="#FFD0D0D0" Text="{Binding Program_Name}" Height="30" Block.TextAlignment="Center">
|
<TextBlock x:Name="name" HorizontalAlignment="Left" Margin="600,0,0,0" TextWrapping="Wrap" FontSize="24" Background="#FFD0D0D0" Text="{Binding Program_Name}" Height="30" Block.TextAlignment="Center">
|
||||||
<TextBlock.LayoutTransform>
|
<TextBlock.LayoutTransform>
|
||||||
<!--文字同样旋转90度-->
|
<!--文字同样旋转90度-->
|
||||||
<RotateTransform Angle="270"/>
|
<RotateTransform Angle="270"/>
|
||||||
</TextBlock.LayoutTransform>
|
</TextBlock.LayoutTransform>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<WrapPanel Orientation="Horizontal" x:Name="WholeView" Background="#FFCCCCCC" VerticalAlignment="Top">
|
<WrapPanel Orientation="Horizontal" Background="#FFCCCCCC" VerticalAlignment="Top">
|
||||||
<Button Content="{x:Static lang:Resources.DyeingMachine}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="DyeingMachine_Click"/>
|
<Button Content="{x:Static lang:Resources.DyeingMachine}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="DyeingMachine_Click"/>
|
||||||
<Button Content="{x:Static lang:Resources.Receipt}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="Receipt_Click"/>
|
<Button Content="{x:Static lang:Resources.Receipt}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="Receipt_Click"/>
|
||||||
|
<Button Content="{x:Static lang:Resources.ParameterSet}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ParameterSet_Click"/>
|
||||||
|
</WrapPanel>
|
||||||
|
<WrapPanel Orientation="Horizontal" Background="#FFCCCCCC" VerticalAlignment="Top" Margin="630,0,0,0">
|
||||||
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
|
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
|
||||||
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_del_Click"/>
|
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_del_Click"/>
|
||||||
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Insert_Click"/>
|
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Insert_Click"/>
|
||||||
|
|||||||
@@ -276,6 +276,12 @@ namespace DyeingComputer.View
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ParameterSet_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (MainWindowViewModel.WORK_RUN == 2) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
|
if (MainWindowViewModel.WORK_RUN == 2) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ using static DyeingComputer.Windows.ViewStep;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Runtime.Remoting.Channels;
|
using System.Runtime.Remoting.Channels;
|
||||||
using System.Diagnostics.Eventing.Reader;
|
using System.Diagnostics.Eventing.Reader;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
@@ -236,22 +238,10 @@ namespace DyeingComputer.ViewModel
|
|||||||
public static string ProgramName = "-----";//工艺名
|
public static string ProgramName = "-----";//工艺名
|
||||||
public static Int32 DIDETime; //空闲计时器
|
public static Int32 DIDETime; //空闲计时器
|
||||||
bool ERR_JOG;//故障状态
|
bool ERR_JOG;//故障状态
|
||||||
|
private int timer1s_ = 0;
|
||||||
|
private int timer5s_ = 0;
|
||||||
public void CountDown()
|
public void CountDown()
|
||||||
{
|
{
|
||||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
||||||
{
|
|
||||||
Interval = TimeSpan.FromSeconds(1)//秒
|
|
||||||
};
|
|
||||||
timer1s.Tick += Tick_Event_1S;
|
|
||||||
timer1s.Start();
|
|
||||||
|
|
||||||
DispatcherTimer timer5s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
||||||
{
|
|
||||||
Interval = TimeSpan.FromSeconds(5)//
|
|
||||||
};
|
|
||||||
timer5s.Tick += Tick_Event_5S;
|
|
||||||
timer5s.Start();
|
|
||||||
|
|
||||||
//设置定时器
|
//设置定时器
|
||||||
DispatcherTimer disTimer = new DispatcherTimer
|
DispatcherTimer disTimer = new DispatcherTimer
|
||||||
{
|
{
|
||||||
@@ -260,7 +250,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
disTimer.Tick += DisTimer_200MS;
|
disTimer.Tick += DisTimer_200MS;
|
||||||
disTimer.Start();//计时开始
|
disTimer.Start();//计时开始
|
||||||
}//时间周期初始化
|
}//时间周期初始化
|
||||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
void Tick_Event_1S()//Tick_Event周期执行事件1S
|
||||||
{
|
{
|
||||||
SYSTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
SYSTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
Sys_Time = SYSTime.ToString();
|
Sys_Time = SYSTime.ToString();
|
||||||
@@ -287,18 +277,22 @@ namespace DyeingComputer.ViewModel
|
|||||||
Alert_bell = !Alert_bell;
|
Alert_bell = !Alert_bell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||||
{
|
{
|
||||||
if (!LINK_OK) Modbus_link();
|
//if(WORK_RUN !=0)
|
||||||
|
Chart();//写入记录
|
||||||
if(WORK_RUN !=0) Chart();//写入记录
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160)))
|
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160)))
|
||||||
{ Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
{ Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
||||||
}
|
}
|
||||||
void DisTimer_200MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
void DisTimer_200MS(object sender, EventArgs e)//Tick_Event周期执行事件200MS
|
||||||
{
|
{
|
||||||
if (LINK_OK) Modbus_link();
|
timer1s_++;
|
||||||
|
timer5s_++;
|
||||||
|
|
||||||
|
if (timer1s_ > 5) Tick_Event_1S();
|
||||||
|
if (timer5s_ > 25) Tick_Event_5S();
|
||||||
|
|
||||||
if (LINK_OK) IO_data();
|
if (LINK_OK) IO_data();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Name_err.ToString()) && (!ERR_JOG)) //有故障信息,无故障保持
|
if (!string.IsNullOrEmpty(Name_err.ToString()) && (!ERR_JOG)) //有故障信息,无故障保持
|
||||||
@@ -1440,9 +1434,10 @@ namespace DyeingComputer.ViewModel
|
|||||||
port.DataBits = 8;
|
port.DataBits = 8;
|
||||||
port.Parity = Parity.None;
|
port.Parity = Parity.None;
|
||||||
port.StopBits = StopBits.One;
|
port.StopBits = StopBits.One;
|
||||||
port.ReadTimeout = 100;
|
port.ReadTimeout = 1000;
|
||||||
port.WriteTimeout = 100;
|
port.WriteTimeout = 1000;
|
||||||
port.Open();//打开串口
|
port.Open();//打开串口
|
||||||
|
Modbus_link();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -1471,15 +1466,15 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
LINK_RUN++;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
master.WriteMultipleCoils(slaveId, 02000, DQ); //写入线圈
|
|
||||||
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
|
||||||
DO = master.ReadCoils(slaveId, 02255, DO_L); //读取线圈
|
DO = master.ReadCoils(slaveId, 02255, DO_L); //读取线圈
|
||||||
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
||||||
|
master.WriteMultipleCoils(slaveId, 02000, DQ); //写入线圈
|
||||||
|
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
||||||
LINK_OK = true;
|
LINK_OK = true;
|
||||||
Name_err = "";
|
Name_err = "";
|
||||||
|
LINK_RUN++;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1487,10 +1482,13 @@ namespace DyeingComputer.ViewModel
|
|||||||
LINK_ERR++;
|
LINK_ERR++;
|
||||||
Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")";
|
Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")";
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Modbus_link();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}//发送
|
||||||
public static string SYSlog;
|
public static string SYSlog;
|
||||||
void LOG_view()//细节页面
|
void LOG_view()//细节页面
|
||||||
{
|
{
|
||||||
@@ -1499,7 +1497,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
SYSlog = SYSlog + "\n" + Resources.Compute + Resources.Temperature + " : " + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1005"))) + "°C";//显示计算温度
|
SYSlog = SYSlog + "\n" + Resources.Compute + Resources.Temperature + " : " + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1005"))) + "°C";//显示计算温度
|
||||||
SYSlog = SYSlog + " | " + Resources.ProportionalValves + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1004")) / 10) + "%";//显示比例
|
SYSlog = SYSlog + " | " + Resources.ProportionalValves + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1004")) / 10) + "%";//显示比例
|
||||||
int IO1015 = Convert.ToInt16(Selet_dtm("1015"));
|
int IO1015 = Convert.ToInt16(Selet_dtm("1015"));
|
||||||
if (IO1015 < MT39)
|
if (IO1015 <= MT39)
|
||||||
{
|
{
|
||||||
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.Low_waterlevel + "]";//显示水位
|
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.Low_waterlevel + "]";//显示水位
|
||||||
}
|
}
|
||||||
@@ -1507,7 +1505,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.Mid_waterlevel + "]";//显示水位
|
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.Mid_waterlevel + "]";//显示水位
|
||||||
}
|
}
|
||||||
else if (IO1015 > MT38)
|
else if (IO1015 >= MT38)
|
||||||
{
|
{
|
||||||
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.High_waterlevel + "]";//显示水位
|
SYSlog = SYSlog + "\n" + Resources.MasterCylinder + Resources.WaterLevel + " : " + string.Format("{0:D4}", IO1015) + "L =>[" + Resources.High_waterlevel + "]";//显示水位
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user