1.测试Home和RQ LOAD指令完成

This commit is contained in:
HCL 2023-12-05 15:53:17 +08:00
parent e63b7ac4e5
commit cec02459c6
10 changed files with 959 additions and 163 deletions

View File

@ -1,4 +1,5 @@
using Aitex.Core.RT.DataCenter;
using Aitex.Core.Common;
using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.OperationCenter;
@ -628,6 +629,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
{
waferCount = 25;
}
if (data.Length == 25)//Wafer Cassette
{
for (int i = 0; i < waferCount; i++)
@ -662,23 +664,34 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
}
}
else if (data.Length == 1)
else if (data.Length <=10)
{
if (data == "0")
if (data == "LOAD A ON")
{
if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), 0))
if (Module=="WaferRobot" && !WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.CreateWafer(ModuleHelper.Converter(Module), 0, Aitex.Core.Common.WaferStatus.Normal);
WaferManager.Instance.CreateWafer(ModuleHelper.Converter(Module), 0, WaferStatus.Normal);
}
if (Module == "TrayRobot" && !WaferManager.Instance.CheckHasTray(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.CreateTray(ModuleHelper.Converter(Module), 0, TrayStatus.Normal);
}
}
else if (data == "1")
else if (data == "LOAD A OFF")
{
if (WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), 0))
if (Module == "WaferRobot" && WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0);
}
if (Module == "TrayRobot" && WaferManager.Instance.CheckHasTray(ModuleHelper.Converter(Module), 0))
{
WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0);
}
}
}
if (!String.IsNullOrEmpty(errorMessage))
{
EV.PostWarningLog(Module, $"Module {CurrentInteractModule} {errorMessage}");
@ -771,11 +784,9 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
_lstHandler.Clear();
lock (_locker)
{
_lstHandler.AddLast(new SunwayRobotSVONHandler(this));
//Robot Home指令包含了清除报警电机使能Home动作
_lstHandler.AddLast(new SunwayRobotHomeHandler(this, _scMotionTimeout.IntValue));
_lstHandler.AddLast(new SunwayRobotOutpOpenHandler(this));
_lstHandler.AddLast(new SunwayRobotINPUTHandler(this));
_lstHandler.AddLast(new SunwayRobotOutpCloseHandler(this));
_lstHandler.AddLast(new SunwayRobotRQLoadHandler(this));
}
}

View File

@ -1,5 +1,6 @@
using Aitex.Core.RT.Log;
using MECF.Framework.Common.Communications;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps.AE;
using System;
using System.Collections.Generic;
using System.Linq;
@ -78,7 +79,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
else if (rawText.Contains("_RDY"))
{
msg.Data = rawText.Replace("_RDY", "");
msg.Data = rawText;
msg.IsResponse = true;
msg.IsAck = true;
@ -88,6 +89,8 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
{
msg.Data = rawText;
msg.IsResponse = true;
msg.IsAck = true;
msg.IsComplete = true;
}
return msg;

View File

@ -67,6 +67,99 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
}
public class SunwayRobotHomeHandler : SunwayRobotHandler
{
//HOM
public SunwayRobotHomeHandler(SunwayRobot device, int timeout = 60, Action onHandlerEndTask = null)
: base(device, $"HOME ALL", onHandlerEndTask: onHandlerEndTask)
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.Both,
BladeTarget = "ArmA.System",
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot HOM Timeout");
return true;
}
if (result.Data == "_RDY")
{
Device.IsBusy = false;
}
else if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot HOME Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
_onHandlerEndTask?.Invoke();
Device.NoteActionCompleted();
return true;
}
}
public class SunwayRobotRQLoadHandler : SunwayRobotHandler
{
// RQ LOAD
public SunwayRobotRQLoadHandler(SunwayRobot device, int timeout = 5)
: base(device, "RQ LOAD A")
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot RQ LOAD Timeout");
return true;
}
if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot RQ LOAD Error");
return false;
}
else
{
Device.SetWaferData(result.Data);
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
//Device.NoteActionCompleted();
handled = true;
return true;
}
}
public class SunwayRobotSTATHandler : SunwayRobotHandler
{
@ -851,6 +944,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
return true;
}
}
public class SunwayRobotMapHandler : SunwayRobotHandler
{
//MAP [module]
@ -1100,54 +1194,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Sunway
}
}
public class SunwayRobotHomeHandler : SunwayRobotHandler
{
//HOM
public SunwayRobotHomeHandler(SunwayRobot device, int timeout = 60, Action onHandlerEndTask = null)
: base(device, $"HOME","ALL", onHandlerEndTask: onHandlerEndTask)
{
AckTimeout = TimeSpan.FromSeconds(timeout);
CompleteTimeout = TimeSpan.FromSeconds(timeout);
device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.Both,
BladeTarget = "ArmA.System",
};
}
public override bool HandleMessage(MessageBase msg, out bool handled)
{
var result = msg as SunwayRobotMessage;
handled = false;
if (!result.IsResponse)
{
Device.NoteError("Robot HOM Timeout");
return true;
}
if (result.Data == "_RDY")
{
Device.IsBusy = false;
}
else if (result.Data.Contains("ERR"))
{
Device.NoteError("Robot HOME Response Error");
return false;
}
Device.MoveInfo = new RobotMoveInfo()
{
Action = RobotAction.Moving,
ArmTarget = RobotArm.ArmA,
BladeTarget = ModuleName.System.ToString(),
};
ResponseMessage = msg;
handled = true;
_onHandlerEndTask?.Invoke();
Device.NoteActionCompleted();
return true;
}
}
public class SunwayRobotMTCSPHandler : SunwayRobotHandler
{

View File

@ -1,13 +1,16 @@
<UserControl x:Class="MECF.Framework.Simulator.Core.Commons.SocketTitleView"
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:local="clr-namespace:MECF.Framework.Simulator.Core.Commons"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="800" Background="LightBlue">
<UserControl
x:Class="MECF.Framework.Simulator.Core.Commons.SocketTitleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Commons"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="100"
d:DesignWidth="800"
Background="LightBlue"
mc:Ignorable="d">
<UserControl.Resources>
<local:ConnectionStatusBackgroundConverter x:Key="connectionStatusBackgroundConverter"/>
<local:ConnectionStatusBackgroundConverter x:Key="connectionStatusBackgroundConverter" />
<Style TargetType="Label">
<Setter Property="FontSize" Value="16" />
@ -18,23 +21,45 @@
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Title}" FontSize="20" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Height="50" Background="{Binding IsConnected, Converter={StaticResource connectionStatusBackgroundConverter}}"></Label>
<Label
Grid.Row="0"
Height="50"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Background="{Binding IsConnected, Converter={StaticResource connectionStatusBackgroundConverter}}"
Content="{Binding Title}"
FontSize="20" />
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBox Text="{Binding LocalPortSetPoint, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }" VerticalContentAlignment="Center" Width="120" Margin="20,0,0,0" Height="35" />
<TextBox
Width="120"
Height="35"
Margin="20,0,0,0"
VerticalContentAlignment="Center"
Text="{Binding LocalPortSetPoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Label Content="Listen port:"></Label>
<Label Content="{Binding LocalPortSetPoint}"></Label>
<Label Content="Listen port:" />
<Label Content="{Binding LocalPortSetPoint}" />
<Label Content="{Binding ConnectionStatus}"></Label>
<Label Content="{Binding ConnectionStatus}" />
<Button Width="100" Height="35" Content="Enable" Command="{Binding EnableCommand}" IsEnabled="{Binding IsEnableEnable}"></Button>
<Button Width="100" Height="35" Content="Disable" Command="{Binding DisableCommand}" IsEnabled="{Binding IsEnableDisable}"></Button>
<Label Content="Connection:"></Label>
<Label Content="{Binding RemoteConnection}"></Label>
<Button
Width="100"
Height="35"
Command="{Binding EnableCommand}"
Content="Enable"
IsEnabled="{Binding IsEnableEnable}" />
<Button
Width="100"
Height="35"
Command="{Binding DisableCommand}"
Content="Disable"
IsEnabled="{Binding IsEnableDisable}" />
<Label Content="Connection:" />
<Label Content="{Binding RemoteConnection}" />
</StackPanel>
</Grid>

View File

@ -1,77 +1,138 @@
<UserControl x:Class="MECF.Framework.Simulator.Core.Robots.BrooksMag7RobotView"
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:local="clr-namespace:MECF.Framework.Simulator.Core.Aligners"
xmlns:deviceControl="clr-namespace:MECF.Framework.UI.Core.DeviceControl;assembly=MECF.Framework.UI.Core"
xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons"
Height="900" Width="900">
<UserControl
x:Class="MECF.Framework.Simulator.Core.Robots.BrooksMag7RobotView"
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:deviceControl="clr-namespace:MECF.Framework.UI.Core.DeviceControl;assembly=MECF.Framework.UI.Core"
xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Aligners"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="900"
Height="900">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="150"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="400"></RowDefinition>
<RowDefinition Height="100" />
<RowDefinition Height="150" />
<RowDefinition Height="50" />
<RowDefinition Height="400" />
</Grid.RowDefinitions>
<commons:SocketTitleView Grid.Row="0"></commons:SocketTitleView>
<commons:SocketTitleView Grid.Row="0" />
<Canvas Grid.Row="1" Width="900">
<Canvas Grid.Row="1" Width="900">
<CheckBox Content="Fail" IsChecked="{Binding IsFailed}" Canvas.Left="36" Canvas.Top="31"></CheckBox>
<CheckBox
Canvas.Left="36"
Canvas.Top="31"
Content="Fail"
IsChecked="{Binding IsFailed}" />
<TextBlock Text="_ERR {Code}" Canvas.Left="225" Canvas.Top="11"></TextBlock>
<TextBlock Text="Error Code:" Canvas.Left="129" Canvas.Top="45"></TextBlock>
<TextBlock
Canvas.Left="225"
Canvas.Top="11"
Text="_ERR {Code}" />
<TextBlock
Canvas.Left="129"
Canvas.Top="45"
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 Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" Canvas.Left="225" Canvas.Top="31" Margin="0" Width="74"/>
<TextBox
Canvas.Left="225"
Canvas.Top="31"
Width="74"
Margin="0"
Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="Event" IsChecked="{Binding EventChecked}" Canvas.Left="36" Canvas.Top="100"></CheckBox>
<CheckBox
Canvas.Left="36"
Canvas.Top="100"
Content="Event"
IsChecked="{Binding EventChecked}" />
<TextBlock Text="_Event {Code}" Canvas.Left="229" Canvas.Top="80"></TextBlock>
<TextBlock Text="Event Code:" Canvas.Left="129" Canvas.Top="110"></TextBlock>
<TextBlock
Canvas.Left="229"
Canvas.Top="80"
Text="_Event {Code}" />
<TextBlock
Canvas.Left="129"
Canvas.Top="110"
Text="Event Code:" />
<TextBox Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" Canvas.Left="225" Canvas.Top="100" Margin="0" Width="550" IsReadOnly="False"/>
<TextBox
Canvas.Left="225"
Canvas.Top="100"
Width="550"
Margin="0"
IsReadOnly="False"
Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" />
</Canvas>
<StackPanel Grid.Row="2" Orientation="Horizontal" Width="900">
<Button Content="Clear Log" Width="100" Height="35" Command="{Binding ClearLogCommand}"></Button>
<StackPanel
Grid.Row="2"
Width="900"
Orientation="Horizontal">
<Button
Width="100"
Height="35"
Command="{Binding ClearLogCommand}"
Content="Clear Log" />
</StackPanel>
<DataGrid Grid.Row="3" FontSize="16" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeRows="False" CanUserSortColumns="False" ItemsSource="{Binding TransactionLogItems}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
Width="900" Height="380" VerticalAlignment="Top">
<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 Header="Time" Width="160" IsReadOnly="True" Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn
Width="160"
Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"
Header="Time"
IsReadOnly="True" />
<DataGridTextColumn Header="Incoming" Width="350" IsReadOnly="True" Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}">
<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"/>
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Outgoing" Width="350" IsReadOnly="True" Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}">
<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"/>
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

View File

@ -1,80 +1,170 @@
<UserControl x:Class="MECF.Framework.Simulator.Core.Robots.HwinRobotView"
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:local="clr-namespace:MECF.Framework.Simulator.Core.Aligners"
xmlns:deviceControl="clr-namespace:MECF.Framework.UI.Core.DeviceControl;assembly=MECF.Framework.UI.Core"
xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons"
Height="900" Width="900">
<UserControl
x:Class="MECF.Framework.Simulator.Core.Robots.HwinRobotView"
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:deviceControl="clr-namespace:MECF.Framework.UI.Core.DeviceControl;assembly=MECF.Framework.UI.Core"
xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Aligners"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="900"
Height="900">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="150"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="400"></RowDefinition>
<RowDefinition Height="100" />
<RowDefinition Height="150" />
<RowDefinition Height="50" />
<RowDefinition Height="400" />
</Grid.RowDefinitions>
<commons:SocketTitleView Grid.Row="0"></commons:SocketTitleView>
<commons:SocketTitleView Grid.Row="0" />
<Canvas Grid.Row="1" Width="900">
<CheckBox Content="Error" IsChecked="{Binding IsError}" Canvas.Left="36" Canvas.Top="73"></CheckBox>
<TextBlock Text="_ERR {Code}" Canvas.Left="204" Canvas.Top="52"></TextBlock>
<TextBlock Text="Error Code:" Canvas.Left="99" Canvas.Top="72"></TextBlock>
<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 Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" Canvas.Left="203" Canvas.Top="70" Width="369" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox
Canvas.Left="203"
Canvas.Top="70"
Width="369"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding ErrorCode, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="_STA {Code}" Canvas.Left="204" Canvas.Top="10"></TextBlock>
<TextBlock Text="State Code:" Canvas.Left="99" Canvas.Top="30"></TextBlock>
<TextBox Text="{Binding StateCode, UpdateSourceTrigger=PropertyChanged}" Canvas.Left="203" Canvas.Top="28" Margin="0" Width="74" IsReadOnly="False"/>
<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 Content="Event" IsChecked="{Binding EventChecked}" Canvas.Left="36" Canvas.Top="110"></CheckBox>
<CheckBox
Canvas.Left="36"
Canvas.Top="110"
Content="Event"
IsChecked="{Binding EventChecked}" />
<TextBlock Text="_Event {Code}" Canvas.Left="204" Canvas.Top="91"></TextBlock>
<TextBlock Text="Event Code:" Canvas.Left="99" Canvas.Top="110"></TextBlock>
<TextBlock
Canvas.Left="204"
Canvas.Top="91"
Text="_Event {Code}" />
<TextBlock
Canvas.Left="99"
Canvas.Top="110"
Text="Event Code:" />
<TextBox Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" Canvas.Left="203" Canvas.Top="107" Margin="0" Width="550" IsReadOnly="False"/>
<TextBox
Canvas.Left="203"
Canvas.Top="107"
Width="550"
Margin="0"
IsReadOnly="False"
Text="{Binding EventCode, UpdateSourceTrigger=PropertyChanged}" />
</Canvas>
<StackPanel Grid.Row="2" Orientation="Horizontal" Width="900">
<Button Content="Clear Log" Width="100" Height="35" Command="{Binding ClearLogCommand}"></Button>
<Label Content="CassetteResult" Width="150" Height="35" Background="White" Padding="5,5" />
<TextBox Name="textBoxResult" Width="500" Height="35" Background="White" Padding="5,5" TextAlignment="Center" Text="{Binding CassetteResult}"/>
<Button Content="Set Result" Width="100" Height="35" Command="{Binding SetResult}"></Button>
<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" FontSize="16" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeRows="False" CanUserSortColumns="False" ItemsSource="{Binding TransactionLogItems}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
Width="900" Height="380" VerticalAlignment="Top">
<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 Header="Time" Width="160" IsReadOnly="True" Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn
Width="160"
Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"
Header="Time"
IsReadOnly="True" />
<DataGridTextColumn Header="Incoming" Width="350" IsReadOnly="True" Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}">
<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"/>
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Outgoing" Width="350" IsReadOnly="True" Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}">
<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"/>
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Height" Value="auto" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

View File

@ -0,0 +1,280 @@
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,
}
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 = "0022133000011111111211541"; //cd
private static string msgRSRCassB = "1111111111111"; //f
private static string msgRSR = "1";
private string lastMsg = "";
private System.Timers.Timer timer;
OperateEnum operateEnum = OperateEnum.Null;
public string CassetteResult { get; set; }
public SunwayRobotSimulator() : base(1103, 0, "\r\n", ' ', 5)
{
AddCommandHandler("HOME", HandleHome);
AddCommandHandler("RQ", HandleRQLoad);
AddCommandHandler("MAP", HandleMap);
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";
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");
}
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)
{
operateEnum = OperateEnum.RSR;
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.RSR)
{
OnWriteMessage(msgRSRCassA);
}
else if (operateEnum == OperateEnum.INPUT)
{
OnWriteMessage("1");
}
else
{
OnWriteMessage(msgDone);
}
}
}
}

View File

@ -0,0 +1,174 @@
<UserControl
x:Class="MECF.Framework.Simulator.Core.Robots.Sunway.SunwayRobotView"
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>

View File

@ -0,0 +1,97 @@
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>
/// SunwayRobotView.xaml 的交互逻辑
/// </summary>
public partial class SunwayRobotView : UserControl
{
public SunwayRobotView()
{
InitializeComponent();
this.DataContext = new SunwayRobotViewModel();
this.Loaded += OnViewLoaded;
}
private void OnViewLoaded(object sender, RoutedEventArgs e)
{
(DataContext as TimerViewModelBase).Start();
}
}
class SunwayRobotViewModel : SocketDeviceViewModel
{
public string Title => "Sunway 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 SunwayRobotViewModel() : base("SunwayRobotViewModel")
{
_robot = new SunwayRobotSimulator();
Init(_robot);
}
}
}

View File

@ -232,6 +232,10 @@
<Compile Include="Robots\JelRobot\JELC500_2\JelRobot5000_2View.xaml.cs">
<DependentUpon>JelRobot5000_2View.xaml</DependentUpon>
</Compile>
<Compile Include="Robots\Sunway\SunwayRobotSimulator.cs" />
<Compile Include="Robots\Sunway\SunwayRobotView.xaml.cs">
<DependentUpon>SunwayRobotView.xaml</DependentUpon>
</Compile>
<Compile Include="Robots\TrayRobot\TrayRobotSimulator.cs" />
<Compile Include="Robots\TrayRobot\TrayRobotView.xaml.cs">
<DependentUpon>TrayRobotView.xaml</DependentUpon>
@ -476,6 +480,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Robots\Sunway\SunwayRobotView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Robots\TrayRobot\TrayRobotView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -582,7 +590,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties vce_4brooksvce_4iosimulatoritems_1json__JsonSchema="http://json.schemastore.org/apibuilder.json" robots_4hiratar4_4iosimulatoritems_1json__JsonSchema="https://jenkins-x.io/schemas/jx-schema.json" />
<UserProperties robots_4hiratar4_4iosimulatoritems_1json__JsonSchema="https://jenkins-x.io/schemas/jx-schema.json" vce_4brooksvce_4iosimulatoritems_1json__JsonSchema="http://json.schemastore.org/apibuilder.json" />
</VisualStudio>
</ProjectExtensions>
</Project>