模拟器增加模拟速度设置。

This commit is contained in:
DESKTOP-GPE37UV\THINKAPD 2022-11-12 23:10:04 +08:00
parent 1d3fa65d1e
commit 41e5539848
9 changed files with 90 additions and 32 deletions

View File

@ -29,6 +29,8 @@ namespace MECF.Framework.UI.Core.Applications
get { return _instance; }
}
public event EventHandler<int> OnSimulationSpeedChanged;
public event Action OnWindowsLoaded;
private IUiInstance _instance;
@ -174,6 +176,11 @@ namespace MECF.Framework.UI.Core.Applications
MaxSizeShow = _instance.MaxSizeShow,
};
_views.OnSimulationSpeedChanged += (sender, speed) =>
{
OnSimulationSpeedChanged?.Invoke(this, speed);
};
//SetCulture((language != null && (int)(language) == 2) ? "zh-CN" : "en-US");
@ -228,6 +235,7 @@ namespace MECF.Framework.UI.Core.Applications
return true;
}
void views_OnMainWindowLoaded()
{
if (OnWindowsLoaded != null)

View File

@ -2,10 +2,21 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.UI.Core.E95Template"
Width="1920" Height="80" Background="{StaticResource mainBackgroundColor}">
Background="{StaticResource mainBackgroundColor}">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
<StackPanel.Resources>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="5 5"/>
</Style>
</StackPanel.Resources>
<RadioButton x:Name="rbtnSimSpeed1x" Content="1x" IsChecked="True" Checked="RbtnSimSpeed1x_OnChecked"/>
<RadioButton x:Name="rbtnSimSpeed2x" Content="2x" Checked="RbtnSimSpeed2x_OnChecked"/>
<RadioButton x:Name="rbtnSimSpeed4x" Content="4x" Checked="RbtnSimSpeed4x_OnChecked"/>
</StackPanel>
</Grid>
</UserControl>

View File

@ -21,6 +21,8 @@ namespace MECF.Framework.UI.Core.E95Template
/// </summary>
public partial class DefaultTopView : UserControl, ITopView
{
public event EventHandler<int> OnSimulationSpeedChanged;
public DefaultTopView()
{
InitializeComponent();
@ -30,5 +32,20 @@ namespace MECF.Framework.UI.Core.E95Template
{
}
private void RbtnSimSpeed1x_OnChecked(object sender, RoutedEventArgs e)
{
OnSimulationSpeedChanged?.Invoke(this, 1);
}
private void RbtnSimSpeed2x_OnChecked(object sender, RoutedEventArgs e)
{
OnSimulationSpeedChanged?.Invoke(this, 2);
}
private void RbtnSimSpeed4x_OnChecked(object sender, RoutedEventArgs e)
{
OnSimulationSpeedChanged?.Invoke(this, 4);
}
}
}

View File

@ -4,16 +4,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="980" d:DesignWidth="1920"
d:DesignHeight="1080" d:DesignWidth="1920"
ShowInTaskbar="True"
WindowState="Maximized">
<Viewbox Stretch="Fill" >
<Border BorderBrush="Gray" BorderThickness="1" Margin="1" CornerRadius="4" Padding="1" >
<Grid x:Name="CenterGrid" Width="1920" Height="1020">
<Grid x:Name="CenterGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition x:Name="TopRow" Height="60" />
<RowDefinition x:Name="CenterRow" Height="890" />
<RowDefinition x:Name="BottomRow" Height="70" />
<RowDefinition x:Name="TopRow" Height="Auto" />
<RowDefinition x:Name="CenterRow" Height="*" />
<RowDefinition x:Name="BottomRow" Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" x:Name="TopPanel" ></Grid>
<Grid Grid.Row="1" x:Name="CenterPanel" ></Grid>

View File

@ -2,19 +2,15 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Controls;
using System.Reflection;
using System.Windows;
using Aitex.Core.Account;
using MECF.Framework.Common.Properties;
using MECF.Framework.UI.Core.Properties;
using Autofac;
using Aitex.Core.UI.View.Common;
using MECF.Framework.UI.Core.Applications;
using MECF.Framework.UI.Core.E95Template;
namespace Aitex.Core.UI.View.Frame
{
@ -23,6 +19,8 @@ namespace Aitex.Core.UI.View.Frame
public const string Culture_CN = "zh-CN";
public const string Culture_EN = "en-US";
public event EventHandler<int> OnSimulationSpeedChanged;
public List<string> GetAllViewList
{
get { return _views == null ? null : _views.ViewIdList; }
@ -90,6 +88,13 @@ namespace Aitex.Core.UI.View.Frame
throw new ApplicationException(string.Format("在程序集{0}中,没有找到{1}请检查UILayout配置文件中的设置", ViewAssembly, _views.TitleView.ViewClass));
}
UserControl uc = (UserControl)_topView;
if (_topView is DefaultTopView view)
{
view.OnSimulationSpeedChanged += delegate(object sender, int speed)
{
OnSimulationSpeedChanged?.Invoke(this, speed);
};
}
_bottomView.CreateMenu(_views.NavigationView);
_bottomView.ButtonClicked += new Action<string>(_bottomView_ButtonClicked);
@ -116,11 +121,11 @@ namespace Aitex.Core.UI.View.Frame
WindowState = MaxSizeShow ? WindowState.Maximized : WindowState.Normal,
};
_mainWindow.CenterGrid.Width = PreferWidth;
/*_mainWindow.CenterGrid.Width = PreferWidth;
_mainWindow.CenterGrid.Height = PreferHeight;
_mainWindow.TopRow.Height = new GridLength(PreferHeightTopPanel);
_mainWindow.CenterRow.Height = new GridLength(PreferHeightCenterPanel);
_mainWindow.BottomRow.Height = new GridLength(PreferHeightBottomPanel);
_mainWindow.BottomRow.Height = new GridLength(PreferHeightBottomPanel);*/
_centerView.Height = PreferHeightCenterPanel;

View File

@ -14,6 +14,10 @@ namespace SicSimulator
base.OnStartup(e);
UiApplication.Instance.Initialize(new UiInstance());
UiApplication.Instance.OnSimulationSpeedChanged += delegate(object sender, int speed)
{
SimulatorSystem.Instance.SetSimulationSpeed(speed);
};
SimulatorSystem.Instance.Initialize();
}

View File

@ -14,7 +14,7 @@ namespace SicSimulator.Instances
public class SimulatorSystem : Singleton<SimulatorSystem>
{
private PeriodicJob _thread;
private int _simSpeed = 1;
Random _rd = new Random();
public SimulatorSystem()
@ -22,6 +22,19 @@ namespace SicSimulator.Instances
}
/// <summary>
/// 设置仿真速度。
/// </summary>
/// <param name="speed"></param>
public void SetSimulationSpeed(int speed)
{
_simSpeed = speed;
if (_simSpeed != 1 || _simSpeed != 2 || _simSpeed != 4)
{
_simSpeed = 1;
}
}
public void Initialize()
{
SetDefaultValue("PM1");
@ -418,13 +431,13 @@ namespace SicSimulator.Instances
if (current >= setpoint)
{
result = current - 50;
result = current - (50 * _simSpeed);
if (result < setpoint)
result = setpoint;
}
if (current < setpoint)
{
result = current + 50;
result = current + (50 * _simSpeed);
if (result > setpoint)
result = setpoint;
}
@ -685,28 +698,28 @@ namespace SicSimulator.Instances
}
else if (isSlowPum)
{
pressure -= 2;
pressure -= (2 * _simSpeed);
}
if (isSlowVent)
{
if (pressure < 300)
{
pressure += 2;
pressure += (2 * _simSpeed);
}
else if (pressure < 400)
{
pressure += 10;
pressure += (10 * _simSpeed);
}
else
{
pressure += 100;
pressure += (100 * _simSpeed);
}
}
if (isV121)
{
pressure -= 0.5;
pressure -= (0.5 * _simSpeed);
}
@ -834,7 +847,7 @@ namespace SicSimulator.Instances
if (IO.DO["DO_LoadLifterCYUp"].Value != IO.DO["DO_LoadLifterCYDown"].Value)
{
time1++;
time1 += _simSpeed;
if (time1 > 10)
{
time1 = 0;
@ -844,7 +857,7 @@ namespace SicSimulator.Instances
}
if (IO.DO["DO_LoadWaferCYClamp"].Value != IO.DO["DO_LoadWaferCYOpen"].Value)
{
time2++;
time2 += _simSpeed;
if (time2 > 10)
{
time2 = 0;
@ -854,7 +867,7 @@ namespace SicSimulator.Instances
}
if (IO.DO["DO_LoadTrayCYClamp"].Value != IO.DO["DO_LoadTrayCYOpen"].Value)
{
time3++;
time3 += _simSpeed;
if (time3 > 10)
{
time3 = 0;
@ -864,7 +877,7 @@ namespace SicSimulator.Instances
}
if (IO.DO["DO_UnloadStationWaferCYClamp"].Value != IO.DO["DO_UnloadStationWaferCYOpen"].Value)
{
time4++;
time4 += _simSpeed;
if (time4 > 10)
{
time4 = 0;
@ -874,7 +887,7 @@ namespace SicSimulator.Instances
}
if (IO.DO["DO_UnloadStationLifterCYUp"].Value != IO.DO["DO_UnloadStationLifterCYDown"].Value)
{
time5++;
time5 += _simSpeed;
if (time5 > 10)
{
time5 = 0;
@ -987,7 +1000,7 @@ namespace SicSimulator.Instances
{
if (IO.DO[$"{pm}.DO_ChamMoveBodyUp"].Value != IO.DO[$"{pm}.DO_ChamMoveBodyDown"].Value)
{
timeMoveUp++;
timeMoveUp += _simSpeed;
if (timeMoveUp > 20)
{
IO.DI[$"{pm}.DI_ChamMoveBodyUp"].Value = IO.DO[$"{pm}.DO_ChamMoveBodyUp"].Value;
@ -1006,7 +1019,7 @@ namespace SicSimulator.Instances
{
if (IO.DO[$"{pm}.DO_ChamMoveBodyForward"].Value != IO.DO[$"{pm}.DO_ChamMoveBodyBackward"].Value)
{
timeMove++;
timeMove += _simSpeed;
if (timeMove > 20)
{
IO.DI[$"{pm}.DI_ChamMoveBodyFront"].Value = IO.DO[$"{pm}.DO_ChamMoveBodyForward"].Value;
@ -1074,7 +1087,7 @@ namespace SicSimulator.Instances
if (IO.DO[$"{pm}.DO_SHLidLoosen"].Value != IO.DO[$"{pm}.DO_SHLidTighten"].Value)
{
timeMove++;
timeMove += _simSpeed;
if (timeMove > 20)
{
IO.DI[$"{pm}.DI_SHLidLoosen"].Value = IO.DO[$"{pm}.DO_SHLidLoosen"].Value;
@ -1085,7 +1098,7 @@ namespace SicSimulator.Instances
}
if (IO.DO[$"{pm}.DO_MiddleLidLoosen"].Value != IO.DO[$"{pm}.DO_MiddleLidTighten"].Value)
{
timeMove++;
timeMove += _simSpeed;
if (timeMove > 20)
{
IO.DI[$"{pm}.DI_MiddleLidLoosen"].Value = IO.DO[$"{pm}.DO_MiddleLidLoosen"].Value;