using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public enum AlarmType
    {
        Cleared=-1,
        Warning=1,
        Error,
        FatalError,
    }
    public class Alarm
    {
        public string AlarmMessage { get; set; }
        public AlarmType AlarmType { get; set; }
        public DateTime Timestamp { get; set; }

        public static List<(string AlarmNode, string AlarmMessage, bool DesiredValue)> AlarmNodeWithMessage = new List<(string, string,bool)>
        {
            ("Application.A00_Turntable_Manual.b转盘轴error" , "A00转盘轴Error" , true),
            ("Application.A01_FeedInStation_Auto.b下压轴Error" , "A01入料站下压轴Error" , true),
            ("Application.A01_FeedInStation_Auto.b分离轴Error" , "A01入料站分离轴Error" , true),
            ("Application.InOutPut.A01入料站.b离子风扇报警" , "A01入料站离子风扇报警" , true),
            ("Application.A02_TestStation_Auto.b下压轴Error" , "A02电极性测试下压轴Error" , true),
            ("Application.A03_DirectionTrun_Auto.b下压轴Error" , "A03转向站1下压轴Error" , true),
            ("Application.A03_DirectionTrun_Auto.b旋转轴Error" , "A03转向站旋转轴Error" , true),
            ("Application.A04_TestStation_Auto.b下压轴Error" , "A04常温测试站1下压轴Error" , true),
            ("Application.A05_TestStation_Auto.b下压轴Error" , "A05常温测试站2下压轴Error" , true),
            ("Application.A06_TestStation_Auto.b下压轴Error" , "A06常温测试站3下压轴Error" , true),
            ("Application.A07_TestStation_Auto.b下压轴Error" , "A07常温测试站4下压轴Error" , true),
            ("Application.A08_TestNGContainer_Auto.b料盒轴Error" , "A08四料盒1料盒轴Error" , true),
            ("Application.A09_TestNGContainer_Auto.b料盒轴Error" , "A09四料盒2料盒轴Error" , true),
            ("Application.A10_LocateStation_Auto.b下压轴Error" , "A10定位站1下压轴Error" , true),
            ("Application.A14_ThermalTest_Auto.b下压轴Error" , "A14热测盘下压轴Error" , true),
            ("Application.A14_ThermalTest_Auto.b热测升降轴Error" , "A14热测盘热测升降轴Error" , true),
            ("Application.A14_ThermalTest_Auto.b热测盘Error" , "A14热测盘Error" , true),
            ("Application.A14_ThermalTest_Auto.b翻转升降轴Error" , "A热测盘翻转升降轴Error" , true),
            ("Application.A14_ThermalTest_Auto.b翻转轴Error" , "A热测盘翻转轴Error" , true),
            ("Application.A18_CoolingStation_Auto.b下压轴Error" , "A18降温站1下压轴Error" , true),
            ("Application.A19_CoolingStation_Auto.b下压轴Error" , "A19降温站2下压轴Error" , true),
            ("Application.A20_TestNGContainer_Auto.b料盒轴Error" , "A20四料盒3料盒轴Error" , true),
            ("Application.A21_LocateStation_Auto.b下压轴Error" , "A21定位站2下压轴Error" , true),
            ("Application.A23_LaserMarking_Auto.bOutputError" , "A23镭射站Error" , true),
            ("Application.A23_LaserMarking_Auto.b下压轴Error" , "A23镭射站下压轴Error" , true),
            ("Application.A25_TestStation_Auto.b下压轴Error" , "A25常温测试站5下压轴Error" , true),
            ("Application.A26_DirectionTurn_Auto.b下压轴Error" , "A26转向站2下压轴Error" , true),
            ("Application.A26_DirectionTurn_Auto.b旋转轴Error" , "A26转向站2旋转轴Error" , true),
            ("Application.A27_3DTestStation_Auto.b下压轴Error" , "A273D监测站下压轴Error" , true),
            ("Application.A28_TestNGContainer_Auto.b料盒轴Error" , "A28四料盒4料盒轴Error" , true),
            ("Application.A29_TestNGContainer_Auto.b料盒轴Error" , "A29四料盒5料盒轴Error" , true),
            ("Application.A30_LocateStation_Auto.b下压轴Error" , "A30封装前定位站下压轴Error" , true),
            ("Application.A33_Encapsulation1_Manual.b下压轴error" , "A33封装站下压轴Error" , true),
            ("Application.A33_Encapsulation1_Manual.b封合轴error" , "A33封装站封合轴Error" , true),
            ("Application.A33_Encapsulation1_Manual.b走带轴error" , "A33封装站走带轴Error" , true),
            ("Application.A33_Encapsulation1_Auto.b走带无法复原报警" , "A33封装站走带无法复原报警" , true),



            ("Application.A00_Turntable_Auto.b_Error[1]" , "A00主转盘下压轴不在位，无法移动" , true),

            ("Application.A01_FeedInStation_Auto.b入料站异常[1]" , "A01入料站门闸感应超时报警" , true),
            
            ("Application.A02_TestStation_Auto.bError[1]" , "A02电极性测试站材料未取走报警" , true),
            ("Application.A02_TestStation_Auto.bError[2]" , "A02电极性测试站材料缺失报警" , true),
            ("Application.A02_TestStation_Auto.bError[10]" , "A02电极性测试站测试机返回EOT超时" , true),
            ("Application.A02_TestStation_Auto.bError[11]" , "A02电极性测试站返回Bin结果异常" , true),

            ("Application.A03_DirectionTrun_Auto.bError[1]" , "A03转向站1材料未取走报警" , true),
            ("Application.A03_DirectionTrun_Auto.bError[2]" , "A03转向站1材料缺失报警" , true),

            ("Application.A04_TestStation_Auto.bError[1]" , "A04测试站1材料未取走报警" , true),
            ("Application.A04_TestStation_Auto.bError[2]" , "A04测试站1材料缺失报警" , true),
            ("Application.A04_TestStation_Auto.bError[10]" , "A04测试站1测试机返回EOT超时" , true),
            ("Application.A04_TestStation_Auto.bError[11]" , "A04测试站1返回Bin结果异常" , true),

            ("Application.A05_TestStation_Auto.bError[1]" , "A05测试站2材料未取走报警" , true),
            ("Application.A05_TestStation_Auto.bError[2]" , "A05测试站2材料缺失报警" , true),
            ("Application.A05_TestStation_Auto.bError[10]" , "A05测试站2测试机返回EOT超时" , true),
            ("Application.A05_TestStation_Auto.bError[11]" , "A05测试站2返回Bin结果异常" , true),

            ("Application.A06_TestStation_Auto.bError[1]" , "A06测试站3材料未取走报警" , true),
            ("Application.A06_TestStation_Auto.bError[2]" , "A06测试站3材料缺失报警" , true),
            ("Application.A06_TestStation_Auto.bError[10]" , "A06测试站3测试机返回EOT超时" , true),
            ("Application.A06_TestStation_Auto.bError[11]" , "A06测试站3返回Bin结果异常" , true),

            ("Application.A07_TestStation_Auto.bError[1]" , "A07测试站4材料未取走报警" , true),
            ("Application.A07_TestStation_Auto.bError[2]" , "A07测试站4材料缺失报警" , true),
            ("Application.A07_TestStation_Auto.bError[10]" , "A07测试站4测试机返回EOT超时" , true),
            ("Application.A07_TestStation_Auto.bError[11]" , "A07测试站4返回Bin结果异常" , true),

            ("Application.A08_TestNGContainer_Auto.bError[1]" , "A08四料盒1站NG抛料失败，需要手动清除材料" , true),
            ("Application.A08_TestNGContainer_Auto.bError[2]" , "A08四料盒1站NG抛料站材料缺失报警" , true),
            ("Application.A08_TestNGContainer_Auto.bError[25]" , "A08四料盒1站NG料盒1满料" , true),
            ("Application.A08_TestNGContainer_Auto.bError[26]" , "A08四料盒1站NG料盒2满料" , true),
            ("Application.A08_TestNGContainer_Auto.bError[27]" , "A08四料盒1站NG料盒3满料" , true),
            ("Application.A08_TestNGContainer_Auto.bError[28]" , "A08四料盒1站NG料盒4满料" , true),
            ("Application.A08_TestNGContainer_Auto.bError[31]" , "A08四料盒1站NG料盒1缺失" , true),
            ("Application.A08_TestNGContainer_Auto.bError[32]" , "A08四料盒1站NG料盒2缺失" , true),
            ("Application.A08_TestNGContainer_Auto.bError[33]" , "A08四料盒1站NG料盒3缺失" , true),
            ("Application.A08_TestNGContainer_Auto.bError[34]" , "A08四料盒1站NG料盒4缺失" , true),

            ("Application.A09_TestNGContainer_Auto.bError[1]" , "A09四料盒2站NG抛料失败，需要手动清除材料" , true),
            ("Application.A09_TestNGContainer_Auto.bError[2]" , "A09四料盒2站NG抛料站材料缺失报警" , true),
            ("Application.A09_TestNGContainer_Auto.bError[25]" , "A09四料盒2站NG料盒1满料" , true),
            ("Application.A09_TestNGContainer_Auto.bError[26]" , "A09四料盒2站NG料盒2满料" , true),
            ("Application.A09_TestNGContainer_Auto.bError[27]" , "A09四料盒2站NG料盒3满料" , true),
            ("Application.A09_TestNGContainer_Auto.bError[28]" , "A09四料盒2站NG料盒4满料" , true),
            ("Application.A09_TestNGContainer_Auto.bError[31]" , "A09四料盒2站NG料盒1缺失" , true),
            ("Application.A09_TestNGContainer_Auto.bError[32]" , "A09四料盒2站NG料盒2缺失" , true),
            ("Application.A09_TestNGContainer_Auto.bError[33]" , "A09四料盒2站NG料盒3缺失" , true),
            ("Application.A09_TestNGContainer_Auto.bError[34]" , "A09四料盒2站NG料盒4缺失" , true),


            ("Application.A10_LocateStation_Auto.bError[1]" , "A10定位站1材料未取走报警" , true),
            ("Application.A10_LocateStation_Auto.bError[2]" , "A10定位站1材料缺失报警" , true),

            ("Application.A14_ThermalTest_Auto.b热测站异常[1]" , "A14热测机返回EOT超时报警" , true),
            ("Application.A14_ThermalTest_Auto.b热测站异常[11]" , "A14热测站测试机返回Bin结果异常" , true),
            ("Application.A14_ThermalTest_Auto.b热测站异常[100]" , "A14热测盘卡料，使能断开" , true),
            ("Application.A14_ThermalTest_Auto.b热测盘可以运行" , "A14热测盘异常，检查热测盘是否卡料，复位报警后点击“热测盘定位”按键解除异常" , false),
            ("Application.A14_ThermalTest_Auto.b温度异常[1]" , "A14热测盘温控器1温度异常" , true),
            ("Application.A14_ThermalTest_Auto.b温度异常[2]" , "A14热测盘温控器2温度异常" , true),
            ("Application.A14_ThermalTest_Auto.b温度异常[3]" , "A14热测盘温控器3温度异常" , true),
            ("Application.A14_ThermalTest_Auto.b温度异常[4]" , "A14热测盘温控器4温度异常" , true),



            ("Application.A18_CoolingStation_Auto.bError[1]" , "A18降温站材料未取走报警" , true),
            ("Application.A18_CoolingStation_Auto.bError[2]" , "A18降温站材料缺失报警" , true),

            ("Application.A19_CoolingStation_Auto.bError[1]" , "A19降温站材料未取走报警" , true),
            ("Application.A19_CoolingStation_Auto.bError[2]" , "A19降温站材料缺失报警" , true),


            ("Application.A20_TestNGContainer_Auto.bError[1]" , "A20四料盒3站NG抛料失败，需要手动清除材料" , true),
            ("Application.A20_TestNGContainer_Auto.bError[2]" , "A20四料盒3站NG抛料站材料缺失报警" , true),
            ("Application.A20_TestNGContainer_Auto.bError[25]" , "A20四料盒3站NG料盒1满料" , true),
            ("Application.A20_TestNGContainer_Auto.bError[26]" , "A20四料盒3站NG料盒2满料" , true),
            ("Application.A20_TestNGContainer_Auto.bError[27]" , "A20四料盒3站NG料盒3满料" , true),
            ("Application.A20_TestNGContainer_Auto.bError[28]" , "A20四料盒3站NG料盒4满料" , true),
            ("Application.A20_TestNGContainer_Auto.bError[31]" , "A20四料盒3站NG料盒1缺失" , true),
            ("Application.A20_TestNGContainer_Auto.bError[32]" , "A20四料盒3站NG料盒2缺失" , true),
            ("Application.A20_TestNGContainer_Auto.bError[33]" , "A20四料盒3站NG料盒3缺失" , true),
            ("Application.A20_TestNGContainer_Auto.bError[34]" , "A20四料盒3站NG料盒4缺失" , true),


            ("Application.A21_LocateStation_Auto.bError[1]" , "A21定位站2材料未取走报警" , true),
            ("Application.A21_LocateStation_Auto.bError[2]" , "A21定位站2材料缺失报警" , true),

            ("Application.A23_LaserMarking_Auto.b镭射打标站异常[1]" , "A23镭射盘材料缺失报警" , true),
            ("Application.A23_LaserMarking_Auto.b镭射打标站异常[2]" , "A23镭射盘材料未取走报警" , true),
            ("Application.A23_LaserMarking_Auto.b镭射打标站异常[3]" , "A23镭射盘下料材料丢失报警，解除报警后按运行启动" , true),
            ("Application.A23_LaserMarking_Auto.b镭射打标站异常[10]" , "A23镭射盘CCD返回EOT结果超时" , true),
            ("Application.A23_LaserMarking_Auto.b镭射打标站异常[20]" , "A23镭射盘打标机返回EOT结果超时" , true),


            ("Application.A25_TestStation_Auto.bError[1]" , "A25测试站5材料未取走报警" , true),
            ("Application.A25_TestStation_Auto.bError[2]" , "A25测试站5材料缺失报警" , true),
            ("Application.A25_TestStation_Auto.bError[10]" , "A25测试站5测试机返回EOT超时" , true),
            ("Application.A25_TestStation_Auto.bError[11]" , "A25测试站5返回Bin结果异常" , true),


            ("Application.A26_DirectionTurn_Auto.bError[1]" , "A26转向站2材料未取走报警" , true),
            ("Application.A26_DirectionTurn_Auto.bError[2]" , "A26转向站2材料缺失报警" , true),


            ("Application.A27_3DTestStation_Auto.bError[10]" , "A27 3D检测站CCD返回EOT超时报警" , true),


            ("Application.A28_TestNGContainer_Auto.bError[1]" , "A28四料盒4站NG抛料失败，需要手动清除材料" , true),
            ("Application.A28_TestNGContainer_Auto.bError[2]" , "A28四料盒4站NG抛料站材料缺失报警" , true),
            ("Application.A28_TestNGContainer_Auto.bError[25]" , "A28四料盒4站NG料盒1满料" , true),
            ("Application.A28_TestNGContainer_Auto.bError[26]" , "A28四料盒4站NG料盒2满料" , true),
            ("Application.A28_TestNGContainer_Auto.bError[27]" , "A28四料盒4站NG料盒3满料" , true),
            ("Application.A28_TestNGContainer_Auto.bError[28]" , "A28四料盒4站NG料盒4满料" , true),
            ("Application.A28_TestNGContainer_Auto.bError[31]" , "A28四料盒4站NG料盒1缺失" , true),
            ("Application.A28_TestNGContainer_Auto.bError[32]" , "A28四料盒4站NG料盒2缺失" , true),
            ("Application.A28_TestNGContainer_Auto.bError[33]" , "A28四料盒4站NG料盒3缺失" , true),
            ("Application.A28_TestNGContainer_Auto.bError[34]" , "A28四料盒4站NG料盒4缺失" , true),


            ("Application.A29_TestNGContainer_Auto.bError[1]" , "A29四料盒5站NG抛料失败，需要手动清除材料" , true),
            ("Application.A29_TestNGContainer_Auto.bError[2]" , "A29四料盒5站NG抛料站材料缺失报警" , true),
            ("Application.A29_TestNGContainer_Auto.bError[25]" , "A29四料盒5站NG料盒1满料" , true),
            ("Application.A29_TestNGContainer_Auto.bError[26]" , "A29四料盒5站NG料盒2满料" , true),
            ("Application.A29_TestNGContainer_Auto.bError[27]" , "A29四料盒5站NG料盒3满料" , true),
            ("Application.A29_TestNGContainer_Auto.bError[28]" , "A29四料盒5站NG料盒4满料" , true),
            ("Application.A29_TestNGContainer_Auto.bError[31]" , "A29四料盒5站NG料盒1缺失" , true),
            ("Application.A29_TestNGContainer_Auto.bError[32]" , "A29四料盒5站NG料盒2缺失" , true),
            ("Application.A29_TestNGContainer_Auto.bError[33]" , "A29四料盒5站NG料盒3缺失" , true),
            ("Application.A29_TestNGContainer_Auto.bError[34]" , "A29四料盒5站NG料盒4缺失" , true),


            ("Application.A30_LocateStation_Auto.bError[1]" , "A30封装前定位材料未取走报警" , true),
            ("Application.A30_LocateStation_Auto.bError[2]" , "A30封装前定位材料缺失报警" , true),


            ("Application.A33_Encapsulation1_Auto.b_Error[1]" , "A33封装站载带丢失" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[2]" , "A33封装站盖膜丢失" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[3]" , "A33封装站加温过高" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[4]" , "A33封装站加温过低" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[5]" , "A33封装站封合罩丢失" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[6]" , "A33封装站叠料报警" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[7]" , "A33封装站封装站整租未到位" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[8]" , "A33封装站盖膜余量少于两卷，及时更换" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[9]" , "A33封装站载带余量少于两卷，及时更换" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[10]" , "A33封装站模式2上下吸嘴有残料" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[11]" , "A33封装站上下吸嘴料件丢失" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[12]" , "A33封装站默认模式上下吸嘴有残料" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[13]" , "A33封装站印字复检CCD未通过" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[14]" , "A33封装站空料检测检出异料" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[15]" , "A33封装站空料检测检出空料" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[16]" , "A33封装站走带时封合轴位置异常" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[17]" , "A33封装站走带时切刀位置异常，检查切刀电磁阀信号" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[18]" , "A33封装站压痕画像CCD未通过" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[19]" , "A33封装站切刀位置异常，不在初始位置" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[20]" , "A33封装站切刀伸出未到位" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[21]" , "A33封装站走带对位失败" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[22]" , "A33封装站封合气缸到位超时" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[23]" , "A33封装站印字复检相机超时" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[24]" , "A33封装站压痕画像相机超时" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[25]" , "A33封装站走带轴移动过大无法自动复位，需手动回记忆位" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[30]" , "A33封装站CCD1发送EOT后返回结果超时" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[31]" , "A33封装站CCD2发送EOT后返回结果超时" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[32]" , "A33封装站上料吸嘴与上料格同时有料，需手动抛掉其中一个" , true),
            ("Application.A33_Encapsulation1_Auto.b_Error[33]" , "A33封装站上料吸嘴取料连续失败" , true),


            ("Application.PieceDate.ar_b低良报警[1]" , "测试站1良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[2]" , "测试站2良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[3]" , "测试站3良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[4]" , "测试站4良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[5]" , "测试站5良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[6]" , "热测良率过低" , true),
            //("Application.PieceDate.ar_b低良报警[7]" , "镭射打标CCD良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[8]" , "3D检测良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[9]" , "封装CCD1良率过低" , true),
            ("Application.PieceDate.ar_b低良报警[10]" , "封装CCD2良率过低" , true),
            //("Application.PieceDate.ar_b低良报警[11]" , "封装2CCD1良率过低" , true),
            //("Application.PieceDate.ar_b低良报警[12]" , "封装2CCD2良率过低" , true),


            ("Application.Var_state.b吸嘴寿命报警[1]" , "吸嘴1使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[2]" , "吸嘴2使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[3]" , "吸嘴3使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[4]" , "吸嘴4使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[5]" , "吸嘴5使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[6]" , "吸嘴6使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[7]" , "吸嘴7使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[8]" , "吸嘴8使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[9]" , "吸嘴9使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[10]" , "吸嘴10使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[11]" , "吸嘴11使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[12]" , "吸嘴12使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[13]" , "吸嘴13使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[14]" , "吸嘴14使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[15]" , "吸嘴15使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[16]" , "吸嘴16使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[17]" , "吸嘴17使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[18]" , "吸嘴18使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[19]" , "吸嘴19使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[20]" , "吸嘴20使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[21]" , "吸嘴21使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[22]" , "吸嘴22使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[23]" , "吸嘴23使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[24]" , "吸嘴24使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[25]" , "吸嘴25使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[26]" , "吸嘴26使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[27]" , "吸嘴27使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[28]" , "吸嘴28使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[29]" , "吸嘴29使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[30]" , "吸嘴30使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[31]" , "吸嘴31使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[32]" , "吸嘴32使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[33]" , "吸嘴33使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[34]" , "吸嘴34使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[35]" , "吸嘴35使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[36]" , "吸嘴36使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[37]" , "吸嘴37使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[38]" , "吸嘴38使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[39]" , "吸嘴39使用寿命到达" , true),
            ("Application.Var_state.b吸嘴寿命报警[40]" , "吸嘴40使用寿命到达" , true),
        };
    }
    public class AlarmDisplay
    {
        public int Id { get; set; }
        public int RowNumber { get; set; }
        public DateTime Timestamp { get; set; }
        public string Username { get; set; }
        public string AlarmMessage { get; set; }
        public string AlarmType { get; set; } // 显示为 "Error", "Warning" 等
    }
    public class PairedAlarm
    {
        public string Username { get; set; }
        public string AlarmMessage { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; } // 若未清除，则为 DateTime.MinValue
        public string Type { get; set; } // 显示为 "Error", "Warning" 等
        // 辅助属性（可选）
        public bool IsCleared => EndTime != DateTime.MinValue;

        public static List<PairedAlarm> PairAlarms(List<AlarmDisplay> logs)
        {
            if (logs == null || !logs.Any())
                return new List<PairedAlarm>();

            var grouped = logs.GroupBy(x => x.AlarmMessage);
            var result = new List<PairedAlarm>();

            foreach (var group in grouped)
            {
                DateTime pendingStart = DateTime.MinValue; // 用 MinValue 表示“无 pending”
                string alarmType=null;
                foreach (var log in group.OrderBy(x => x.Timestamp))
                {
                    if (log.AlarmType != AlarmType.Cleared.ToString())
                    {
                        // 只有当前没有 pending 发生事件时，才记录新的开始
                        if (pendingStart == DateTime.MinValue)
                        {
                            pendingStart = log.Timestamp;
                            alarmType = log.AlarmType;
                        }
                        // 否则忽略重复“发生”
                    }
                    else if (log.AlarmType == AlarmType.Cleared.ToString())
                    {
                        if (pendingStart != DateTime.MinValue)
                        {
                            // 配对成功
                            result.Add(new PairedAlarm
                            {
                                AlarmMessage = group.Key,
                                StartTime = pendingStart,
                                EndTime = log.Timestamp,
                                Type=alarmType
                                
                            });
                            pendingStart = DateTime.MinValue; // 清空 pending
                        }
                        // 否则：清除前无发生，忽略（或记录警告）
                    }
                }

                // 循环结束后，若仍有 pending，说明未清除
                if (pendingStart != DateTime.MinValue)
                {
                    result.Add(new PairedAlarm
                    {
                        AlarmMessage = group.Key,
                        StartTime = pendingStart,
                        EndTime = DateTime.Now // 表示未清除
                    });
                }
            }

            return result.OrderBy(x => x.StartTime).ThenBy(x => x.AlarmMessage).ToList();
        }
    }


}
