Browse Source

add VoltageSetUnitSetScale,revise metalusage/LogManager bug

chenzk 3 weeks ago
parent
commit
494dc08d31

+ 14 - 14
CyberX8_RT/Config/Devices/PowerSupplierCfg-Simulator.xml

@@ -1,56 +1,56 @@
 <?xml version="1.0" encoding="utf-8"?>
 <PowerSupplierConfig>
   <PowerSupplierDeviceConfig Name="Power1" IpAddress="127.0.0.1" Port="820" Type="1" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power1-1" Address="1"  UnitSetScale="1000000" UnitScale="10000" />
+    <Device Name="Power1-1" Address="1"  VoltageUnitSetScale ="1000"  UnitSetScale="1000000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   <PowerSupplierDeviceConfig Name="Power2" IpAddress="127.0.0.1" Port="821" Type="1" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power2-1" Address="1"  UnitSetScale="1000000" UnitScale="10000" />
+    <Device Name="Power2-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   <PowerSupplierDeviceConfig Name="Power3" IpAddress="127.0.0.1" Port="822" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power3-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+    <Device Name="Power3-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   <PowerSupplierDeviceConfig Name="Power4" IpAddress="127.0.0.1" Port="823" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power4-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+    <Device Name="Power4-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   
   <PowerSupplierDeviceConfig Name="Power5" IpAddress="127.0.0.1" Port="824" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power5-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+    <Device Name="Power5-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   
   <PowerSupplierDeviceConfig Name="Power6" IpAddress="127.0.0.1" Port="825" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power6-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+    <Device Name="Power6-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
   
   <PowerSupplierDeviceConfig Name="Power7" IpAddress="127.0.0.1" Port="826" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power7-1" Address="1" UnitSetScale="1000" UnitScale="10000"  />
+    <Device Name="Power7-1" Address="1" VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000"  />
   </PowerSupplierDeviceConfig>
   
   <PowerSupplierDeviceConfig Name="Power8" IpAddress="127.0.0.1" Port="827" Type="0" SendTimeout="2000" RecvTimeout="2000"> 
-    <Device Name="Power8-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+    <Device Name="Power8-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
   </PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power9" IpAddress="127.0.0.1" Port="828" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power9-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power9-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power10" IpAddress="127.0.0.1" Port="829" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power10-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power10-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power11" IpAddress="127.0.0.1" Port="831" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power11-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power11-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power12" IpAddress="127.0.0.1" Port="832" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power12-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power12-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power13" IpAddress="127.0.0.1" Port="833" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power13-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power13-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
 
 	<PowerSupplierDeviceConfig Name="Power14" IpAddress="127.0.0.1" Port="834" Type="0" SendTimeout="2000" RecvTimeout="2000">
-		<Device Name="Power14-1" Address="1"  UnitSetScale="1000" UnitScale="10000" />
+		<Device Name="Power14-1" Address="1"  VoltageUnitSetScale ="1000" UnitSetScale="1000" UnitScale="10000" />
 	</PowerSupplierDeviceConfig>
   
   <PowerSupplierDeviceConfig Name="CMMPower1" IpAddress="127.0.0.1" Port="835" Type="0" SendTimeout="2000" RecvTimeout="2000"> 

+ 6 - 1
CyberX8_RT/Devices/PowerSupplier/CellPowerSupplier.cs

@@ -109,6 +109,10 @@ namespace CyberX8_RT.Devices.PowerSupplier
         /// 设置数值比例
         /// </summary>
         private int _unitSetScale = 1000;
+        /// <summary>
+        /// 设置电压数值比例
+        /// </summary>
+        private int _voltageUnitSetScale = 1000;
         #endregion
 
         #region 属性
@@ -173,6 +177,7 @@ namespace CyberX8_RT.Devices.PowerSupplier
                 }
                 _unitScale = _deviceParameter.UnitScale;
                 _unitSetScale= _deviceParameter.UnitSetScale;
+                _voltageUnitSetScale = _deviceParameter.VoltageUnitSetScale;
             }
             else
             {
@@ -594,7 +599,7 @@ namespace CyberX8_RT.Devices.PowerSupplier
         {
             List<PowerSupplierStepPeriodData> powerSupplierStepPeriodDatas = (List<PowerSupplierStepPeriodData>)args[1];
 
-            bool result=PowerSupplierDeviceConfigManager.Instance.SetStepPeriod(Module, _channel, powerSupplierStepPeriodDatas,_unitSetScale);
+            bool result=PowerSupplierDeviceConfigManager.Instance.SetStepPeriod(Module, _channel, powerSupplierStepPeriodDatas,_unitSetScale, _voltageUnitSetScale);
             _sendDateTime = DateTime.Now;
             if (result)
             {

+ 2 - 2
CyberX8_Simulator/Instances/SystemConfig.cs

@@ -31,7 +31,7 @@ namespace CyberX8_Simulator.Instances
 
                     if (File.Exists(config_path))
                     {
-                        var cfg_stream = File.Open(config_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+                        var cfg_stream = File.Open(config_path, FileMode.Open, FileAccess.Read, FileShare.Read);
                         XmlDocument xmlData = new XmlDocument();
                         xmlData.Load(config_path);
 
@@ -137,7 +137,7 @@ namespace CyberX8_Simulator.Instances
 
             try
             {
-                var stream = File.Open(xmlFile, FileMode.Open, FileAccess.ReadWrite);
+                var stream = File.Open(xmlFile, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
                 xml.Load(stream);
 
                 XmlNodeList nodeConfigs = xml.SelectNodes("root/configs");

+ 1 - 1
CyberX8_Themes/UserControls/RecipeFileLoadControl.xaml

@@ -54,12 +54,12 @@
                         <StackPanel Orientation="Horizontal">
                             <Image Width="16" Height="16" Source="{Binding NodeType,Converter={StaticResource recipeIconConverter}}" />
                             <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" Margin="5,0">
+                            </TextBlock>
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="MouseLeftButtonDown">
                                     <i:InvokeCommandAction Command="{Binding ElementName=self,Path=OperationCommand,UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding Name}"/>
                                 </i:EventTrigger>
                             </i:Interaction.Triggers>
-                            </TextBlock>
                         </StackPanel>
                     </HierarchicalDataTemplate>
                 </TreeView.ItemTemplate>

+ 1 - 1
Framework/Common/Device/PowerSupplier/IPowerSupplierDevice.cs

@@ -77,7 +77,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="name"></param>
         /// <param name="channel"></param>
         /// <param name="stepPeriodDatas"></param>
-        bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepPeriodDatas, int scale);
+        bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepPeriodDatas, int scale,int? voltageUnitSetScale);
         /// <summary>
         /// 启动步阶
         /// </summary>

+ 2 - 0
Framework/Common/Device/PowerSupplier/PowerSupplierDevice.cs

@@ -33,6 +33,8 @@ namespace MECF.Framework.Common.Device.PowerSupplier
 
         [XmlAttribute(AttributeName = "UnitScale", Form = XmlSchemaForm.Unqualified, DataType = "int")]
         public int UnitScale { get; set; }
+        [XmlAttribute(AttributeName = "VoltageUnitSetScale", Form = XmlSchemaForm.Unqualified, DataType = "int")]
+        public int VoltageUnitSetScale { get; set; }
         #endregion
     }
 }

+ 2 - 2
Framework/Common/Device/PowerSupplier/PowerSupplierDeviceConfigManager.cs

@@ -235,11 +235,11 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="name"></param>
         /// <param name="channel"></param>
         /// <param name="stepPeriodDatas"></param>
-        public bool SetStepPeriod(string name,byte channel,List<PowerSupplierStepPeriodData> stepPeriodDatas,int scale)
+        public bool SetStepPeriod(string name,byte channel,List<PowerSupplierStepPeriodData> stepPeriodDatas,int scale, int? _voltageUnitSetScale)
         {
             if (_nameModbusDeviceDic.ContainsKey(name))
             {
-                return _nameModbusDeviceDic[name].SetStepPeriod(channel, stepPeriodDatas,scale);
+                return _nameModbusDeviceDic[name].SetStepPeriod(channel, stepPeriodDatas,scale, _voltageUnitSetScale);
             }
             return false;
         }

+ 4 - 3
Framework/Common/Device/PowerSupplier/PowerSupplierGoldModbusDevice.cs

@@ -9,6 +9,7 @@ using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -123,7 +124,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// </summary>
         /// <param name="channel"></param>
         /// <param name="stepDatas"></param>
-        public bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepDatas, int scale)
+        public bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepDatas, int scale, int? voltageUnitSetScale)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
@@ -134,8 +135,8 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             for (int i = 0; i < stepDatas.Count; i++)
             {
                 PowerSupplierStepPeriodData data = stepDatas[i];
-                command.Datas[0 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Voltage * 1000,0)/0x10000);
-                command.Datas[1 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Voltage * 1000,0) %0x10000);
+                command.Datas[0 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Voltage * (double)voltageUnitSetScale, 0)/0x10000);
+                command.Datas[1 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Voltage * (double)voltageUnitSetScale, 0) % 0x10000);
                 command.Datas[2 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Current * scale, 0)/0x10000);
                 command.Datas[3 + STEP_PERIOD_LENGTH * i] = (ushort)(Math.Round(data.Current * scale, 0) % 0x10000);
                 command.Datas[4 + STEP_PERIOD_LENGTH * i] = 0;

+ 1 - 1
Framework/Common/Device/PowerSupplier/PowerSupplierModbusDevice.cs

@@ -123,7 +123,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// </summary>
         /// <param name="channel"></param>
         /// <param name="stepDatas"></param>
-        public bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepDatas, int scale)
+        public bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepDatas, int scale,int? voltageUnitSetScale)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;

+ 18 - 5
Framework/Common/Log/LogManager.cs

@@ -67,13 +67,13 @@ namespace Aitex.Core.RT.Log
             }
             else if (deleteTimer.Interval == 60 * 1000)
             {
-                if (DateTime.Now.Hour != 0 && DateTime.Now.Minute != 10)//下一次是0点10分钟
+                if (DateTime.Now.Hour == 0 && DateTime.Now.Minute == 5)//下一次是0点10分
                 {
-                    return;
+                    deleteTimer.Interval = 60 * 60 * 1000;
                 }
                 else
                 {
-                    deleteTimer.Interval = 60 * 60 * 1000;
+                    return;
                 }
             }
             else if (deleteTimer.Interval == 60 * 60 * 1000)
@@ -90,6 +90,7 @@ namespace Aitex.Core.RT.Log
                 FileInfo[] fileInfos;
                 DirectoryInfo curFolderInfo = new DirectoryInfo(path);
                 fileInfos = curFolderInfo.GetFiles();
+                List<string> deleteLst = new List<string>();
                 foreach (FileInfo info in fileInfos)
                 {
                     if (info.Extension == ".log" || info.Extension == ".txt" || info.Name.Contains("log"))
@@ -109,11 +110,23 @@ namespace Aitex.Core.RT.Log
                         {
                             if (CompressFile(info.FullName, $"{curFolderInfo.FullName}//{info.Name}.zip"))
                             {
-                                File.Delete(info.FullName);
-                                LOG.WriteBackgroundLog(eEvent.INFO_WINRESOURCE, "System", $"delete log successfully,logName:{info.Name}");
+                                deleteLst.Add(info.FullName);
                             }
                         }
                     }
+
+                    foreach (string item in deleteLst)
+                    {
+                        try
+                        {
+                            File.Delete(item);
+                            LOG.WriteBackgroundLog(eEvent.INFO_WINRESOURCE, "System", $"delete log successfully,logName:{item}");
+                        }
+                        catch
+                        {
+
+                        }
+                    }
                 }
             }
             catch(Exception ex)

+ 15 - 2
Framework/Common/ToolLayout/MetalUsageManager.cs

@@ -2,6 +2,7 @@
 using DocumentFormat.OpenXml.Spreadsheet;
 using MECF.Framework.Common.DBCore;
 using MECF.Framework.Common.ProcessCell;
+using SciChart.Core.Extensions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -131,9 +132,13 @@ namespace MECF.Framework.Common.ToolLayout
                     case "Anode B Total Wafers":
                         _metalUsageDictionary[metalName].AnodeBWafers = int.Parse(NewValue); break;
                     case "Anode A bath Usage(Days)":
-                        _metalUsageDictionary[metalName].AnodeABathUsage = int.Parse(NewValue); break;
+                        _metalUsageDictionary[metalName].AnodeABathUsage = int.Parse(NewValue);
+                        _metalUsageDictionary[metalName].BathResetTime = UpadateMetalUsageBathResetTime(_metalUsageDictionary[metalName].AnodeABathUsage);
+                        break;
                     case "Anode B bath Usage(Days)":
-                        _metalUsageDictionary[metalName].AnodeBBathUsage = int.Parse(NewValue); break;
+                        _metalUsageDictionary[metalName].AnodeBBathUsage = int.Parse(NewValue);
+                        _metalUsageDictionary[metalName].BathResetTime = UpadateMetalUsageBathResetTime(_metalUsageDictionary[metalName].AnodeBBathUsage);
+                        break;
                 }
                 MetalUsageRecorder.UpdateMetalUsageData(metalName, _metalUsageDictionary[metalName]);
             }
@@ -147,5 +152,13 @@ namespace MECF.Framework.Common.ToolLayout
         {
             return _metalUsageDictionary.ContainsKey(metalName) ? _metalUsageDictionary[metalName] : null;
         }
+
+        /// <summary>
+        /// 手动修改usage days时,resetTime也要相应更改
+        /// </summary>
+        private DateTime UpadateMetalUsageBathResetTime(int value)
+        {
+            return DateTime.Now.AddDays(-value);
+        }
     }
 }