今日需求
1、ic读卡逻辑编写
2、发卡系统验证逻辑
3、金马衡器界面设计
第一次接触ic读卡功能,虽然也不是很明白什么意思,可是会用了,记得刚干编程的时候王经理在那滴滴滴,我露出了项目的目光
贴一下代码:
仪表与刷卡器
//仪表
$.Meter={
type:"YB",
open:function(obj){
extend(obj,{operation:"open",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
close:function(obj){
extend(obj,{operation:"close",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
getdata:function(obj){
extend(obj,{operation:"getdata",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
ybclear:function(obj){
extend(obj,{operation:"ybclear",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
}
}
//刷卡器
$.ICReader={
type:'MWRF35',
open:function(obj){
$.Meter.open.call(this,obj);
},
close:function(obj){
$.Meter.close.call(this,obj);
},
remotesetid:function(obj){
extend(obj,{operation:"remotesetid",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
remoteclearsetid:function(obj){
extend(obj,{operation:"remoteclearsetid",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
getid:function(obj){
extend(obj,{operation:"do_card",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
getic:function(obj){
extend(obj,{operation:"do_read",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
setic:function(obj){
extend(obj,{operation:"do_write",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
seticloop:function(obj){
extend(obj,{operation:"seticloop",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
seticbyte:function(obj){
extend(obj,{operation:"do_write_byte",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
changepassword:function(obj){
extend(obj,{operation:"changepassword",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
loadkey:function(obj){
extend(obj,{operation:"loadkey",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
},
sendmsg:function(obj){//网络读卡器
extend(obj,{operation:"sendmsg",type:this.type});
var c1= new currency(obj);
c1.web_senddata();
} ,
setStatus:function(obj){//网络读卡器
$.JDQ.setStatus.call(this,obj);
}
}
js调用代码
function openIC(pos,showID){
device.ICReader.open({
position:pos,
callback:function(data,ws){
document.getElementById(showID).innerHTML= data;
}
});
}
function getIC(pos,showID){
device.ICReader.getid({
position:pos,
isclose:true,
count:1,
interval:1000,
data:"{docardmodel:1,convert:1}",
callback:function(data,ws){
document.getElementById(showID).innerHTML= data;
}
});
}
HTML:
<tr class="tr_odd">
<td>读卡器1:</td>
<td><input type="button" value="打开" onclick="openIC('201','IC1');"/></td>
<td>
<input type="button" value="获取卡号" onclick="getIC('201','IC1');"/>
<input type="button" value="写卡" onclick="setStr('201','IC1');"/>
<input type="button" value="读卡" onclick="getStr('201','IC1');"/>
</td>
<td>
<input id="secF" placeholder="扇区号" style="width:45px;"/>
<input id="blockF" placeholder="块号" style="width:35px;"/>
<input id="strF" placeholder="内容"/>
</td>
<td id="IC1"></td>
</tr>
每日一题
0,1,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个数字。
例如,0、1、2、3、4这5个数字组成一个圆圈,从数字0开始每次删除第3个数字,则删除的前4个数字依次是2、0、4、1,因此最后剩下的数字是3。
示例 1:
输入: n = 5, m = 3
输出: 3
自我理解
1、题目表明目的输入两个数n与m
先写输入
2、n为数字的个数,从0开始,那我们
使用一个list存进去 (为什么使用list,因为list方便删除)
ArrayList<Integer> list = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
list.add(i);
}
3、通过题目找到删除的数的规律是 (ids+m-1)%n,使用while循环n>1,如果结果只有一个,就输出出来
int idx = 0;
while (n > 1) {
idx = (idx + m - 1) % n;
System.out.println("idx:"+idx);
list.remove(idx);
System.out.println("循环:"+list.get(0));
n--;
}