Browse Source

Add inputs setting in GalilSimualtor; Modify SRD UI;

niuyx 3 weeks ago
parent
commit
125446bdf2

+ 2 - 2
CyberX8_MainPages/Views/SRDHomePageView.xaml

@@ -149,9 +149,9 @@
                                          WaferID="{Binding WaferID}" />
         </Grid>
         <Grid Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" >
-            <UserControls:WaferPresenceControl HorizontalAlignment="Left" Margin="295,5,0,0" VerticalAlignment="Top"
+            <!--<UserControls:WaferPresenceControl HorizontalAlignment="Left" Margin="295,5,0,0" VerticalAlignment="Top"
                                           PersistentValue="{Binding SRDPersistent}" IsEnabled="{Binding IsEnabled}"
-                                          ModuleName="{Binding Module}" IsWaferPresence="{Binding IsWaferPresence}"/>
+                                          ModuleName="{Binding Module}" IsWaferPresence="{Binding IsWaferPresence}"/>-->
         </Grid>
     </Grid>
 

+ 6 - 6
CyberX8_MainPages/Views/SRDMotionView.xaml

@@ -18,25 +18,25 @@
             <ColumnDefinition Width="450"></ColumnDefinition>
             <ColumnDefinition ></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <UserControls:MotionControl Grid.Column="1" 
+        <!--<UserControls:MotionControl Grid.Column="1" 
                                     ModuleTitle="{Binding SRD1ArmModuleName}" 
                                     ModuleName="{Binding SRD1ArmModuleName}" 
                                     ModuleUnit="deg" 
                                     MotionData="{Binding SRD1ArmMotionData}" 
-                                    IncrementValue="{Binding IncrementValue}"/>
-        <UserControls:SRDMotionControl Grid.Column="2" 
+                                    IncrementValue="{Binding IncrementValue}"/>-->
+        <UserControls:SRDMotionControl Grid.Column="1" 
                                     ModuleTitle="{Binding SRD1RotaionModuleName}" 
                                     ModuleName="{Binding SRD1RotaionModuleName}" 
                                     ModuleUnit="deg" 
                                     MotionData="{Binding SRD1RotationMotionData}" 
                                     IncrementValue="{Binding IncrementValue}"/>
-        <UserControls:MotionControl Grid.Column="3" 
+        <!--<UserControls:MotionControl Grid.Column="3" 
                                     ModuleTitle="{Binding SRD2ArmModuleName}" 
                                     ModuleName="{Binding SRD2ArmModuleName}" 
                                     ModuleUnit="deg" 
                                     MotionData="{Binding SRD2ArmMotionData}" 
-                                    IncrementValue="{Binding IncrementValue}"/>
-        <UserControls:SRDMotionControl Grid.Column="4" 
+                                    IncrementValue="{Binding IncrementValue}"/>-->
+        <UserControls:SRDMotionControl Grid.Column="2" 
                                     ModuleTitle="{Binding SRD2RotaionModuleName}" 
                                     ModuleName="{Binding SRD2RotaionModuleName}" 
                                     ModuleUnit="deg" 

+ 8 - 8
CyberX8_MainPages/Views/SRDStationSetupView.xaml

@@ -22,7 +22,7 @@
             <ColumnDefinition Width="500"></ColumnDefinition>
             <ColumnDefinition/>
         </Grid.ColumnDefinitions>
-        <Grid Grid.Row="0" Grid.Column="0">
+        <!--<Grid Grid.Row="0" Grid.Column="0">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="380"></ColumnDefinition>
                 <ColumnDefinition/>
@@ -33,8 +33,8 @@
                                                        CurrentPosition="{Binding SRD1ArmMotionData.MotorPosition}" 
                                                        Torque="{Binding SRD1ArmMotionData.Torque}" 
                                                        CurrentStation="{Binding SRD1ArmCurrentStation}"/>
-        </Grid>
-        <Grid Grid.Row="0" Grid.Column="2">
+        </Grid>-->
+        <!--<Grid Grid.Row="0" Grid.Column="2">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="380"></ColumnDefinition>
                 <ColumnDefinition/>
@@ -45,8 +45,8 @@
                                            CurrentPosition="{Binding SRD2ArmMotionData.MotorPosition}" 
                                            Torque="{Binding SRD2ArmMotionData.Torque}" 
                                            CurrentStation="{Binding SRD2ArmCurrentStation}"/>
-        </Grid>
-        <Grid Grid.Row="1" Grid.Column="0">
+        </Grid>-->
+        <Grid Grid.Row="0" Grid.Column="0">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="380"></ColumnDefinition>
                 <ColumnDefinition/>
@@ -58,7 +58,7 @@
                                Torque="{Binding SRD1RotationMotionData.Torque}" 
                                CurrentStation="{Binding SRD1RotationCurrentStation}"/>
         </Grid>
-        <Grid Grid.Row="1" Grid.Column="2">
+        <Grid Grid.Row="0" Grid.Column="2">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="380"></ColumnDefinition>
                 <ColumnDefinition/>
@@ -70,8 +70,8 @@
                                Torque="{Binding SRD2RotationMotionData.Torque}" 
                                CurrentStation="{Binding SRD2RotationCurrentStation}"/>
         </Grid>
-        <Grid Grid.Row="2" Grid.Column="1">
+        <!--<Grid Grid.Row="2" Grid.Column="1">
             <UserControls:SrdAwcCycleControl Visibility="Collapsed" IsEnabled="False" SRDModuleName="{Binding AWCModuleName,Mode=TwoWay}" IsRunning="{Binding IsAWCCycling}" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="495" Height="180"/>
-        </Grid>
+        </Grid>-->
     </Grid>
 </UserControl>

+ 34 - 8
CyberX8_Simulator/Devices/GalilSocketSimulator.cs

@@ -1,6 +1,5 @@
 using Aitex.Common.Util;
 using Aitex.Core.RT.Log;
-using Aitex.Core.UI.Converters;
 using Aitex.Core.Util;
 using MECF.Framework.Common.Beckhoff.AxisProvider;
 using MECF.Framework.Common.Device.Galil;
@@ -81,7 +80,7 @@ namespace CyberX8_Simulator.Devices
         /// <summary>
         /// Key:dataName - Value:GalilDI
         /// </summary>
-        private Dictionary<string, GalilDI> _inputDataNameDIDic = new Dictionary<string, GalilDI>();
+        public Dictionary<string, GalilDI> InputDataNameDIDic = new Dictionary<string, GalilDI>();
         #endregion
         /// <summary>
         /// 构造函数
@@ -198,8 +197,7 @@ namespace CyberX8_Simulator.Devices
                 _galilControlData.GalilAxisDatas[i].Status = 0x00;
             }
             _galilControlData.Inputs  = new byte[10];
-            _galilControlData.Outputs = new byte[10];             
-            
+            _galilControlData.Outputs = new byte[10];
             //电机数据更新事件
             MotorSimulator.Instance.OnUpdateMotionDatasChanged += UpdateRealTimeMotionData;
             MotorSimulator.Instance.OnUpdateInputDatasChanged += UpdateInputData;
@@ -227,7 +225,7 @@ namespace CyberX8_Simulator.Devices
                             {
                                 foreach (var items in config.GalilDigIn.DIs)
                                 {
-                                    _inputDataNameDIDic[items.Name] = items;
+                                    InputDataNameDIDic[items.Name] = items;
                                 }
                             }
                             
@@ -586,10 +584,10 @@ namespace CyberX8_Simulator.Devices
         /// </summary>
         private void UpdateInputData(string module, string VariableName, bool value) 
         {
-            if(_moduleName == module && _inputDataNameDIDic.ContainsKey(VariableName))
+            if(_moduleName == module && InputDataNameDIDic.ContainsKey(VariableName))
             {
-                int tmp = _inputDataNameDIDic[VariableName].Invert ? (!value ? 1 : 0) : (value ? 1 : 0);
-                _galilControlData.Inputs[_inputDataNameDIDic[VariableName].Address] = (byte)(tmp << _inputDataNameDIDic[VariableName].Bit);
+                int tmp = InputDataNameDIDic[VariableName].Invert ? (!value ? 1 : 0) : (value ? 1 : 0);
+                _galilControlData.Inputs[InputDataNameDIDic[VariableName].Address] = (byte)(tmp << InputDataNameDIDic[VariableName].Bit);
             }
         }
         /// <summary>
@@ -604,6 +602,34 @@ namespace CyberX8_Simulator.Devices
             _galilControlData.GalilAxisDatas[index].Torque = data.ActualTorque;
             _galilControlData.GalilAxisDatas[index].StopCode = data.StopCode;
         }
+        /// <summary>
+        /// 模拟器UI更新inputs数据
+        /// </summary>
+        /// <param name="name"></param>
+        /// <param name="value"></param>
+        public void UpdateInputByte(string name, int value)
+        {
+            if (InputDataNameDIDic.ContainsKey(name))
+            {
+                GalilDI galilDI = InputDataNameDIDic[name];
+                short byteValue = (short)(_galilControlData.Inputs[galilDI.Address] & ~(1 << galilDI.Bit));
+                short tmp = (short)(value << galilDI.Bit);
+                _galilControlData.Inputs[galilDI.Address] = (byte)(byteValue | tmp);
+            }
+        }
+        /// <summary>
+        /// 模拟器获取inputs数据
+        /// </summary>
+        /// <param name="name"></param>
+        public int GetInputData(string name)
+        {
+            int result = 0;
+            if (!InputDataNameDIDic.ContainsKey(name)) return 0;
+            GalilDI galilDI = InputDataNameDIDic[name];
+            int tmp = _galilControlData.Inputs[galilDI.Address] & (1 << galilDI.Bit);
+            result = (tmp == (1 << galilDI.Bit)) ? 1 : 0;
+            return result;
+        }
 
         #region AxisOperation
         /// <summary>

+ 16 - 0
CyberX8_Simulator/Views/GalilView.xaml

@@ -5,6 +5,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:CyberX8_Simulator.Views"
              xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons;assembly=MECF.Framework.Simulator.Core"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:Height="900" d:Width="1200">
     <Grid>
@@ -20,6 +21,21 @@
         <Grid  Grid.Row="1">
             <StackPanel Orientation="Horizontal" Width="1200">
                 <Button Content="Clear Log" Width="100" Height="35"   Command="{Binding ClearLogCommand}"></Button>
+                <StackPanel Orientation="Horizontal" Width="577" Height="50" Margin="100,0,0,0">
+                    <Label Content="Inputs:" VerticalAlignment="Center"></Label>
+                    <ComboBox  Width="250" Height="30" VerticalContentAlignment="Center" ItemsSource="{Binding InputsNameItems}" SelectedItem="{Binding InputsSelectedItem}">
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="SelectionChanged">
+                                <i:InvokeCommandAction Command="{Binding InputsSelectionChangedCommand}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </ComboBox>
+                    <ComboBox  Width="60" Height="30" Margin="5,0,0,0" VerticalContentAlignment="Center" ItemsSource="{Binding DigitalOutputSelected}" SelectedItem="{Binding InputValue}" HorizontalContentAlignment="Center"></ComboBox>
+                    <Button Content="Set Input" Height="30" Width="100" Margin="5,10,0,0" Command="{Binding SetInputsCommand}"/>
+                    <Border Margin="5,0,0,0" Background="Black" Height="30" Width="80">
+                        <TextBlock Text="{Binding InputCurrentValue}" Foreground="Lime"   FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                    </Border>
+                </StackPanel>
             </StackPanel>
         </Grid>
 

+ 68 - 1
CyberX8_Simulator/Views/GalilView.xaml.cs

@@ -1,8 +1,11 @@
 using Aitex.Core.UI.MVVM;
+using Aitex.Core.Utilities;
 using CyberX8_Simulator.Devices;
 using MECF.Framework.Simulator.Core.Commons;
+using System.Collections.ObjectModel;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Input;
 
 namespace CyberX8_Simulator.Views
 {
@@ -28,10 +31,53 @@ namespace CyberX8_Simulator.Views
         {
             get { return "Galil Simulator"; }
         }
-
+        private string _inputsSelectedItem;
+        [IgnorePropertyChange]
+        public string InputsSelectedItem
+        {
+            get
+            {
+                return _inputsSelectedItem;
+            }
+            set
+            {
+                _inputsSelectedItem = value;
+            }
+        }
+        private int _inputValue;
+        [IgnorePropertyChange]
+        public int InputValue
+        {
+            get
+            {
+                return _inputValue;
+            }
+            set
+            {
+                _inputValue = value;
+            }
+        }
+        private int _inputCurrentValue;
+        [IgnorePropertyChange]
+        public int InputCurrentValue
+        {
+            get
+            {
+                return _inputCurrentValue;
+            }
+            set
+            {
+                _inputCurrentValue = value;
+            }
+        }
+        public ObservableCollection<string> InputsNameItems { get; set; }
+        public ObservableCollection<int> DigitalOutputSelected { get; set; }
         #endregion
 
         #region 内部变量
+        public ICommand SetInputsCommand { get; set; }
+        public ICommand InputsSelectionChangedCommand { get; set; }
+
         private GalilSocketSimulator _sim;
         #endregion
         public GalilViewModel(string str) : base("GalilViewModel")
@@ -39,6 +85,27 @@ namespace CyberX8_Simulator.Views
             int.TryParse(str, out int port);
             _sim = new GalilSocketSimulator(port);
             Init(_sim);
+            InitData(port);
+            SetInputsCommand = new DelegateCommand<object>(SetInputsAction);
+            InputsSelectionChangedCommand = new DelegateCommand<object>(InputsSelectionChangedAction);
+        }
+        private void InitData(int port)
+        {
+            DigitalOutputSelected = new ObservableCollection<int> { 0, 1 };
+            InputsNameItems = new ObservableCollection<string>();
+            foreach (var item in _sim.InputDataNameDIDic.Keys)
+            {
+                InputsNameItems.Add(item);
+            }
+        }
+        private void SetInputsAction(object obj)
+        {
+            _sim.UpdateInputByte(InputsSelectedItem, InputValue);
+            InputsSelectionChangedAction("");
+        }
+        private void InputsSelectionChangedAction(object obj)
+        {
+            InputCurrentValue = _sim.GetInputData(InputsSelectedItem);
         }
     }
 }

+ 12 - 13
CyberX8_Themes/UserControls/SRDMoveControl.xaml

@@ -6,7 +6,7 @@
              xmlns:converters="clr-namespace:CyberX8_Themes.Converters"
              xmlns:local="clr-namespace:CyberX8_Themes.UserControls"
              mc:Ignorable="d" x:Name="self"
-             d:DesignHeight="160" Width="495">
+             d:DesignHeight="120" Width="495">
     <UserControl.Resources>
         <converters:BoolToColor x:Key="boolToColor"/>
         <converters:BoolToRedColor x:Key="boolToRedColor"/>
@@ -16,7 +16,6 @@
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>
-            <RowDefinition Height="40"/>
             <RowDefinition/>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
@@ -30,10 +29,10 @@
         <Grid Grid.Row="0" Grid.Column="0">
             <Label  Content="Door" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
         </Grid>
-        <Grid Grid.Row="1" Grid.Column="0">
+        <!--<Grid Grid.Row="1" Grid.Column="0">
             <Label  Content="Arm Position" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-        </Grid>
-        <Grid Grid.Row="2" Grid.Column="0">
+        </Grid>-->
+        <Grid Grid.Row="1" Grid.Column="0">
             <Label  Content="Rotation" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
         </Grid>
         <Grid Grid.Row="0" Grid.Column="1">
@@ -55,23 +54,23 @@
         <Grid Grid.Row="0" Grid.Column="3">
             <Button Style="{StaticResource SysBtnStyle}" Margin="10,0,10,0" Grid.Column="1" Height="25" Width="100" HorizontalAlignment="Center" Content="Open" Click="Open_Click"></Button>
         </Grid>
-        <Grid Grid.Row="1" Grid.Column="2">
+        <!--<Grid Grid.Row="1" Grid.Column="2">
             <Button Style="{StaticResource SysBtnStyle}" Margin="10,0,10,0" Grid.Column="1" Height="25" Width="100" HorizontalAlignment="Center" Content="Out" Click="Out_Click"></Button>
-        </Grid>
-        <Grid Grid.Row="1" Grid.Column="3">
+        </Grid>-->
+        <!--<Grid Grid.Row="1" Grid.Column="3">
             <Button Style="{StaticResource SysBtnStyle}" Margin="10,0,10,0" Grid.Column="1" Height="25" Width="100" HorizontalAlignment="Center" Content="In" Click="In_Click"></Button>
-        </Grid>
-        <Grid Grid.Row="2" Grid.Column="2">
+        </Grid>-->
+        <Grid Grid.Row="1" Grid.Column="2">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="79*"/>
                 <ColumnDefinition Width="46*"/>
             </Grid.ColumnDefinitions>
             <Button Style="{StaticResource SysBtnStyle}" Margin="12,8,0,8" Height="25" Width="100" HorizontalAlignment="Left" Content="Start" Click="Start_Click" Grid.ColumnSpan="2"/>
         </Grid>
-        <Grid Grid.Row="2" Grid.Column="3">
+        <Grid Grid.Row="1" Grid.Column="3">
             <Button Style="{StaticResource SysBtnStyle}" Margin="10,0,10,0" Grid.Column="1" Height="25" Width="100" HorizontalAlignment="Center" Content="Stop" Click="Stop_Click"></Button>
         </Grid>
-        <Grid Grid.Row="3" Grid.Column="2">
+        <Grid Grid.Row="2" Grid.Column="2">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="65"></ColumnDefinition>
                 <ColumnDefinition Width="65"></ColumnDefinition>
@@ -80,7 +79,7 @@
             <TextBox IsEnabled="False" Grid.Column="1" Text="sec" Width="45" FontWeight="Bold" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="15"  Height="22"/>
         </Grid>
 
-        <Grid Grid.Row="3" Grid.Column="3">
+        <Grid Grid.Row="2" Grid.Column="3">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="65"></ColumnDefinition>
                 <ColumnDefinition Width="65"></ColumnDefinition>