Browse Source

Add to chart@@to slot switch page function
Improve SerialPort about package break problem

Intern01 1 year ago
parent
commit
171eef8acc

+ 6 - 0
Venus/Framework/Common/CommonData/HistoryDataItem.cs

@@ -144,6 +144,12 @@ namespace MECF.Framework.Common.CommonData
         [EnumMember]
         Recipe
     }
+    public class Anychange
+    {
+        public static string menuname { get; set; } 
+        public static bool needchange { get; set; } = false;
+        public static WaferHistoryWafer args { get; set;}
+    }
 
     [DataContract]
     [Serializable]

+ 41 - 2
Venus/Framework/Common/Communications/AsyncSerialPort.cs

@@ -9,6 +9,8 @@ using MECF.Framework.Common.Utilities;
 using Aitex.Core.RT.SCCore;
 using MECF.Framework.Common.SCCore;
 using Aitex.Core.Util;
+using System.Linq;
+using DocumentFormat.OpenXml.Drawing;
 
 namespace MECF.Framework.Common.Communications
 {
@@ -31,10 +33,13 @@ namespace MECF.Framework.Common.Communications
         protected SerialPort _port;
 
         private string _buff = "";
-
         public bool EnableLog { get; set; }
+        public StringBuilder str { get; set; }
+        public byte[] GetData { get; set; }
+        public bool bValidate { get; set; }
 
         private bool _isAsciiMode;
+
         private static BitArray _EnableLog;
 
         public AsyncSerialPort(string name, int baudRate, int dataBits, Parity parity = Parity.None, StopBits stopBits = StopBits.One, string newline = "\r", bool isAsciiMode=true)
@@ -62,6 +67,12 @@ namespace MECF.Framework.Common.Communications
             _port.ErrorReceived += new SerialErrorReceivedEventHandler(ErrorReceived);
 
             EnableLog = GetEnableFlag(name);
+
+            str = new StringBuilder();
+
+            bValidate = false;
+
+            GetData = new byte[] { };
         }
 
         public void Dispose()
@@ -172,7 +183,35 @@ namespace MECF.Framework.Common.Communications
                 return false;
             }
         }
-
+        public void HandlePorts(byte[] obj, int _length, byte start, string Module, eEvent errdevice,int nOffset)
+        {
+            lock (_locker)
+            {
+              GetData = (byte[])GetData.Concat(obj).ToArray();
+              //str.Append(System.Text.Encoding.Default.GetString(obj));
+              var strData1 = System.Text.Encoding.Default.GetString(GetData);
+              for (int i = 0; i < GetData.Length; i++)
+                {
+                    if (GetData[i] == start)
+                    {
+                        if ((GetData.Length - i) >= _length)
+                        {
+                            bValidate = true;
+                            byte[] array = new byte[GetData.Length - i - nOffset];
+                            Array.Copy(GetData, i + nOffset, array, 0, _length - nOffset);
+                            str.Append(System.Text.Encoding.Default.GetString(array));
+                            //str.Remove(0, i);
+                            //str.Remove(i + _length - 1, str.Length - i - _length);
+                            break;
+                        }
+                    }
+                }
+                if (GetData.Length > _length * 3 && !bValidate)
+                {
+                    LOG.Write(errdevice, Module, $"Receive invalidate data:{str} ");
+                }
+            }
+        }
 
         public void DataReceived(object sender, SerialDataReceivedEventArgs e)
         {

+ 22 - 17
Venus/Venus_MainPages/ViewModels/ProcessHistoryViewModel.cs

@@ -22,6 +22,8 @@ using System.Diagnostics;
 using Aitex.Core.RT.Routine;
 using System.Xml.Linq;
 using System.Windows.Forms;
+using ExcelLibrary.BinaryFileFormat;
+using Aitex.Core.UI.View.Common;
 
 namespace Venus_MainPages.ViewModels
 {
@@ -78,7 +80,7 @@ namespace Venus_MainPages.ViewModels
             _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand<object>(OnLoadPd));
         private DelegateCommand _SearchRecipeCommand;
         public DelegateCommand SearchRecipeCommand =>
-        _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipe));
+        _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipes));
         private DelegateCommand<object> _PdParameterCheckCommand;
         public DelegateCommand<object> PdParameterCheckCommand=>
            _PdParameterCheckCommand??(_PdParameterCheckCommand=new DelegateCommand<object>(OnParameterCheck));
@@ -103,7 +105,6 @@ namespace Venus_MainPages.ViewModels
         public ProcessHistoryViewModel()
         {
             ProcessChartData = new ProcessDataChartDataItem(60000);
-            
             Recipes = new ObservableCollection<RecipeItem>();
             timer.Interval = TimeSpan.FromSeconds(0.5);
             CheboxRecipes = new List<Recipeslist>();
@@ -145,11 +146,14 @@ namespace Venus_MainPages.ViewModels
                 }
             }
         }
-        public void SearchRecipe()
+        public void SearchRecipes()
         {
-
-            this.StartDateTime = this.view.wfTimeFrom.Value;
-            this.EndDateTime = this.view.wfTimeTo.Value;
+            SearchRecipe(this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value);
+        }
+        public void SearchRecipe(DateTime start,DateTime end )
+        {
+            this.StartDateTime = start;
+            this.EndDateTime = end;
             Recipes.Clear();
 
             try
@@ -195,9 +199,9 @@ namespace Venus_MainPages.ViewModels
                         item.SlotID = dbData.Rows[i]["slot_id"].ToString();
                         item.LotID = dbData.Rows[i]["lot_id"].ToString();
                         if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
-                            item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
+                            item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]);
                         if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
-                            item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
+                            item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]);
                         Recipes.Add(item);                  
                     }
                 }));
@@ -425,14 +429,15 @@ namespace Venus_MainPages.ViewModels
             //    }
             //}));          
             this.view.MyDrawGraphicsControl.ClearPlotPoints();
-            DateTime dtFrom = Convert.ToDateTime(dataLog.StartTime);
+            DateTime dtFrom = dataLog.StartTime;
+            //DateTime dtFrom = Convert.ToDateTime(dataLog.StartTime);
             DateTime dtTo = dtFrom.AddMinutes(10);
-            if (!string.IsNullOrEmpty(dataLog.EndTime))
-            {
-                dtTo = Convert.ToDateTime(dataLog.EndTime);
-            }
+            dtTo = dataLog.EndTime;
+            //if (!string.IsNullOrEmpty(dataLog.EndTime))
+            //{
+            //    dtTo = Convert.ToDateTime(dataLog.EndTime);
+            //}
             var result = GetData(keys.Distinct().ToList(), dtFrom, dtTo);
-            //var result = GetData(keys.Distinct().ToList(), this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value);
             List<PointCollection> cls = new List<PointCollection>();
             for (int i = 0; i < keys.Count; i++)
             {
@@ -449,7 +454,7 @@ namespace Venus_MainPages.ViewModels
             this.view.MyDrawGraphicsControl.FitControl();
         }
 
-        private void OnDataGridSelectionChanged(object obj)
+        public void OnDataGridSelectionChanged(object obj)
         {
             selectedRecipeItem =  obj as RecipeItem;
             ParameterNodes = new ObservableCollection<ParameterNode>(_provider.GetParameters().Where(x => x.Name == selectedRecipeItem?.Chamber));
@@ -502,8 +507,8 @@ namespace Venus_MainPages.ViewModels
         public string RecipeRunGuid { get; set; }
         public string Chamber { get; set; }
         public string Status { get; set; }
-        public string StartTime { get; set; }
-        public string EndTime { get; set; }
+        public DateTime StartTime { get; set; }
+        public DateTime EndTime { get; set; }
         public string LotID { get; set; }
         public string SlotID { get; set; }
     }

+ 53 - 0
Venus/Venus_MainPages/ViewModels/WaferHistoryDBViewModel.cs

@@ -17,6 +17,7 @@ using System.ComponentModel;
 using OpenSEMI.Ctrlib.Controls;
 using Venus_Core;
 using RecipeStep = MECF.Framework.Common.CommonData.RecipeStep;
+using QiHe.CodeLib;
 
 namespace Venus_MainPages.ViewModels
 {
@@ -90,6 +91,10 @@ namespace Venus_MainPages.ViewModels
         public DelegateCommand<object> QueryCommand =>
             _QueryCommand ?? (_QueryCommand = new DelegateCommand<object>(QueryLots));
 
+        private DelegateCommand<object> _ToChartCommand;
+        public DelegateCommand<object> ToChartCommand =>
+            _ToChartCommand ?? (_ToChartCommand = new DelegateCommand<object>(Tocharts));
+
         private DelegateCommand<WaferHistoryItem> _SelectionChangedCommand;
         public DelegateCommand<WaferHistoryItem> SelectionChangedCommand =>
             _SelectionChangedCommand ?? (_SelectionChangedCommand = new DelegateCommand<WaferHistoryItem>(SelectionChanged));
@@ -103,6 +108,54 @@ namespace Venus_MainPages.ViewModels
         {
             HistoryData = new ObservableCollection<LazyTreeItem<WaferHistoryItem>>();
         }
+        void Tocharts(object o)
+        {
+            WaferHistoryItem item = o as WaferHistoryItem;
+            WaferHistoryWafer item1 = o as WaferHistoryWafer;
+
+            if (o  is DateTime startTime)
+            {
+                var query = _recipes.FirstOrDefault(t => t.StartTime.CompareTo(startTime) == 0);
+                if (query is null) return;
+                WaferHistoryWafer wafer1 = new WaferHistoryWafer();
+                wafer1.StartTime = query.StartTime;
+                wafer1.EndTime = query.EndTime;
+                SwitchPage( "ProcessHistory", wafer1);
+            }
+            else if (o is WaferHistoryLot waferLot)
+            {
+                item.Type = WaferHistoryItemType.Lot;
+                SelectionChanged(item);
+                WaferHistoryItem selectItem = null;
+                foreach (var root in HistoryData)
+                {
+                    foreach (var subroot in root.SubItems)
+                    {
+                        var data = subroot.Data as WaferHistoryItem;
+                        if (data != null && data.Name != null && data.Name == item.Name)
+                        {
+                            selectItem = data;
+                            subroot.IsExpanded = true;
+                            break;
+                        }
+                    }
+                    if (selectItem != null)
+                        break;
+                }
+            }
+            else if (o is WaferHistoryWafer wafer) 
+            {
+                SwitchPage("ProcessHistory", item1);
+            }
+            
+        }
+      
+        void SwitchPage(string MenuID, WaferHistoryWafer queryFilter)
+        {
+            Anychange.needchange = true;
+            Anychange.menuname = MenuID;
+            Anychange.args= queryFilter;
+        }
         void QueryLots(object e)
         {
             this.SearchBeginTime = this.view.wfTimeFrom.Value;

+ 2 - 2
Venus/Venus_MainPages/Views/ProcessHistoryView.xaml

@@ -117,7 +117,7 @@
                 <Grid HorizontalAlignment="Center">
                     <!--<ComboBox Width="400" ItemsSource="{Binding CheboxRecipes, Mode=TwoWay}" SelectedValue="{Binding RecipeName ,Mode=TwoWay}" DisplayMemberPath="BoxName" SelectedValuePath="BoxName">
                     </ComboBox>-->
-                    <TextBox Text="{Binding RecipeName,UpdateSourceTrigger=PropertyChanged}" Width="400" VerticalContentAlignment="Center" FontSize="15"/>
+                    <TextBox Text="{Binding RecipeName,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Width="400" VerticalContentAlignment="Center" FontSize="15"/>
                 </Grid>
             </Border>
             <Button Margin="5,0,0,0" Grid.Column="6" Content="Search" Width="80" Height="30" Command="{Binding SearchRecipeCommand}">
@@ -202,7 +202,7 @@
                     <DataGridTemplateColumn Header="Recipe" Width="300">
                         <DataGridTemplateColumn.CellTemplate>
                             <DataTemplate>
-                                <TextBlock Text="{Binding Recipe}" Margin="5,0" FontFamily="Arial" FontSize="20" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
+                                <TextBlock Text="{Binding Recipe}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                             </DataTemplate>
                         </DataGridTemplateColumn.CellTemplate>
                     </DataGridTemplateColumn>

+ 1 - 1
Venus/Venus_MainPages/Views/ProcessHistoryView.xaml.cs

@@ -30,7 +30,7 @@ namespace Venus_MainPages.Views
         public ProcessHistoryView()
         {
             InitializeComponent();
-
+            this.DataContext = new ProcessHistoryViewModel();
         }
         private ProcessHistoryViewModel _viewModel;
 

+ 67 - 9
Venus/Venus_RT/Devices/AdixenTurboPump.cs

@@ -13,6 +13,12 @@ using Aitex.Core.RT.Device;
 using Aitex.Core.RT.Log;
 using Venus_Core;
 using MECF.Framework.Common.Device.Bases;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices.ComTypes;
+using System.Reflection;
+using System.Threading;
+
 namespace Venus_RT.Devices
 {
     class AdixenTurboPump : PumpBase
@@ -109,11 +115,11 @@ namespace Venus_RT.Devices
             {"Err4",  "checksum error" },
         };
 
-        private readonly ushort PUMP_ON_FLAG            = 0x02;
-        private readonly ushort PUMP_ERROR_FLAG         = 0x40;
-        private readonly ushort ISO_VALVE_OPEN_FLAG     = 0x01;
-        private readonly ushort WATER_VALVE_OEPN_FLAG   = 0x08;
-        private readonly ushort VALVE_AT_SPEED_FLAG     = 0x40;
+        private readonly ushort PUMP_ON_FLAG = 0x02;
+        private readonly ushort PUMP_ERROR_FLAG = 0x40;
+        private readonly ushort ISO_VALVE_OPEN_FLAG = 0x01;
+        private readonly ushort WATER_VALVE_OEPN_FLAG = 0x08;
+        private readonly ushort VALVE_AT_SPEED_FLAG = 0x40;
 
         public override bool IsRunning
         {
@@ -202,7 +208,7 @@ namespace Venus_RT.Devices
         }
         private void AdixenTurboPump_sendDataChangedEvent(string obj)
         {
-            
+
         }
         public override bool Initialize()
         {
@@ -221,7 +227,7 @@ namespace Venus_RT.Devices
 
         public override void Monitor()
         {
-            if(_queryWatch.ElapsedMilliseconds > _readInterval)
+            if (_queryWatch.ElapsedMilliseconds > _readInterval)
             {
                 _queryWatch.Restart();
                 if (_lastCommand == Operation.Invalid)
@@ -278,7 +284,7 @@ namespace Venus_RT.Devices
                     return;
                 }
 
-                if(obj.Substring(0, 3) == "Err")
+                if (obj.Substring(0, 3) == "Err")
                 {
                     if (_comError.ContainsKey(obj.Substring(0, 4)))
                     {
@@ -314,7 +320,59 @@ namespace Venus_RT.Devices
                 _noRepeatAlarm($"[{Module}] Adixen Turbo Pump error: [{ex.Message}], Data: {obj}");
             }
         }
-
+        
+        private void _OnHandleBinaryData(byte[] obj)
+        {
+            //System.Threading.Monitor.Enter(_Lock);
+                byte start = System.Text.Encoding.Default.GetBytes("#")[0];
+                _serial.HandlePorts(obj,78, start, Module, eEvent.ERR_TURBO_PUMP,9);
+                if (_serial.bValidate == true)
+                {
+                     _pumpStatus = _serial.GetData[6];
+                     _valveStatus = _serial.GetData[7];
+                     //int nOffset = 9;
+                     //_serial.str.Remove(0, nOffset);
+                      OnPortDataChanged(_serial.str.ToString());
+                     _serial.str.Clear();
+                      _serial.GetData = new byte[] { };
+                    _serial.bValidate = false;
+                }
+            }
+        
+        private  byte[] GetData=new byte[]{};
+        private void OnHandleBinaryData(byte[] obj)
+        {
+            bool bValidate = false;
+            GetData = (byte[])GetData.Concat(obj).ToArray();
+            var strData1 = System.Text.Encoding.Default.GetString(GetData);
+                for (int i = 0; i < GetData.Length; i++)
+                {
+                    if (GetData[i] == (byte)'#')
+                    {                      
+                        if ((GetData.Length - i) >= 78)
+                        {
+                            _pumpStatus = GetData[i + 6];
+                            _valveStatus = GetData[i + 7];
+                            int nOffset = 9;
+                            byte[] array = new byte[GetData.Length - i - nOffset];
+                            Array.Copy(GetData, i + nOffset, array, 0, GetData.Length - i - nOffset);
+                            int _start = i + 78;
+                            int _end = GetData.Length - 1;
+                            //GetData = (byte[])GetData.Skip(_start).Take(_end - _start + 1).ToArray();
+                            GetData = new byte[] { };
+                            var strData = System.Text.Encoding.Default.GetString(array);
+                            OnPortDataChanged(strData);
+                            bValidate = true;
+                            break;
+                        }
+                    }
+                }
+                if (GetData.Length>156 && !bValidate)
+                {
+                 var strData = System.Text.Encoding.Default.GetString(GetData);
+                 _noRepeatAlarm($"Receive invalidate data:{strData} ");
+                }                    
+        }
         private void OnPortBinaryDataChanged(byte[] obj)
         {
             bool bValidate = false;

+ 32 - 4
Venus/Venus_UI/Views/ShellView.xaml.cs

@@ -17,6 +17,12 @@ using Venus_MainPages.Unity;
 using MECF.Framework.Common.DataCenter;
 using Aitex.Core.RT.SCCore;
 using MECF.Framework.Common.OperationCenter;
+using Aitex.Core.RT.OperationCenter;
+using Venus_MainPages.ViewModels;
+using MECF.Framework.Common.CommonData;
+using System.Windows.Controls.Primitives;
+using System.Timers;
+using System.Windows.Threading;
 
 namespace Venus_UI.Views
 {
@@ -30,6 +36,7 @@ namespace Venus_UI.Views
         List<VenusMenu> VenusMenu;
         List<TabControl>  centerTabViews=new List<TabControl> ();
         List<Button> buttonList=new List<Button> ();
+        DispatcherTimer timer = new DispatcherTimer();
 
         public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
         {
@@ -42,7 +49,17 @@ namespace Venus_UI.Views
 
             VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
             VenusGlobalEvents.SlotWaferTransferEvent += Instance_SlotStartTransferEvent;
-
+            timer.Tick += timer_Tick;
+            timer.Interval = TimeSpan.FromSeconds(0.5);
+            timer.Start();
+        }
+        void timer_Tick(object sender, EventArgs e)
+        {
+            if (Anychange.needchange)
+            {
+                Anystationchange(Anychange.menuname, Anychange.args);
+                Anychange.needchange=false;
+            }
         }
         private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
         {
@@ -68,7 +85,7 @@ namespace Venus_UI.Views
 
         private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
         {
-            VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");
+            VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");            
             int index = 0;
             for (int i = 0; i < VenusMenu.Count; i++)
             {
@@ -151,13 +168,24 @@ namespace Venus_UI.Views
                     }
                     tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
                 }
-                centerTabViews.Add(tabControl);
+                centerTabViews.Add(tabControl);               
             }
             Main_Frame.Content = centerTabViews[0];
             ModuleManager.Initialize();
 
         }
-
+         
+        public void Anystationchange(string menuviewItem, WaferHistoryWafer queryFilter)
+        {
+            UserControl address = new ProcessHistoryView();          
+            ProcessHistoryViewModel vm = new ProcessHistoryViewModel() {};
+            vm.SearchRecipe(queryFilter.StartTime, queryFilter.EndTime);
+            vm.OnDataGridSelectionChanged(new Venus_MainPages.ViewModels.RecipeItem { StartTime=queryFilter.StartTime, EndTime= queryFilter.EndTime});
+            address.DataContext = vm;
+            centerTabViews.Last().Items[2]= new TabItem() { Header = menuviewItem, Content = address };
+            centerTabViews.Last().SelectedIndex = 2;
+            Main_Frame.Content = centerTabViews.Last();
+        }
         private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
         {
             var currentButton = sender as AduRadioButtonIcon;