首次上传

This commit is contained in:
hanqiangqiang
2026-06-15 10:56:30 +08:00
commit b0213b94d6
4160 changed files with 736101 additions and 0 deletions
@@ -0,0 +1,316 @@
using MECF.Framework.Common.Equipment;
using MECF.Framework.Simulator.Core.SubstrateTrackings;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace MECF.Framework.Simulator.Core.Robots.Sunway
{
public class SunwayRobotSimulator : RobotSimulator
{
public enum OperateEnum
{
Null,
RSR,
INPUT,
STAT,
RQ,
RSRWafer,
RSRTray
}
protected Random _rd = new Random();
public bool IsError { get; set; }
public string ErrorCode { get; set; }
public bool StateChecked { get; set; }
public int StateCode { get; set; }
public bool EventChecked { get; set; }
public string EventCode { get; set; }
private static string msgDone = "_RDY";
private static string msgError = "_ERR";
private static string msgRSRCassA = "MAP 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 ?";
private static string msgRSRCassB = "MAP 1 2 3 0 1 2 3 0";
private static string msgRSR = "1";
private string lastMsg = "";
private System.Timers.Timer timer;
OperateEnum operateEnum = OperateEnum.Null;
public string CassetteResult { get; set; }
Dictionary<int, string> ModuleAssociateStationDic;
public SunwayRobotSimulator(int port) : base(port, 0, "\r\n", ' ', 5)
{
AddCommandHandler("HOME", HandleHome);
AddCommandHandler("RQ", HandleRQLoad);
AddCommandHandler("GOTO", HandleHome);
AddCommandHandler("MAP", HandleMap);
AddCommandHandler("RSR", HandleRSR);
AddCommandHandler("PICK", HandleHome);
AddCommandHandler("PLACE", HandleHome);
AddCommandHandler("VAC", HandleHome);
AddCommandHandler("SET", HandleHome);
AddCommandHandler("SVON", HandleHome);
AddCommandHandler("ERR", HandleErr);
AddCommandHandler("OUTP", HandleHome);
AddCommandHandler("MOVR", HandleHome);
AddCommandHandler("RETH", HandleHome);
AddCommandHandler("INPUT", HandleInput);
AddCommandHandler("OUPT", HandleHome);
ErrorCode = "0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000";
ModuleAssociateStationDic = new Dictionary<int, string>()
{
{1,$"{ModuleName.PM1 }"},
{2,$"{ModuleName.PM2}" },
{3,$"{ModuleName.Buffer}1"},
{4,$"{ModuleName.Buffer}2"},
{5,$"{ModuleName.Buffer}3"},
{6,$"{ModuleName.LoadLock}"},
{7,$"{ModuleName.UnLoad}"},
{8,$"{ModuleName.Aligner}"},
{9,$"{ModuleName.CassAL}"},
{10,$"{ModuleName.CassAR}"},
{12,$"{ModuleName.CassBL}"},
};
timer = new System.Timers.Timer();
timer.Enabled = false;
timer.AutoReset = false;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
}
internal void HandleErr(string msg)
{
lastMsg = msg;
if (IsError)
OnWriteMessage(string.IsNullOrEmpty(ErrorCode) ? @"FFFF, FFFF, FFFF, FFFF, FFFF, FFFF, FFFF, FFFF" : ErrorCode);
else
OnWriteMessage("0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000");
}
internal void HandleStat(string msg)
{
lastMsg = msg;
OnWriteMessage(StateCode.ToString());
}
internal void HandleHome(string msg)
{
lastMsg = msg;
operateEnum = OperateEnum.Null;
HandleMove(RobotStateEnum.Homing, new string[] { "" });
}
internal void HandleRQLoad(string msg)
{
lastMsg = msg;
operateEnum = OperateEnum.Null;
OnWriteMessage($"LOAD A OFF/r/n_RDY");
}
internal void HandleGetSp(string msg)
{
// GETSP B 11 1
lastMsg = msg;
operateEnum = OperateEnum.Null;
HandleGetSp(RobotStateEnum.Picking, msg.Split(' '));
}
internal void HandleInput(string msg)
{
lastMsg = msg;
operateEnum = OperateEnum.INPUT;
HandleInput(RobotStateEnum.Input, new string[] { "" });
}
internal void HandleMap(string msg)
{
lastMsg = msg;
HandleMap(RobotStateEnum.MAP, new string[] { "" });
}
internal void HandleRSR(string msg)
{
int cassette = int.Parse(msg.Replace("RSR", "").Trim());
if (ModuleAssociateStationDic[cassette] == ModuleName.CassAL.ToString() || ModuleAssociateStationDic[cassette] == ModuleName.CassAR.ToString())
{
operateEnum = OperateEnum.RSRWafer;
}
else
{
operateEnum = OperateEnum.RSRTray;
}
HandleRSR(RobotStateEnum.RSR, new string[] { "" });
}
internal void HandleSTAT(string msg)
{
operateEnum = OperateEnum.STAT;
HandleSTAT(RobotStateEnum.STAT, new string[] { "" });
}
internal void SetResult()
{
msgRSRCassA = CassetteResult;
}
private bool HandleRSR(RobotStateEnum action, string[] cmdComponents)
{
if (robotStateArgs.State != RobotStateEnum.Idle &&
(action == RobotStateEnum.Homing && robotStateArgs.State != RobotStateEnum.Errored)) // allow homes when in error, but not other moves
{
HandleError("Already moving");
return false;
}
double delay = 1;
timer.Interval = delay * 1000;
timer.Enabled = true;
return true;
}
private bool HandleSTAT(RobotStateEnum action, string[] cmdComponents)
{
if (robotStateArgs.State != RobotStateEnum.Idle &&
(action == RobotStateEnum.Homing && robotStateArgs.State != RobotStateEnum.Errored)) // allow homes when in error, but not other moves
{
HandleError("Already moving");
return false;
}
double delay = 1;
timer.Interval = delay * 1000;
timer.Enabled = true;
return true;
}
internal void HandleUnknown(string msg)
{
OnWriteMessage(msgError);
}
private bool HandleMove(RobotStateEnum action, string[] cmdComponents)
{
if (robotStateArgs.State != RobotStateEnum.Idle &&
(action == RobotStateEnum.Homing && robotStateArgs.State != RobotStateEnum.Errored)) // allow homes when in error, but not other moves
{
HandleError("Already moving");
return false;
}
ErrorCode = "0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000";
double delay = 1;
timer.Interval = delay * 1000;
timer.Enabled = true;
return true;
}
private bool HandleGetSp(RobotStateEnum action, string[] args)
{
if (IsError && args[3] == "1")
{
ErrorCode = "0000, 0000, 0000, 0001, 0000, 0000, 0001, 0001";
OnWriteMessage(msgError);
return true;
}
OnWriteMessage(msgDone);
return true;
}
private bool HandleInput(RobotStateEnum action, string[] cmdComponents)
{
if (robotStateArgs.State != RobotStateEnum.Idle &&
(action == RobotStateEnum.Homing && robotStateArgs.State != RobotStateEnum.Errored)) // allow homes when in error, but not other moves
{
HandleError("Already moving");
return false;
}
double delay = 1;
timer.Interval = delay * 1000;
timer.Enabled = true;
return true;
}
private bool HandleMap(RobotStateEnum action, string[] cmdComponents)
{
if (robotStateArgs.State != RobotStateEnum.Idle
&& (action == RobotStateEnum.Homing && robotStateArgs.State != RobotStateEnum.Errored)
) // allow homes when in error, but not other moves
{
HandleError("Already moving");
return false;
}
double delay = 1;
timer.Interval = delay * 1000;
timer.Enabled = true;
return true;
}
private void HandleError(string msg)
{
OnWriteMessage(msgError);
}
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
SetRobotState(RobotStateEnum.Idle);
timer.Enabled = false;
this.CassetteResult = msgRSRCassA;
if (operateEnum == OperateEnum.STAT)
{
OnWriteMessage("19568");
}
else if (operateEnum == OperateEnum.RSRWafer)
{
OnWriteMessage(msgRSRCassA);
}
else if (operateEnum == OperateEnum.RSRTray)
{
OnWriteMessage(msgRSRCassB);
}
else if (operateEnum == OperateEnum.INPUT)
{
OnWriteMessage("1");
}
else
{
OnWriteMessage(msgDone);
}
}
}
}
@@ -0,0 +1,174 @@
<UserControl
x:Class="MECF.Framework.Simulator.Core.Robots.Sunway.SunwayTrayRobotView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Robots.Sunway"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="900"
Height="900"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="150" />
<RowDefinition Height="50" />
<RowDefinition Height="400" />
</Grid.RowDefinitions>
<commons:SocketTitleView Grid.Row="0" />
<Canvas Grid.Row="1" Width="900">
<CheckBox
Canvas.Left="36"
Canvas.Top="73"
Content="Error"
IsChecked="{Binding IsError}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="52"
Text="_ERR {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="72"
Text="Error Code:" />
<!--<TextBox Text="{Binding ResultValue, UpdateSourceTrigger=PropertyChanged }" Canvas.Left="358" Canvas.Top="31" Margin="0" Width="284"></TextBox>
<TextBlock Text="Error:" Canvas.Left="310" Canvas.Top="45"></TextBlock>-->
<TextBox
Canvas.Left="203"
Canvas.Top="70"
Width="369"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="10"
Text="_STA {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="30"
Text="State Code:" />
<TextBox
Canvas.Left="203"
Canvas.Top="28"
Width="74"
Margin="0"
IsReadOnly="False"
Text="{Binding StateCode, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox
Canvas.Left="36"
Canvas.Top="110"
Content="Event"
IsChecked="{Binding EventChecked}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="91"
Text="_Event {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="110"
Text="Event Code:" />
<TextBox
Canvas.Left="203"
Canvas.Top="107"
Width="550"
Margin="0"
IsReadOnly="False"
Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" />
</Canvas>
<StackPanel
Grid.Row="2"
Width="900"
Orientation="Horizontal">
<Button
Width="100"
Height="35"
Command="{Binding ClearLogCommand}"
Content="Clear Log" />
<Label
Width="150"
Height="35"
Padding="5,5"
Background="White"
Content="CassetteResult" />
<TextBox
Name="textBoxResult"
Width="500"
Height="35"
Padding="5,5"
Background="White"
Text="{Binding CassetteResult}"
TextAlignment="Center" />
<Button
Width="100"
Height="35"
Command="{Binding SetResult}"
Content="Set Result" />
</StackPanel>
<DataGrid
Grid.Row="3"
Width="900"
Height="380"
VerticalAlignment="Top"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
FontSize="16"
ItemsSource="{Binding TransactionLogItems}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn
Width="160"
Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"
Header="Time"
IsReadOnly="True" />
<DataGridTextColumn
Width="350"
Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}"
Header="Incoming"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="350"
Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}"
Header="Outgoing"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>
@@ -0,0 +1,98 @@
using Aitex.Core.UI.MVVM;
using Aitex.Core.Utilities;
using MECF.Framework.Simulator.Core.Commons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MECF.Framework.Simulator.Core.Robots.Sunway
{
/// <summary>
/// SunwayTrayRobotView.xaml 的交互逻辑
/// </summary>
public partial class SunwayTrayRobotView : UserControl
{
public SunwayTrayRobotView()
{
InitializeComponent();
this.DataContext = new SunwayTrayRobotViewModel();
this.Loaded += OnViewLoaded;
}
private void OnViewLoaded(object sender, RoutedEventArgs e)
{
(DataContext as TimerViewModelBase).Start();
}
}
class SunwayTrayRobotViewModel : SocketDeviceViewModel
{
public string Title => "Sunway Tray Robot Simulator";
private SunwayRobotSimulator _robot;
public bool IsError
{
get => _robot.IsError;
set => _robot.IsError = value;
}
//private string _value;
[IgnorePropertyChange]
public string ErrorCode
{
get => _robot.ErrorCode;
set => _robot.ErrorCode = value;
}
public bool StateChecked
{
get => _robot.StateChecked;
set => _robot.StateChecked = value;
}
public int StateCode
{
get => _robot.StateCode;
set => _robot.StateCode = value;
}
public bool EventChecked
{
get => _robot.EventChecked;
set
{
_robot.EventChecked = value;
if (value) EventCode = "_EVENT ROBOR 02610 0003 B -00028 000028 000028 -00002\r";
else EventCode = null;
}
}
[IgnorePropertyChange]
public string EventCode
{
get => _robot.EventCode;
set => _robot.EventCode = value;
}
public SunwayTrayRobotViewModel() : base("SunwayRobotViewModel")
{
_robot = new SunwayRobotSimulator(1104);
Init(_robot);
}
}
}
@@ -0,0 +1,174 @@
<UserControl
x:Class="MECF.Framework.Simulator.Core.Robots.Sunway.SunwayWaferRobotView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Robots.Sunway"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="900"
Height="900"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="150" />
<RowDefinition Height="50" />
<RowDefinition Height="400" />
</Grid.RowDefinitions>
<commons:SocketTitleView Grid.Row="0" />
<Canvas Grid.Row="1" Width="900">
<CheckBox
Canvas.Left="36"
Canvas.Top="73"
Content="Error"
IsChecked="{Binding IsError}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="52"
Text="_ERR {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="72"
Text="Error Code:" />
<!--<TextBox Text="{Binding ResultValue, UpdateSourceTrigger=PropertyChanged }" Canvas.Left="358" Canvas.Top="31" Margin="0" Width="284"></TextBox>
<TextBlock Text="Error:" Canvas.Left="310" Canvas.Top="45"></TextBlock>-->
<TextBox
Canvas.Left="203"
Canvas.Top="70"
Width="369"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="10"
Text="_STA {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="30"
Text="State Code:" />
<TextBox
Canvas.Left="203"
Canvas.Top="28"
Width="74"
Margin="0"
IsReadOnly="False"
Text="{Binding StateCode, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox
Canvas.Left="36"
Canvas.Top="110"
Content="Event"
IsChecked="{Binding EventChecked}" />
<TextBlock
Canvas.Left="204"
Canvas.Top="91"
Text="_Event {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="110"
Text="Event Code:" />
<TextBox
Canvas.Left="203"
Canvas.Top="107"
Width="550"
Margin="0"
IsReadOnly="False"
Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" />
</Canvas>
<StackPanel
Grid.Row="2"
Width="900"
Orientation="Horizontal">
<Button
Width="100"
Height="35"
Command="{Binding ClearLogCommand}"
Content="Clear Log" />
<Label
Width="150"
Height="35"
Padding="5,5"
Background="White"
Content="CassetteResult" />
<TextBox
Name="textBoxResult"
Width="500"
Height="35"
Padding="5,5"
Background="White"
Text="{Binding CassetteResult}"
TextAlignment="Center" />
<Button
Width="100"
Height="35"
Command="{Binding SetResult}"
Content="Set Result" />
</StackPanel>
<DataGrid
Grid.Row="3"
Width="900"
Height="380"
VerticalAlignment="Top"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
FontSize="16"
ItemsSource="{Binding TransactionLogItems}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn
Width="160"
Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"
Header="Time"
IsReadOnly="True" />
<DataGridTextColumn
Width="350"
Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}"
Header="Incoming"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="350"
Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}"
Header="Outgoing"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>
@@ -0,0 +1,96 @@
using Aitex.Core.UI.MVVM;
using Aitex.Core.Utilities;
using MECF.Framework.Simulator.Core.Commons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MECF.Framework.Simulator.Core.Robots.Sunway
{
/// <summary>
/// SunwayWaferRobotView.xaml 的交互逻辑
/// </summary>
public partial class SunwayWaferRobotView : UserControl
{
public SunwayWaferRobotView()
{
InitializeComponent();
this.DataContext = new SunwayWaferRobotViewModel();
this.Loaded += OnViewLoaded;
}
private void OnViewLoaded(object sender, RoutedEventArgs e)
{
(DataContext as TimerViewModelBase).Start();
}
}
class SunwayWaferRobotViewModel : SocketDeviceViewModel
{
public string Title => "Sunway Wafer Robot Simulator";
private SunwayRobotSimulator _robot;
public bool IsError
{
get => _robot.IsError;
set => _robot.IsError = value;
}
//private string _value;
[IgnorePropertyChange]
public string ErrorCode
{
get => _robot.ErrorCode;
set => _robot.ErrorCode = value;
}
public bool StateChecked
{
get => _robot.StateChecked;
set => _robot.StateChecked = value;
}
public int StateCode
{
get => _robot.StateCode;
set => _robot.StateCode = value;
}
public bool EventChecked
{
get => _robot.EventChecked;
set
{
_robot.EventChecked = value;
if (value) EventCode = "_EVENT ROBOR 02610 0003 B -00028 000028 000028 -00002\r";
else EventCode = null;
}
}
[IgnorePropertyChange]
public string EventCode
{
get => _robot.EventCode;
set => _robot.EventCode = value;
}
public SunwayWaferRobotViewModel() : base("SunwayRobotViewModel")
{
_robot = new SunwayRobotSimulator(1103);
Init(_robot);
}
}
}