matlab之用m脚本自动完成检查变量命名规范

matlab之用m脚本自动完成检查变量命名规范

文章目录

    • matlab之用m脚本自动完成检查变量命名规范
      • 0.前言
      • 1.需求分析
        • 1.1完成变量的拆分
        • 1.2对每大块拆成的小块判断
        • 1.3第二大块的要注意顺序
      • 2.程序实现

0.前言

接到这个任务好久了,由于需求一直在变,导致我无法冻结,目前算是一个比较稳定的版本,由于涉及到公司机密问题,我只能提几点对技术提高有帮助的需求,具体如下!

1.需求分析

以KtTqDmd_VehSpdSign_flg为例

1.1完成变量的拆分

第一点:拆成三大块:KtTqDmd和VehSpdSOCSign和flg
第二点:每一个大块要根据大写拆分或者其他特殊需求拆分
如下第一大块:要拆成Kt;Tq;Dmd
第二大块:Veh;Spd:SOC;Sign
第三大块:Flg

1.2对每大块拆成的小块判断

实现方法:根据大写拆分

1.3第二大块的要注意顺序

即:第二大块:Veh;Spd:SOC;Sign这四个属于4大类的话,要注意先后顺序
如:Veh属于MeanEnvironmentDevice;Spd属于ActionPhysicalType;等要注意顺序,MED一定要排在ActionPhysicalType的前面
实现方法:根据前后游标来判断(利用m语言的键值对,利用排序看是否顺序改变来判断)

2.程序实现

代码如下:

clear;
clc;
disp('程序正在运行....');
%%
% Total_variable_list 可更改提取的文件名和对应的sheet已经范围
file_name_str = './变量命名规范查询表.xlsx';
need_write_sheet = '变量表'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Total_variable_list] = xlsread(file_name_str,need_write_sheet,xlrange);  % the first thing is data,the second is text
Total_variable_list(1)= []; % get rid of D1,the rest of type is cell
% Total_variable_list={'KtTqDmd_VehSpdSign_flg'}; % 方便调试,先提前写好

% Type_identifier_list
Type_identifier_sheet = '类型标识符'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Type_identifier_list] = xlsread(file_name_str,Type_identifier_sheet,xlrange);  % the first thing is data,the second is text
Type_identifier_list(1)= []; % get rid of D1,the rest of type is cell
% Type_identifier_list = {'C','K','V','M'}; % 方便调试,先提前写好

% Type_of_data_list
Type_of_data_sheet = '数据类型'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,Type_of_data_list] = xlsread(file_name_str,Type_of_data_sheet,xlrange);  % the first thing is data,the second is text
Type_of_data_list(1)= []; % get rid of D1,the rest of type is cell
% Type_of_data_list = {'m','d','t','u8','s8','u16','s16','u32','i32','b','f'};% 方便调试,先提前写好

% Extended_description_list
Extended_description_sheet = '扩展说明'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Extended_description_list] = xlsread(file_name_str,Extended_description_sheet,xlrange);  % the first thing is data,the second is text
Extended_description_list(1)= []; % get rid of D1,the rest of type is cell
% Extended_description_list= {'1X','1Y','2X','2Y','2Z'};% 方便调试,先提前写好

% unit_type_list
unit_type_sheet = '单位类型'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,unit_type_list] = xlsread(file_name_str,unit_type_sheet,xlrange);  % the first thing is data,the second is text
unit_type_list(1)= []; % get rid of D1,the rest of type is cell
% unit_type_list = {'rpm','Nm','Pct','enum','Kph','deg','V','A','s','ms','w','kw','m','km','flg','Nmps','inc','dec','lim','NULL'};

% ActionPhysicalType_list
ActionPhysicalType_sheet = 'ActionPhysicalType'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,ActionPhysicalType_list] = xlsread(file_name_str,ActionPhysicalType_sheet,xlrange);  % the first thing is data,the second is text
ActionPhysicalType_list(1)= []; % get rid of D1,the rest of type is cell
% ActionPhysicalType_list = {'Abrt',	'Absptn',	'Abstrn',	'Accl',	'Acpt',	'Acs',	'Accmd',	'Ack',	'Acq',	'Actn',	'Actvn',	'Actv',	'Acttn',	'Add',	'Adh',	'Adj',	'Adjmt',	'Adsptn',	'Agi',	'Aid',	'Allot',	'Amnt',	'Ang',	'Ajerk',	'Apply',	'Arbn',	'Ar',	'Arm',	'Asstn',	'Authn',	'Aux',	'Bkp',	'Blink',	'Blstr',	'Bnce',	'Bdr',	'Brkg',	'Brn',	'BMEP',	'Brkpt',	'Bucd',	'Brng',	'Byp',	'Calc',	'Calcn',	'Cal',	'Call',	'Cncl',	'Cp',	'Chg',	'Chrg',	'Chk',	'CS',	'Chirp',	'Circum',	'Clsf',	'Cln',	'Clng',	'Clr',	'Clima',	'Cls',	'Coast',	'Coff',	'ColdStrt',	'Cllsn',	'Cmb',	'Cmng',	'Cmd',	'Cmm',	'Cmt',	'Comp',	'Cmptmt',	'Cmp',	'Conc',	'Cdsn',	'Cdng',	'Cfm',	'Cstn',	'Cnsm',	'Cns',	'Ctrl',	'Cnvc',	'Cnvn',	'Coolg',	'CD',	'Coor',	'Coorn',	'Copy',	'Corrn',	'Cnt',	'Coupl',	'Covrg',	'Crk',	'Crash',	'Crawl',	'Crp',	'Crs',	'I',	'Cut',	'Dampg',	'Day',	'Dctvt',	'Dctvn',	'Deb',	'Decel',	'Defrst',	'Defu',	'Deg',	'Dly',	'Drtv',	'Kd',	'Tv',	'Dep',	'Desptn',	'Dtcn',	'Dtrt',	'Detmn',	'Dvt',	'Diag',	'Diam',	'Diffp',	'Dffsn',	'Dgt',	'Disb',	'Disa',	'Disarm',	'Dcha',	'Dcnct',	'Disczn',	'Dst',	'Dstb',	'Dthr',	'Div',	'Dos',	'Drft',	'Drng',	'Drift',	'Drvaw',	'Drvg',	'Drp',	'Dropspd',	'Durn',	'Duty',	'Ducyc',	'Dwl',	'Edit',	'Eff',	'Ela',	'Emsvty',	'Emuln',	'Ena',	'Enag',	'Enc',	'Egy',	'Engmt',	'Enhmt',	'Enchmt',	'Entry',	'Erase',	'Err',	'Esti',	'Evln',	'E',	'Excd',	'Exh',	'Exct',	'Exclsn',	'Exit',	'Exp',	'Exp',	'Expn',	'Exprt',	'Extn',	'Extrpn',	'Fac',	'Fade',	'Fall',	'Fillg',	'Fns',	'Fixa',	'Flsg',	'Flow',	'Fluc',	'Flux',	'FM',	'Fold',	'Folw',	'F',	'Frq',	'Fric',	'Fid',	'Fusn',	'Gain',	'Gentn',	'Get',	'Glw',	'Grdt',	'Grip',	'Hdlg',	'Heal','Heat',	'Heatg',	'Htc',	'Hgt',	'Hbrnt',	'Hold',	'Hr',	'Hum',	'Idn',	'Illmn',	'Img',	'Imobn',	'Impct',	'Z',	'Imprt',	'Iacv',	'Incln',	'Incl',	'Inct',	'Idx',	'Indcd',	'IMEP',	'Indcn',	'L',	'Inertia',	'Inhb',	'Inhbn',	'Initlzt',	'Inj',	'Insert',	'Insrtn',	'Insp',	'Ki',	'Tn',	'Itgr',	'Inten',	'Intrpn',	'Intrpt',	'Intv',	'Invld',	'Ivt',	'Jam',	'Jmp',	'Keep',	'Kd',	'Knk',	'Lmbd',	'Laun',	'Lyt',	'Lrn',	'Lrng',	'Lvng',	'Len',	'Lvl',	'Lvlg',	'Lighter',	'Ltg',	'Limt',	'Lnrzn',	'Lnk',	'List',	'Load',	'Ldng',	'Lct',	'Lock',	'Lockg',	'Lubt',	'Mng',	'Mpg',	'Mask',	'M',	'Masg',	'Meas',	'Milg',	'Ms',	'Mins',	'Misf',	'Misfg',	'Mtgtn',	'Modcn',	'Modln',	'Mom',	'Mon',	'Mth',	'Mtn',	'Mntg',	'Mov',	'Movg',	'Notif',	'Nr',	'Obs',	'Ohm',	'Oper',	'Optmzn',	'Orntn',	'Osc',	'Oscn',	'Ovrhtg',	'Ovrd',	'Ovtk',	'Oxd',	'Park',	'Prkg',	'Part',	'Pass',	'Passd',	'Pctg',	'Pfmnc',	'Pen',	'Polling',	'Posn',	'Posng',	'Pwr',	'Prepn',	'Prep',	'Pres',	'P',	'Prevn',	'Procsng',	'Prog',	'Progm',	'Progs',	'Kp',	'Protn',	'Pull',	'Purg',	'Push',	'Put',	'PWM',	'Quisc',	'Qut',	'Rad',	'Rd',	'Rng',	'Rate',	'Ratng',	'Rat',	'Reactn',	'Reacvn',	'Read',	'Readg',	'Rbd',	'Recall',	'Rciv',	'Rcpt',	'Recirc',	'Rec',	'Rcv',	'Recup',	'Redn',	'Rflctg',	'Refi',	'Rflx',	'Refrsh',	'Refu',	'Rgn',	'Rgln',	'Reinf',	'Rejct',	'Rels',	'Rlvc',	'Rmvl',	'Rep',	'Repn',	'Repl',	'Replm',	'Rpt',	'Req',	'Rqur',	'Rst',	'R',	'Resp',	'Rstrt',	'Restore',	'Restrnt',	'Resu',	'Rtd',	'Rvsg',	'Rvis',	'Rev',	'Rho',	'Rcrltn',	'Ride',	'Rise',	'Risg',	'Roll',	'Rollg',	'Rollovr',	'Rot',	'Roughns',	'Run',	'Runng',	'RT',	'Sfty',	'Sale',	'Smp',	'Satn',	'Save',	'Sca',	'Scan','Scav',	'Seatg',	'Sec',	'Snd',	'Sen',	'Sep',	'Set',	'Setg',	'Shd',	'Shift',	'Shdwn',	'Shup',	'Shiftg',	'Shong',	'Shtdn',	'Shto',	'Sim',	'Simn',	'Sitn',	'Sleep',	'Sldg',	'Slip',	'Slop',	'Smotng',	'Spk',	'Spd',	'Spl',	'Spt',	'Sq',	'Staby',	'Stabn',	'Stallg',	'Stamp',	'Stand',	'Stdn',	'Strt',	'Strtg',	'St',	'Sof',	'Soh',	'Sts',	'Stfn',	'Stop',	'Store',	'Strike',	'Stk',	'Sub',	'Scs',	'Suctn',	'Sppl',	'Sply',	'Spprt',	'Supp',	'Surge',	'Suspc',	'Swp',	'Sym',	'Syncn',	'Sync',	'Synt',	'Task',	'Tau',	'Telltl',	'T',	'Term',	'Test',	'Thrmls',	'Tgtnss',	'Ti',	'Tc',	'Td',	'Tout',	'Tog',	'Tq',	'Tors',	'Tw',	'Trac',	'Trf',	'Trfon',	'Tran',	'Trans',	'Trnsp',	'Trap',	'Trvl',	'Treat',	'Trig',	'Trim',	'Trip',	'Tumb',	'Tun',	'Ukwn',	'Unlck',	'Upd',	'Upw',	'Usg',	'Use',	'Valt',	'Vld',	'Vldt',	'Val',	'V',	'Ventn',	'Vibrn',	'Vcos',	'U',	'Vol',	'Wait',	'Wake',	'Wrmp',	'Warn',	'Wshng',	'Wkn',	'Weakng',	'Wght',	'Wtng',	'Wipg',	'Wish',	'Wrk',	'Wr',	'Yaw',	'Yr'};

% ConditionQualifier_list
ConditionQualifier_sheet = 'ConditionQualifier'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,ConditionQualifier_list] = xlsread(file_name_str,ConditionQualifier_sheet,xlrange);  % the first thing is data,the second is text
ConditionQualifier_list(1)= []; % get rid of D1,the rest of type is cell

% ConditionQualifier_list = {'Abd',	'Abno',	'Abs',	'Acc',	'Accumd',	'Acst',	'Act',	'Adptv',	'Addl',	'Addv',	'Adr',	'Adv',	'Ajar',	'All',	'Allwd',	'Alpha',	'Altv',	'Alti',	'Amp',	'An',	'Agr',	'Arbd',	'Ary',	'Assid',	'Async',	'Attn',	'Aud',	'Auto',	'Avl',	'Avg',	'B1',	'B4',	'Back',	'Backlt',	'Backkw',	'Bad',	'Bal',	'Brm',	'Bas',	'Basc',	'Beta',	'Bgft',	'Bny',	'Bli',	'Blkd',	'Bool',	'Boost',	'Boot',	'Bndls',	'Break',	'Brt',	'Bkn',	'Byte',	'Calcd',	'Cncld',	'Cpby',	'Cgrd',	'Cen',	'Chartc',	'Ckd',	'China',	'Circuml',	'Clmpd',	'Clrd',	'Clsd',	'CL',	'Cot',	'Cold',	'Col',	'Cmft',	'Cmn',	'Cpl',	'Cmpl',	'Cmplx',	'Cmpn',	'Cdn',	'Cfg',	'Cfgd',	'Cfmd',	'Con',	'Contns',	'Ctrld',	'Cnvinc',	'Cool',	'Coord',	'Cornr',	'Corrd',	'Corrln',	'Coupld',	'Crtr',	'Crit',	'Cubd',	'Cub',	'Crvt',	'Cyc',	'Date',	'Dctvd',	'Dbnd',	'Dec',	'Dft',	'Dfct',	'Defd',	'Deged',	'Dlt',	'Dmd',	'Dend',	'Dnmtr',	'Dens',	'Dprt',	'Dsr',	'Dtcd',	'Diagc',	'Diff',	'Dig',	'Dim',	'Dimd',	'Dir',	'Disarmed',	'Dis',	'Dpl',	'Dispd',	'Done',	'Dbl',	'Down',	'Dwnhl',	'Ds',	'Drg',	'Drvblty',	'Drv',	'Dry',	'Dummy',	'Dyn',	'Early',	'Easy',	'Eco',	'Edge',	'Efc',	'Elpd',	'Eltl',	'Electc',	'Elevn',	'Emgy',	'Emp',	'Empty',	'Emuld',	'Enad',	'End',	'Engd',	'Enhd',	'Engh',	'Equ',	'Equid',	'Equiv',	'Estimd',	'Evap',	'Even',	'Eve',	'Excdd',	'Excr',	'Excpn',	'Exist',	'Exo',	'Expd',	'Extd',	'Ext',	'Facd',	'Faild',	'Failr',	'Frd',	'Fast',	'Fav',	'FB',	'Ff',	'Ft',	'Fmale',	'Fie',	'Fild',	'Final',	'Fine',	'Finshd',	'First',	'Fixd',	'Flg',	'Flank',	'Flash',	'Flood',	'Fmt',	'Fwd',	'Free',	'Fw',	'Fr',	'Frzn',	'Full',	'Fctl',	'Gap',	'Gend',	'Gen',	'Gmtrc',	'Giga',	'Glb','Grd',	'Gr',	'Group',	'Half',	'Hptc',	'Hard',	'Hzrd',	'Heatd',	'Hvy',	'Hz',	'Hi',	'HP',	'Hist',	'Hom',	'Hozl',	'Hot',	'Hyb',	'Hyd',	'Hys',	'Id',	'Imdt',	'Impy',	'Imps',	'Impsb',	'Inc',	'Ind',	'Indct',	'Info',	'Init',	'Inp',	'Insd',	'Intgl',	'Iprt',	'Itgrtd',	'Intd',	'Intn',	'Intr',	'Ilck',	'Intery',	'Inter',	'Intm',	'Int',	'Intvl',	'Intxcn',	'Intrv',	'Ivs',	'Irrv',	'Jou',	'Kelvin',	'Keyls',	'Kilo',	'Kin',	'Lrg',	'Lst',	'Late',	'Lat',	'Lead',	'Lean',	'Left',	'Lgt',	'Lim',	'Limd',	'Limp',	'Limpho',	'Lnr',	'Lqd',	'L',	'Lcl',	'Lockd',	'Logl',	'Long',	'Lgtd',	'Loss',	'Lost',	'Ldn',	'Lo',	'Lowr',	'LP',	'Mag',	'Mgn',	'Main',	'Mntn',	'Male',	'Manv',	'Man',	'Mat',	'Max',	'Mean',	'Measd',	'Mec',	'Mecl',	'Mega',	'Memr',	'Memd',	'Mtr',	'Micro',	'Mid',	'Milli',	'Min',	'Misc',	'Miss',	'Mod',	'Mdld',	'Mod',	'Mntd',	'Mpl',	'Nat',	'Nav',	'Near',	'Neg',	'Neut',	'New',	'Nwt',	'Nxt',	'No',	'Nois',	'Nom',	'Nlnr',	'Norm',	'Now',	'Obj',	'Odd',	'Off',	'OFF',	'Offs',	'Ok',	'Old',	'On',	'ON',	'Only',	'Open',	'Opend',	'Optm',	'Opt',	'Ord',	'Outp',	'Outsd',	'Over',	'Ovf',	'Ovrhtd',	'Ovld',	'Ovrdn',	'Panic',	'Prm',	'Par',	'Ptl',	'Pa',	'Pas',	'Pat',	'Peak',	'Pnd',	'Perc',	'Perd',	'Prmnt',	'Prsnl',	'Pha',	'Phy',	'Plt',	'Plbty',	'Plaus',	'Pnm',	'Polnml',	'Pos',	'Psbl',	'Post',	'Pre',	'Pred',	'Prel',	'Prem',	'Prsnt',	'Psd',	'Prev',	'Prim',	'Prio',	'Prvt',	'Problty',	'Progd',	'P',	'Pprt',	'Prp',	'Protd',	'Prtctv',	'Qly',	'Qnty',	'Quo',	'Ramp',	'Rnd',	'Raw',	'Rchd',	'Rctv',	'Rdy',	'Real',	'Relzd',	'Re',	'Rsn',	'Recpr',	'Rcnd',	'Rcmn',	'Ref',	'Rgtv','Rgl',	'Rnst',	'Rejctd',	'Rel',	'Reld',	'Rlv',	'Rmng',	'Rem',	'Reqd',	'Rqrd',	'Resv',	'Resd',	'Resi',	'Resl',	'Rest',	'Res',	'Rvs',	'Rvsb',	'Rich',	'Right',	'Roty',	'Rotl',	'Safe',	'SSt',	'Satd',	'Saved',	'Scdr',	'Sector',	'Secu',	'Segd',	'Seld',	'Self',	'Snvty',	'Sent',	'Seq',	'Seql',	'Serl',	'Srv',	'Sp',	'Sev',	'Shrt',	'Side',	'Sgn',	'Simp',	'Simd',	'Sng',	'Slow',	'Sml',	'Smt',	'Smot',	'Soft',	'Sld',	'Sonc',	'Soon',	'Src',	'Spare',	'Spcl',	'Spc',	'Spo',	'Sqd',	'Sqrt',	'Stab',	'Stall',	'Std',	'Stb',	'Standg',	'Sndsl',	'Strtd',	'Stat',	'Stc',	'Stdy',	'Stp',	'Step',	'Srad',	'Still',	'Sti',	'Stoi',	'Strght',	'Stgy',	'Strat',	'Stuck',	'Subt',	'Sum',	'Supr',	'Suspd',	'Swil',	'Syncd',	'Tgt',	'Tmp',	'Tstd',	'Theo',	'Therm',	'Thrd',	'Thd',	'Tolr',	'Top',	'TDC',	'Tot',	'Touchd',	'Tra',	'Trv',	'Trapg',	'Trvld',	'Tro',	'Trbl',	'Turn',	'Typ',	'Undefd',	'Under',	'Unfav',	'Unlckd',	'Unstall',	'Up',	'Uppr',	'Us',	'Vanity',	'Var',	'Vari',	'Vrnt',	'Vect',	'Vers',	'Vert',	'Virt',	'Vis',	'Volt',	'Volmc',	'Wup',	'Wrm',	'Watt',	'Way',	'Wghtd',	'Wldd',	'Wide',	'WOT',	'Width',	'Wntr',	'Wishd',	'Wrg',	'Yes'};

% MeanEnvironmentDevice_list
MeanEnvironmentDevice_sheet = 'MeanEnvironmentDevice'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,MeanEnvironmentDevice_list] = xlsread(file_name_str,MeanEnvironmentDevice_sheet,xlrange);  % the first thing is data,the second is text
MeanEnvironmentDevice_list(1)= []; % get rid of D1,the rest of type is cell
%方便测试,提前提取
% MeanEnvironmentDevice_list = {'ABS','Li',	'AC',	'ACC',	'Accr',	'Acsy',	'Accum',	'Actr',	'Adpt',	'AEB',	'Air',	'Airb',	'Airf',	'Alrm',	'AWD',	'Alt',	'Amb',	'Ampr',	'AMT',	'Anode',	'Aki',	'App',	'ASW',	'Armtr',	'Ash',	'Ashtray',	'Assi',	'AVH',	'Axle',	'Bank',	'Bnk',	'Bar',	'BSW',	'Batt',	'BE',	'BMU',	'BDC',	'Beam',	'Blt',	'BSG',	'Bench',	'Bcycl',	'Blk',	'Bd',	'Body',	'Bolt',	'Btldr',	'Box',	'Bpil',	'Brkt',	'Brk',	'BLS',	'Brdg',	'Bri',	'Buc',	'Buf',	'Bmp',	'Brnr',	'Bus',	'Btn',	'Buz',	'Cbn',	'Cam',	'Camsft',	'Cnst',	'Car',	'Case',	'Cat',	'Cell',	'Chmb',	'Ch',	'Chrgr',	'Chrgn',	'Chsis',	'Chd',	'Chok',	'Cgrt',	'Circ',	'Cty',	'Clmp',	'Cls',	'Clnr',	'Clk',	'Clu',	'Cch',	'Cod',	'COG',	'Coil',	'Coll',	'Cpt',	'Cmpr',	'Cdnr',	'CVT',	'Ctrlr',	'CAN',	'Cnvr',	'Coolt',	'CF',	'Coorr',	'Cntr',	'Ctrsft',	'Ctry',	'Course',	'Cpil',	'CPU',	'Crkcs',	'Crksft',	'CRBS',	'Curt',	'Crv',	'Cush',	'Cust',	'CVT',	'Cyl',	'D',	'Dampr',	'DAS',	'Dshb',	'Dash',	'Data',	'Dayti',	'DC',	'DCC',	'DCT',	'DEM',	'Demo',	'DR',	'Dev',	'Dew',	'Dsl',	'Dpf',	'Dftl',	'Dftllock',	'Dil',	'Dio',	'Dire',	'Dsk',	'Disp',	'Door',	'DM',	'Dln',	'Drvr',	'Dt',	'DTD',	'Dyno',	'EBD',	'ECU',	'EGR',	'EHB',	'Elc',	'Elm',	'Emi',	'Em',	'EMS',	'Encr',	'Eng',	'Env',	'EPB',	'Equip',	'ERAD',	'ESC',	'ESP',	'Estimr',	'Ethl',	'Euler',	'Evlr',	'Evapr',	'Exh',	'Expdr',	'Extr',	'Facy',	'Fan',	'Flt',	'File',	'Filt',	'Findr',	'Flk',	'Flap',	'Flxry',	'Flpr',	'Flr',	'Fld',	'Flywh',	'Fog',	'Fold',	'Fol',	'Foot',	'Footwell',	'Frk',	'Fu',	'Fct',	'Fuse',	'Gas',	'Gsl',	'Gate',	'Gtw',	'Gear',	'GP',	'Gbx',	'Genr',	'Glass','GD',	'Glv',	'Govr',	'Grvy',	'Grid',	'Grl',	'Gnd',	'Gulf',	'Hndbrk',	'Hdl',	'HW',	'HBA',	'HCU',	'Hd',	'Hdr',	'Hdlamp',	'Hdphn',	'Hdrest',	'Heatr',	'Hpass',	'HPP',	'HSD',	'HV',	'HVB',	'HVC',	'Hill',	'HDC',	'HHC',	'Hitch',	'HMI',	'Home',	'Hood',	'Hoop',	'Hzn',	'Horn',	'Htl',	'HVAC',	'I',	'Ice',	'Idle',	'Ign',	'Immo',	'Imp',	'IUPR',	'Indcr',	'Indctr',	'Infstr',	'Ice',	'Injr',	'Inlet',	'Inst',	'Instr',	'Intk',	'Intgr',	'Itgrtr',	'Ico',	'Interdom',	'If',	'ISG',	'Itp',	'Intscn',	'Inv',	'Jerk',	'Jctn',	'Key',	'Knee',	'Knob',	'Lamp',	'Lane',	'Lang',	'Ltch',	'Lay',	'Leak',	'LED',	'Lvr',	'Lid',	'Limr',	'Line',	'Lob',	'Loop',	'LV',	'Lpass',	'LPP',	'LSD',	'LVB',	'Lum',	'Mac',	'MIL',	'Mngt',	'Mgr',	'Mnfld',	'MT',	'Map',	'Mkr',	'Mkt',	'Mst',	'Mtrl',	'Mtrx',	'Med',	'Mem',	'Msg',	'Mtl',	'Mthl',	'Meth',	'MC',	'Mind',	'Mirr',	'Mdl',	'Mdul',	'Mol',	'Momtm',	'Monr',	'Mot',	'Motorcycle',	'Movmt',	'Mmed',	'Mux',	'Nano',	'Negn',	'Net',	'Night',	'N2',	'Nod',	'NVM',	'Nox',	'Noz',	'Obsvr',	'Obstcl',	'Obstrcn',	'Occpt',	'Oil',	'OBD',	'Opener',	'OS',	'Optic',	'Outl',	'Oxy',	'Pack',	'Pad',	'Pan',	'Passg',	'Pah',	'Pdl',	'Ped',	'Pelv',	'Pty',	'Pi',	'PID',	'Pin',	'Pinion',	'Pipe',	'Pist',	'Plate',	'Plg',	'Point',	'Ptr',	'Pool',	'Port',	'Poti',	'PT',	'Prec',	'PCV',	'Proc',	'Prof',	'Prj',	'Ppty',	'Prpsn',	'PTC',	'Puddle',	'Pls',	'Pmp',	'Pyro',	'Qf',	'Radar',	'Radr',	'Radio',	'Rail',	'Rain',	'RAM',	'RE',	'Rctnt',	'RSDS',	'RCWM',	'Rcir',	'RL',	'Regn',	'Rly',	'Rlf',	'Rmn',	'Restr',	'Rtdr',	'Rtrctr',	'Ring',	'RKE',	'Road',	'RD',	'Rollbar',	'Rollr',	'ROM',	'RON','Roof',	'Rtr',	'Route',	'Row',	'RPM',	'RSC',	'Rngbd',	'Scanr',	'Sdl',	'Seat',	'Sblt',	'Seed',	'Seg',	'Seln',	'Snsr',	'Ser',	'Servo',	'Shaft',	'Shftmp',	'Sov',	'Shnt',	'Shttr',	'Shtl',	'Sig',	'Sink',	'Sin',	'Slave',	'Sld',	'Smk',	'Snrck',	'Sckt',	'SW',	'SOI',	'Soln',	'Sound',	'Soundr',	'Sprk',	'Spkr',	'SPI',	'Splr',	'Sprg',	'SSM',	'Stabr',	'Stack',	'Stg',	'Strtr',	'SOC',	'Staty',	'Steer',	'Storg',	'Struct',	'Su',	'Sun',	'Sup',	'Surf',	'Surrndgs',	'Susp',	'Swirl',	'Swt',	'Sys',	'Tbl',	'Tank',	'Telgrm',	'Telm',	'Tensnr',	'Terminal',	'Tstbd',	'Thermo',	'Th',	'Thorax',	'Thr',	'Tmr',	'Tip',	'Tire',	'Tit',	'Tooth',	'Twbr',	'Track',	'Tcs',	'Trctr',	'Trfc',	'Trlr',	'Trsm',	'Tr',	'Tube',	'Tnl',	'Trb',	'Trbo',	'Twli',	'UDS',	'Unit',	'Urea',	'Usr',	'Vac',	'Vlv',	'Van',	'Vane',	'Vap',	'Veh',	'Vcu',	'Vlc',	'Vent',	'VIN',	'Visn',	'Wall',	'WR',	'Wnty',	'Wshct',	'Wshr',	'Wst',	'Wg',	'Wdg',	'Wtr',	'WV',	'Wthr',	'Whl',	'Whls',	'Wndg',	'Windw',	'WS',	'Wipr',	'Wire',	'Wirels',	'Word',	'World'};

% Preposition_list
Preposition_sheet = 'Preposition'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,Preposition_list] = xlsread(file_name_str,Preposition_sheet,xlrange);  % the first thing is data,the second is text
Preposition_list(1)= []; % get rid of D1,the rest of type is cell
%方便测试,提前提取
% Preposition_list= {'Aft',	'Ahd',	'And',	'At',	'Blw',	'Botm',	'By',	'Dur',	'For',	'From',	'In',	'Not',	'Of',	'Or',	'Out',	'Per',	'To',	'Vs',	'With',	'Within',	'Wo'};

%% 进行依次判断
need_write_sheet = '变量表';
number_0_9_Table = {'0','1','2','3','4','5','6','7','8','9'};

process_show=waitbar(0,'检查进度'); %显示初始界面
%特殊的1X对应的数据类型
special_type_data='';


for temp_total=1:length(Total_variable_list)
    test_variable_name = char(Total_variable_list(temp_total));
    Percentage = temp_total/length(Total_variable_list);
    waitbar(Percentage,process_show,['已完成'  (num2str(round(100*Percentage)))  '%']); %进度条,进度增加情况 后面有判断是否关闭


    %% First check variable length
    if length(test_variable_name) > 31 || (length(test_variable_name)==0)
        result_B = {'Failed'};
        write_region_B = char(strcat('B',num2str(temp_total+1)));
        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

        suggestion_C = {'Variable naming length should meet the requirements! or the data is empty '};
        write_region_C = char(strcat('C',num2str(temp_total+1)));
        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
        continue; % 结束循环中的第n次,继续n+1次循环
    end



    if (sum(strcmp(char(test_variable_name(1)),Type_identifier_list)) >= 1) %判断 第一个字母 >=是防止有多个查询

        if numel(strfind(char(test_variable_name),'_'))~=2 %表示有3段_,共两个下划线
            result_B = {'Failed'};
            write_region_B = char(strcat('B',num2str(temp_total+1)));
            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

            suggestion_C =  strcat({'component name error01: '},'need two _'); % matlab中的cell类型要转换成str之后在进行拼接;
            write_region_C = char(strcat('C',num2str(temp_total+1)));
            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
            continue; % 结束循环中的第n次,继续n+1次循环
        end

         %% 前面已经进行拆分  只有两个下划线 Vu32BattLimt_BMSVCUBattSoc_Nm; VtTrqLimt_VehSpdBattSoc1Y_flg; VmTrqLimt_VehSpdBattSoc2Z_enum
        if numel(strfind(char(test_variable_name),'_'))==2 
            %  重复判断,后期删除
            CheckDifferentBlock=regexp(test_variable_name,'_','split'); %根据下划线分隔为成3部分
            %% 第3部分判断和第1部分判断
            if (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求
                % 处理第一部分
                Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写
                matchStr = regexp(char(CheckDifferentBlock(1)),Re_Expression,'match');
                [matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !
                % 特殊情况宏变量:Mf_RvsTq_pct
                
                
                if matchStr_size==1 %表示第一部分只有一个大写字母,判断结束之后记得加continue;
                    %对第一部分的类型标识符和数据类型进行判断 ,由于第一个大写字母为类型标识符,已经判断过!
                    Macro_variable_special=char(matchStr(matchStr_size));
                    Macro_variable_special(1)=[]; %删除第一个类型标识符
                    special_type_data=Macro_variable_special;
                    if(sum(strcmp(char(Macro_variable_special),Type_of_data_list)) < 1) %数据类型没找到
                        %报错
                        result_B ={ 'Failed'};
                        write_region_B = char(strcat('B',num2str(temp_total+1)));
                        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                        suggestion_C = strcat({'Type identifier  error63: '},Macro_variable_special); 
                        write_region_C = char(strcat('C',num2str(temp_total+1)));
                        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                        continue; % 结束循环中的第n次,继续n+1次循环
                    end
                    %进行第2部分的判断即可
                   
                    special_second_block =char(CheckDifferentBlock(2));% 特殊情况判断
                    if(sum(strcmp(char(special_second_block(length(special_second_block)-1:end)),Extended_description_list)) >= 1)
                        if special_second_block(length(special_second_block)-1)=='1'  % 特殊情况判断:1X,1Y-->t;
                            if(special_type_data~='t')
                                %报错
                                result_B = {'Failed'};
                                write_region_B = char(strcat('B',num2str(temp_total+1)));
                                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果


                                suggestion_C = strcat({'1X,1Y must  match t.Matching error25: '},special_type_data); 
                                write_region_C = char(strcat('C',num2str(temp_total+1)));
                                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                continue; % 结束循环中的第n次,继续n+1次循环
                            end

                        elseif(special_second_block(length(special_second_block)-1)=='2') % 特殊情况判断:2X,2Y,2Z-->m
                            if(special_type_data~='m')
                                %报错
                                result_B = {'Failed'};
                                write_region_B = char(strcat('B',num2str(temp_total+1)));
                                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果


                                suggestion_C = strcat({'2X,2Y,2Z must  match m.Matching error26: '},special_type_data); 
                                write_region_C = char(strcat('C',num2str(temp_total+1)));
                                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                continue; % 结束循环中的第n次,继续n+1次循环
                            end
                        else
                            %报错
                            result_B = {'Failed'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果


                            suggestion_C = strcat({'the last two letter is wrong,Matching error23: '},special_second_block(length(special_second_block)-1:end)); 
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                            continue; % 结束循环中的第n次,继续n+1次循环
                        end
                        %把CheckDifferentBlock(2)中最后两个元素给去掉
                        special_second_block(length(special_second_block)-1:end)=[];

                    end

                    if (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求
                        % 处理第二部分
                        Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写
                        matchStr = regexp(char(special_second_block),Re_Expression,'match');
                        [matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !

                        total_split_section = {}; %用来记录一共拆分为几部分
                        for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena 

                            if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算
                                %% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_Type
                                matchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSS
                                matchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS 

                                if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                                   matchStrtest_Split_All_Capital_Type_total(end)=[];
                                end
                                if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                                   matchStrtest_Split_All_Capital_Type_total(end)=[];
                                end


                                if length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段
                                    length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的
                                   % disp(length_3_Split_All_Capital_Type);
                                    for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)
                                        matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组
                                        total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去
                                    end 
                                else % 如果小于6就直接进行判断
                                    matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断
                                    total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去
                                end
                                %% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_Type
                                matchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));
                                The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S 
                                later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pd
                                if length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况
                                    matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;
                                else
                                    matchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spd
                                end

                                if (sum(strcmp(char(matchStrtest_Split_First_Capital_Type(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                                   matchStrtest_Split_First_Capital_Type(end)=[];
                                end

                                total_split_section = [total_split_section , matchStrtest_Split_First_Capital_Type]; %添加进去


                            else    %只有一个大写字母 按照之前判断就可以了 比如:Spd
                                if temp==0 % 永远不会成立
                                    continue;
                                else
                                    judge_number = char(matchStr(temp));         
                                    if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次
                                        judge_number(end)=[];
                                    end
                                    if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数
                                        judge_number(end)=[];
                                    end
                                    total_split_section = [total_split_section , judge_number]; %用来记录一共拆分为几部分

                                end

                            end   
                        end  
                        %% 后续在这里对total_split_section进行判断
                        current_position=1;
                        next_position = 1;
                        Internal_error_flag=0;%内部错误标志位,表示内部的其他错误,比如没查询到等
                        for split_tmp=1:length(total_split_section)
                            %total_split_section(split_tmp) %测试
                            if split_tmp==1 %给定初始值,并设定两个位置游标,进行游标判断
                                if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)
                                    current_position = 1;
                                    next_position = 1;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)
                                    current_position = 2;
                                    next_position = 2;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)
                                    current_position = 3;
                                    next_position = 3;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)
                                    current_position = 4;
                                    next_position = 4;
                                else
                                    Internal_error_flag=1;%内部标志位
                                    
                                    result_B ={ 'Failed'};
                                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                    suggestion_C = strcat({'Abbreviation name error39: '},total_split_section(split_tmp)); 
                                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                    break; % 结束最里面的循环  

                                end
                                current_position = next_position; %再次确保两者初始值相等
                            else
                                   %求出下一个游标位置

                                if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)
                                    next_position = 1;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)
                                    next_position = 2;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)
                                    next_position = 3;
                                elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)
                                    next_position = 4;
                                else
                                    %报错,表示当前没有找到 %结束当前变量查询
                                    Internal_error_flag=1;%内部标志位
                                    result_B ={ 'Failed'};
                                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                    suggestion_C = strcat({'Abbreviation name error56: '},total_split_section(split_tmp)); 
                                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                    break; % 结束最里面的循环 
                                end
                                %游标位置的比较
                                if next_position >= current_position
                                    current_position = next_position; % 把此次游标的位置记录,方便后面比较
                                else %位置对应的顺序不符报错
                                    Internal_error_flag=1;%内部标志位
                                    result_B ={ 'Failed'};
                                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                    suggestion_C = strcat({'The two section  sequence error36: '},total_split_section(split_tmp),' and  ',total_split_section(split_tmp-1)); 
                                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                    break;  % 结束最里面的循环 
                                end

                            end
                        if Internal_error_flag==0 %内部标志位是0,即内部无错误
                            result_B = {'Pass'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                            suggestion_C = strcat({'NULL'});
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                        end
                        end
                        continue; %结束此次宏变量的判断,之前把正确的结果写入

                    else %表示第3部分不符要求
                        result_B = {'Failed'};
                        write_region_B = char(strcat('B',num2str(temp_total+1)));
                        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                        suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));
                        write_region_C = char(strcat('C',num2str(temp_total+1)));
                        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                        continue;
                    end
        
                end
                %% 第一部分有多个大写+小写的情况
                Internal_error_flag=0;
                for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena 
                    
                    if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算
                        %% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_Type
                        matchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSS
                        matchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS 

                        if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                           matchStrtest_Split_All_Capital_Type_total(end)=[];
                        end
                        if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                           matchStrtest_Split_All_Capital_Type_total(end)=[];
                        end


                        if length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段
                            length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的
                           % disp(length_3_Split_All_Capital_Type);
                            for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)
                                matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组
                                Logical_Flag_Result = (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ActionPhysicalType_list)) >= 1) || (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ConditionQualifier_list)) >= 1) ;
                                if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),MeanEnvironmentDevice_list)) >= 1) || Logical_Flag_Result ; % 如果第一个部分符合组件的简化要求 
                                    %表示无错误,测试使用;
                                    
                                else
                                    Internal_error_flag=1;
                                    result_B ={ 'Failed'};
                                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                    suggestion_C = strcat({'Abbreviation name error73: '},matchStrtest_Split_All_Capital_Type); 
                                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                    continue; % 结束循环中的第n次,继续n+1次循环    
                                end
                            end 
                        else % 如果小于6就直接进行判断
                            matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断
                            Logical_Flag_Result = (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ActionPhysicalType_list)) >= 1) || (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ConditionQualifier_list)) >= 1) ;
                            if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),MeanEnvironmentDevice_list)) >= 1) || Logical_Flag_Result ; % 如果第一个部分符合组件的简化要求 
                                %set(handles.result_suggest,'string','NULL_33'); %测试使用;
                            else
                                Internal_error_flag=1;
                                result_B ={ 'Failed'};
                                write_region_B = char(strcat('B',num2str(temp_total+1)));
                                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                suggestion_C = strcat({'Abbreviation name error31: '},matchStrtest_Split_All_Capital_Type); 
                                write_region_C = char(strcat('C',num2str(temp_total+1)));
                                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                continue; % 结束循环中的第n次,继续n+1次循环    
                            end
                        end
                        %% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_Type
                        matchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));
                        The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S 
                        later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pd
                        if length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况
                            matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;
                        else
                            matchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spd
                        end

                        if (sum(strcmp(char(matchStrtest_Split_First_Capital_Type),Abbreviation_Total_Table)) >= 1); % 如果第二个部分符合组件的简化要求 比如:Spd  
                             %测试使用;
                         
                        else
                            Internal_error_flag=1;
                            result_B = {'Failed'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                            suggestion_C =  strcat({'Abbreviation name error22: '},matchStrtest_Split_First_Capital_Type);
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                            continue; % 结束循环中的第n次,继续n+1次循环     

                        end 
                    else    %只有一个大写字母 按照之前判断就可以了 比如:Spd
                        if temp==1 % 表示是Vu32
                           first_little_leter = char(matchStr(temp));
                           first_little_leter(1)=[]; %删除第一个字母V
                           special_type_data = first_little_leter;% 因为后面可能需要进行判断,如1X等特殊情况判断
                           if (sum(strcmp(char((special_type_data)),Type_of_data_list)) == 0) %表示没找到u32之类的数据类型
                                result_B = {'Failed'};
                                write_region_B = char(strcat('B',num2str(temp_total+1)));
                                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                suggestion_C =  strcat({'type data name error23: '},char(matchStr(temp))); % matlab中的cell类型要转换成str之后在进行拼接;
                                write_region_C = char(strcat('C',num2str(temp_total+1)));
                                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                           end
                            
                        else
                            judge_number = char(matchStr(temp));         
                            if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次
                                judge_number(end)=[];
                            end
                            if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数
                                judge_number(end)=[];
                            end

                            if (sum(strcmp(char((judge_number)),ActionPhysicalType_list)) >= 1) | (sum(strcmp(char((judge_number)),ConditionQualifier_list)) >= 1) | (sum(strcmp(char((judge_number)),MeanEnvironmentDevice_list)) >= 1)% 如果第二个部分符合组件的简化要求 
                                %set(handles.result_suggest,'string','NULL_11'); %测试使用;
                                
                            else
                                Internal_error_flag=1;
                                result_B = {'Failed'};
                                write_region_B = char(strcat('B',num2str(temp_total+1)));
                                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                                suggestion_C = strcat({'Abbreviation name error11: '},char(matchStr(temp)));
                                write_region_C = char(strcat('C',num2str(temp_total+1)));
                                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                                break; % 结束最里面的循环   

                            end 
                        end
                        
                    end   
                end  
                if Internal_error_flag==0 %内部标志位是0,即内部无错误
                    result_B = {'Pass'};
                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                    suggestion_C = strcat({'NULL'});
                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                end
            else %表示第3部分不符要求
                result_B = {'Failed'};
                write_region_B = char(strcat('B',num2str(temp_total+1)));
                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));
                write_region_C = char(strcat('C',num2str(temp_total+1)));
                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                continue;
            end
            %% 处理第三部分和第二部分判断(:第三部分是重复判断)
            % 特殊情况判断:1X,1Y-->t; 2X,2Y,2Z-->m
            special_second_block =char(CheckDifferentBlock(2));% 特殊情况判断
     
            if(sum(strcmp(char(special_second_block(length(special_second_block)-1:end)),Extended_description_list)) >= 1)
                if special_second_block(length(special_second_block)-1)=='1'  % 特殊情况判断:1X,1Y-->t;
                    if(special_type_data~='t')
                        %报错
                        result_B = {'Failed'};
                        write_region_B = char(strcat('B',num2str(temp_total+1)));
                        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果
                         
                         
                        suggestion_C = strcat({'1X,1Y must  match t.Matching error25: '},special_type_data); 
                        write_region_C = char(strcat('C',num2str(temp_total+1)));
                        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                        continue; % 结束循环中的第n次,继续n+1次循环
                    end
                        
                elseif(special_second_block(length(special_second_block)-1)=='2') % 特殊情况判断:2X,2Y,2Z-->m
                    if(special_type_data~='m')
                        %报错
                        result_B = {'Failed'};
                        write_region_B = char(strcat('B',num2str(temp_total+1)));
                        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果
                         
                        suggestion_C = strcat({'2X,2Y,2Z must  match m.Matching error26: '},special_type_data); 
                        write_region_C = char(strcat('C',num2str(temp_total+1)));
                        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                        continue; % 结束循环中的第n次,继续n+1次循环
                    end
                else
                    %报错
                    result_B = {'Failed'};
                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果


                    suggestion_C = strcat({'the last two letter is wrong,Matching error23: '},special_second_block(length(special_second_block)-1:end)); 
                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                    continue; % 结束循环中的第n次,继续n+1次循环
                end
                %把CheckDifferentBlock(2)中最后两个元素给去掉
                special_second_block(length(special_second_block)-1:end)=[];              
            end
            if (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求
                % 处理第二部分
                Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写
                matchStr = regexp(char(special_second_block),Re_Expression,'match');
                [matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !
                
                total_split_section = {}; %用来记录一共拆分为几部分
                
                for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena 
                    if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算
                        %% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_Type
                        matchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSS
                        matchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS 

                        if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                           matchStrtest_Split_All_Capital_Type_total(end)=[];
                        end
                        if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                           matchStrtest_Split_All_Capital_Type_total(end)=[];
                        end

                        if length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段
                            length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的
                           % disp(length_3_Split_All_Capital_Type);
                            for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)
                                matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组
                                total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去
                            end 
                        else % 如果小于6就直接进行判断
                            matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断
                            total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去
                        end
                        %% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_Type
                        matchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));
                        The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S 
                        later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pd
                        if length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况
                            matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;
                        else
                            matchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spd
                        end

                        if (sum(strcmp(char(matchStrtest_Split_First_Capital_Type(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉
                           matchStrtest_Split_First_Capital_Type(end)=[];
                        end
                        total_split_section = [total_split_section , matchStrtest_Split_First_Capital_Type]; %添加进去


                    else    %只有一个大写字母 按照之前判断就可以了 比如:Spd
                        if temp==0 % 永远不会成立
                            continue;
                        else
                            judge_number = char(matchStr(temp));         
                            if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次
                                judge_number(end)=[];
                            end
                            if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数
                                judge_number(end)=[];
                            end
                            total_split_section = [total_split_section , judge_number]; %用来记录一共拆分为几部分

                        end

                    end   
                end  
                %% 后续在这里对total_split_section进行判断
                current_position=1;
                next_position = 1;
                Internal_error_flag=0;%内部标志位是0,即内部无错误
                for split_tmp=1:length(total_split_section)
                    %total_split_section(split_tmp) %测试
                    if split_tmp==1 %给定初始值,并设定两个位置游标,进行游标判断
                        if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)
                            current_position = 1;
                            next_position = 1;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)
                            current_position = 2;
                            next_position = 2;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)
                            current_position = 3;
                            next_position = 3;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)
                            current_position = 4;
                            next_position = 4;
                        else
                            Internal_error_flag=1;%内部标志位是0,即内部无错误
                            result_B ={ 'Failed'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                            suggestion_C = strcat({'Abbreviation name error39: '},total_split_section(split_tmp)); 
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                            break; % 结束最里面的循环 

                        end
                        current_position = next_position; %再次确保两者初始值相等
                    else
                           %求出下一个游标位置
                        
                        if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)
                            next_position = 1;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)
                            next_position = 2;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)
                            next_position = 3;
                        elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)
                            next_position = 4;
                        else
                            %报错,表示当前没有找到 %结束当前变量查询
                            Internal_error_flag=1;%内部标志位是0,即内部无错误
                            result_B ={ 'Failed'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                            suggestion_C = strcat({'Abbreviation name error56: '},total_split_section(split_tmp)); 
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                            break; % 结束最里面的循环  
                        end
                        %游标位置的比较
                        if next_position >= current_position
                            current_position = next_position; % 把此次游标的位置记录,方便后面比较
                        else %位置对应的顺序不符报错
                            Internal_error_flag=1;%内部标志位是0,即内部无错误
                            result_B ={ 'Failed'};
                            write_region_B = char(strcat('B',num2str(temp_total+1)));
                            xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                            suggestion_C = strcat({'The two section  sequence error36: '},total_split_section(split_tmp),' and  ',total_split_section(split_tmp-1)); 
                            write_region_C = char(strcat('C',num2str(temp_total+1)));
                            xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                            break; % 结束最里面的循环  
                        end

                    end
                if Internal_error_flag==0 %内部标志位是0,即内部无错误
                    result_B = {'Pass'};
                    write_region_B = char(strcat('B',num2str(temp_total+1)));
                    xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                    suggestion_C = strcat({'NULL'});
                    write_region_C = char(strcat('C',num2str(temp_total+1)));
                    xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                end
                end %表示第二部分的每个部分也判断结束,最后会有结论出来的
                
                

            else %表示第3部分不符要求
                
                result_B = {'Failed'};
                write_region_B = char(strcat('B',num2str(temp_total+1)));
                xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

                suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));
                write_region_C = char(strcat('C',num2str(temp_total+1)));
                xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
                continue;
            end
            
    
            
        end % 第二层判断!!


    else % 第一层判断第一个字母是否正确!!
        
        result_B = {'Failed'};
        write_region_B = char(strcat('B',num2str(temp_total+1)));
        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

        suggestion_C = {'The first capital letter corresponds to the type identifier is incorrect'}; 
        write_region_C = char(strcat('C',num2str(temp_total+1)));
        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
        continue; % 结束循环中的第n次,继续n+1次循环
    end  %第一层第一个变量判断
    % 得出结论,通过
    if Internal_error_flag==0 %内部标志位是0,即内部无错误
        result_B = {'Pass'};
        write_region_B = char(strcat('B',num2str(temp_total+1)));
        xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果

        suggestion_C = strcat({'NULL'});
        write_region_C = char(strcat('C',num2str(temp_total+1)));
        xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); 
    end
    

end
close(process_show);%关闭进度条
disp('程序运行结束.');

你可能感兴趣的:(MATLAB/Simulink,MATLAB,m脚本,自动化检查)