MatchFinder

public class MatchFinder {
//static List<FileInfo> matchNames = new ArrayList<FileInfo>();
static List<String> nonMatchNames = new ArrayList<String>();

public static void main(String[] args) throws Exception {
List<MatchInfo> matchNames = new ArrayList<MatchInfo>();

//enumerate(new File("I:/_backup/_bad"));
//enumerate(new File("D:/_bad"));
//enumerate(new File("E:/badmintons"), matchNames);
//enumerate(new File("F:/badmintons"), matchNames);

/**/
readIndexFromFile("I:/_backup/_bad/bad.index.txt", matchNames);
/* readIndexFromFile("F:/louis/badminton-index/Home.BY.E.txt", matchNames);
readIndexFromFile("F:/louis/badminton-index/Home.Louis.E.txt", matchNames);
readIndexFromFile("F:/louis/badminton-index/Home.Louis.F.txt", matchNames);*/

//enumerate(new File("F:/_bad/badmintons"), matchNames);
Collections.sort(matchNames); //, new MatchInfoCompator()
Log.prt(matchNames);

//writeToExcel(matchNames, "c:/tmp/matches.xls");
}

static void writeToExcel(List<MatchInfo> matchNames, String fileName) {
FileOutputStream fos = null;
try {
MWorkbook workbook = new MWorkbook();

//write data
MSheet sheet = workbook.createSheet("Match");
MRow row = sheet.createRow(0);
//Create Header
String[] headers = {"Year", "Match", "Item", "Player1", "Player2", "File Name", "Absolute Path"};
for (int i = 0; i < headers.length; i++) {
MCell cell = row.createCell((short) i);
cell.setMCellValue(headers[i], true);
}

for (int i = 0; i < matchNames.size(); i ++ ) {
MatchInfo info = matchNames.get(i);
row = sheet.createRow(1 + i);

MCell cell = row.createCell((short) 0);
cell.setMCellValue(info.year);

cell = row.createCell((short) 1);
cell.setMCellValue(info.match);

cell = row.createCell((short) 2);
cell.setMCellValue(info.item);

cell = row.createCell((short) 3);
cell.setMCellValue(info.player1);

cell = row.createCell((short) 4);
cell.setMCellValue(info.player2);

cell = row.createCell((short) 5);
cell.setMCellValue(info.fileName);

cell = row.createCell((short) 6);
cell.setMCellValue(info.absolutePath);
}

//Set column to proper size
for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn((short) i);
}

//Save to file
fos = new FileOutputStream(fileName);
workbook.write(fos);
}
catch (FileNotFoundException e1) {
Log.error(e1);
}
catch (IOException e2) {
Log.error(e2);
}
finally {
if (fos != null)
try {
fos.close();
}
catch (IOException e) {
Log.error(e);
}
}
}

public static void enumerate(File directory, List<MatchInfo> matchNames) throws Exception {
File[] files = directory.listFiles();
for (File file : files) {
if (file.isDirectory())
enumerate(file, matchNames);
else
search(file, matchNames);
}
}

static void search(File file, List<MatchInfo> matchNames) throws IOException {
String fileName = file.getName();
if (!isValidMatchFile(fileName)) {
//Log.prt("*** " + fileName);
nonMatchNames.add(fileName);
return;
}

int itemIndex = itemIndex(fileName);
int vsIndex = vsIndex(fileName);

//itemIndex should >=6, vsIndex should >=11, eg. 1999 X MS A VS B.avi
if (itemIndex < 6 || vsIndex < 11)
Log.prt("*** " + file.getAbsolutePath());
else {
//String matchName = getMatchName(fileName);
matchNames.add(new MatchInfo(file.getAbsolutePath(), fileName));
}
}

/** Valid match file name: (2001) China (MS) Alice (VS) Bob(.)rmvb */
static boolean isValidMatchFile(String fileName) {
if (fileName.endsWith(".txt"))
return false;
try {
//If is a full file Name that contains path
if (fileName.contains("\\")) {
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
}

String year = fileName.substring(0, 4);
Integer.parseInt(year);
} catch (Exception e) {
//Log.prt("*** " + fileName);
return false;
}

return true;
}

static void readIndexFromFile(String indexFileName, List<MatchInfo> matchNames) throws FileNotFoundException {
File file = new File(indexFileName);
Scanner in = new Scanner(new FileInputStream(file));
//int lineNumber = 0;
while (in.hasNextLine()) {
//lineNumber++;
String absolutePath = in.nextLine();

if (!isValidMatchFile(absolutePath)) {
//Log.prt("*** " + absolutePath);
continue;
}

//If is a full file Name that contains path
String fileName = absolutePath;
if (absolutePath.contains("\\")) {
fileName = absolutePath.substring(absolutePath.lastIndexOf("\\") + 1);
}

int itemIndex = itemIndex(fileName);
int vsIndex = vsIndex(fileName);
//itemIndex should >=6, vsIndex should >=11, eg. 1999 X MS A VS B.avi
if (itemIndex < 6 || vsIndex < 11)
Log.prt("*** " + file.getAbsolutePath());
else {
MatchInfo matchInfo = new MatchInfo(absolutePath, fileName);
getMatchInfo(matchInfo);
matchNames.add(matchInfo);
}
}
in.close();
}

public static void getMatchInfo(MatchInfo matchInfo) {
//String s = "1997 All England MD Kang kyun-Ha tae Kwon VS Michael Sogaard-Jon holst.flv";
String fileName = matchInfo.fileName;

//1) Year
String year = fileName.substring(0, 4), match = "*", item = "*";
matchInfo.year = year;

//2) Match
int index = itemIndex(fileName);
if (index > -1) {
match = fileName.substring(5, index).trim();
matchInfo.match = match;
}

//3) Item
if (index > -1) {
item = fileName.substring(index + 1, index + 3);
matchInfo.item = item;
}

//4) Players
int vsIndex = vsIndex(fileName);
try {
if (vsIndex > -1) {
matchInfo.player1 = fileName.substring(index + 4, vsIndex).trim();

int lastPoint = fileName.lastIndexOf(".");
if (lastPoint > 0)
matchInfo.player2 = fileName.substring(vsIndex + 4, lastPoint);
}
} catch (Exception e) {
Log.error(e);
Log.prt(fileName);
}

//Log.prt("%s, %s, %s, %s, VS, %s\n", year, match, item, a, b);
//String ss = String.format("%s, %s, %s, %s, VS, %s", year, match, item, a, b);
}

public static int vsIndex(String source) {
source = source.toUpperCase();
int index = source.indexOf(" VS ");
return index;
}

public static int itemIndex(String source) {
source = source.toUpperCase();
int index = source.indexOf(" MS ");
if (index < 0)
index = source.indexOf(" WS ");
if (index < 0)
index = source.indexOf(" MD ");
if (index < 0)
index = source.indexOf(" WD ");
if (index < 0)
index = source.indexOf(" XD ");
return index;
}
}


public class MatchInfo implements Comparable<MatchInfo> {
public String absolutePath;
public String fileName;
public boolean isMatch = true;

public String year;
public String match;
public String item;
public String player1;
public String player2;
public String description;

public MatchInfo(String absolutePath, String fileName) {
super();
this.absolutePath = absolutePath;
this.fileName = fileName;
}

public MatchInfo(String absolutePath, String fileName, boolean isMatch) {
super();
this.absolutePath = absolutePath;
this.fileName = fileName;
this.isMatch = isMatch;
}

public MatchInfo(String absolutePath, String fileName, boolean isMatch, String year, String match, String item, String player1,
String player2, String description) {
super();
this.absolutePath = absolutePath;
this.fileName = fileName;
this.isMatch = isMatch;
this.year = year;
this.match = match;
this.item = item;
this.player1 = player1;
this.player2 = player2;
this.description = description;
}

@Override
public String toString() {
return fileName;
}

@Override
public int compareTo(MatchInfo o) {
return this.fileName.compareTo(o.fileName);
}
}


public class MatchInfoCompator implements Comparator<MatchInfo> {

@Override
public int compare(MatchInfo o1, MatchInfo o2) {
int x = BaseUtils.compareTo(o1.year, o2.year);
if (x == 0)
x = BaseUtils.compareTo(o1.match, o2.match);
if (x == 0)
x = BaseUtils.compareTo(o1.item, o2.item);
if (x == 0)
x = BaseUtils.compareTo(o1.player1, o2.player1);
if (x == 0)
x = BaseUtils.compareTo(o1.player2, o2.player2);

return x;
}
}
内容概要:本文档详细介绍了Analog Devices公司生产的AD8436真均方根-直流(RMS-to-DC)转换器的技术细节及其应用场景。AD8436由三个独立模块构成:轨到轨FET输入放大器、高动态范围均方根计算内核和精密轨到轨输出放大器。该器件不仅体积小巧、功耗低,而且具有广泛的输入电压范围和快速响应特性。文档涵盖了AD8436的工作原理、配置选项、外部组件选择(如电容)、增益调节、单电源供电、电流互感器配置、接地故障检测、三相电源监测等方面的内容。此外,还特别强调了PCB设计注意事项和误差源分析,旨在帮助工程师更好地理解和应用这款高性能的RMS-DC转换器。 适合人群:从事模拟电路设计的专业工程师和技术人员,尤其是那些需要精确测量交流电信号均方根值的应用开发者。 使用场景及目标:①用于工业自动化、医疗设备、电力监控等领域,实现对交流电压或电流的精准测量;②适用于手持式数字万用表及其他便携式仪器仪表,提供高效的单电源解决方案;③在电流互感器配置中,用于检测微小的电流变化,保障电气安全;④应用于三相电力系统监控,优化建立时间和转换精度。 其他说明:为了确保最佳性能,文档推荐使用高质量的电容器件,并给出了详细的PCB布局指导。同时提醒用户关注电介质吸收和泄漏电流等因素对测量准确性的影响。
内容概要:本文档介绍了一种基于ADP5070 DC-DC开关稳压器、ADP7142和ADP7182 CMOS LDO线性稳压器、LC滤波器及电阻分压器的电路设计方案,旨在为仅拥有5 V单电源的系统提供低噪声、双电源解决方案,以支持AD5761R双极性DAC的工作。AD5761R是一款16位双极性DAC,需要双电源来提供双极性输出电压范围。文中详细描述了如何配置该电路以适应单电源系统的应用,并展示了不同电源配置(包括外部电源、ADP5070和LC滤波器、ADP5070和LDO线性稳压器)下的性能测试结果,特别是频谱分析、输出电压噪声和交流性能等方面的数据。测试结果表明,增加LDO线性稳压器可以显著降低输出噪声,提升整体性能。 适合人群:从事精密仪器设计、数据采集系统开发的技术人员,尤其是那些需要理解和应用低噪声电源解决方案的专业人士。 使用场景及目标:适用于需要从单一5 V电源生成双电源的应用场合,如测试与测量设备、数据采集系统、执行器控制系统和工业自动化等领域。主要目标是在保证低噪声的前提下,确保AD5761R DAC能够在单电源环境中正常工作,提供高质量的双极性输出。 其他说明:本文档不仅提供了详细的电路配置指南,还通过大量的图表和数据分析验证了不同电源配置的效果。特别强调了在不同频率范围内,使用内部基准电压源和外部基准电压源(如ADR4525)对DAC输出噪声的影响。此外,文档还讨论了LC滤波器和LDO线性稳压器在减少开关纹波方面的作用,为实际应用提供了有价值的参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值