4.电池功耗测试
测试目的:获取移动终端使用电池供电时各功能模块在不同使用频度下的使用次数和时间,计算其工作或待机状态下的功耗,为在此平台环境下开发应用程序的可行性提供分析依据。
测试代码:
private void Form1_Load(object sender, EventArgs e)
{
//初始化RFID读头
int portNo = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ComParam\\", "RFIDConfig", 0);
CRFID.GPB_OUTH(portNo);
CRFID.ZLG522Init((byte)portNo);
//连接条码扫描设备并加电
CommonApi.KDT_Scan_PowerOn();
CommonApi.KDT_Scan_ConnectEx();
//打开网线网络
CommonApi.KDT_Wifi_On();
}
private void button1_Click(object sender, EventArgs e)
{
this.button1.Enabled = false;
int time = Environment.TickCount;
//利用Timer模拟各功能模块的使用频率
if (false == this.timer1.Enabled)
{
timer1.Enabled = true;
if (this.checkBox1.Checked)
{
this.timer1.Interval = 60 * 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
}
}
if (false == this.timer2.Enabled)
{
timer2.Enabled = true;
this.timer2.Interval = int.Parse(textBox2.Text) * 1000;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
}
if (false == this.timer3.Enabled)
{
timer3.Enabled = true;
if (!"".Equals(st3))
{
this.timer3.Interval = int.Parse(textBox3.Text) * 1000;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
}
}
if (false == this.timer4.Enabled)
{
timer4.Enabled = true;
if (!"".Equals(st4))
{
this.timer4.Interval = int.Parse(textBox4.Text) * 1000;
this.timer4.Tick += new System.EventHandler(this.timer4_Tick);
}
}
if (false == this.timer5.Enabled)
{
timer5.Enabled = true;
if (!"".Equals(st5))
{
this.timer5.Interval = int.Parse(textBox5.Text) * 1000;
this.timer5.Tick += new System.EventHandler(this.timer5_Tick);
}
}
//设置各Timer任务
private void timer1_Tick(object sender, EventArgs e)
{
CommonApi.KDT_Open_BackLight(1);
}
private void timer2_Tick( object sender, EventArgs e)
{
CommonApi.KDT_Beep(int.Parse(textBox1.Text));
}
private void timer3_Tick(object sender, EventArgs e)
{
this.ReadRfid();
}
private void timer4_Tick(object sender, EventArgs e)
{
this.ScanBarCode();
}
private void timer5_Tick(object sender, EventArgs e)
{
this.getContent();
}
}