package com.socket;
|
|
import android.drm.DrmStore;
|
import android.webkit.JavascriptInterface;
|
import android.webkit.WebView;
|
|
import com.fgkj.action.ServiceModel;
|
import com.fgkj.dao.ActionUtil;
|
import com.fgkj.dao.DBHelper;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public class FBS9600S_DeviceService {
|
public static final int MAXCONCENTRATORCOUNT = 16; //最多连接的汇集器数量
|
public static final String JS_INTERFACE_NAME = "FBS9600S_DeviceService"; //JS调用类名
|
|
public List<BattDataThread> allBattDatt;
|
public DBHelper dbHelper;
|
public WebView webView;
|
public FBS9600S_DeviceService(WebView webView,DBHelper dbHelper){
|
this.dbHelper = dbHelper;
|
this.webView = webView;
|
allBattDatt = new ArrayList<>();
|
for(int i=0;i<MAXCONCENTRATORCOUNT;i++){
|
BattDataThread thread = new BattDataThread(i+1,this.dbHelper,webView);
|
allBattDatt.add(thread);
|
thread.start();
|
}
|
allBattDatt.get(0).isInstall = true;
|
}
|
|
//读取系统状态
|
@JavascriptInterface
|
public void readSystemState(String index){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).readSystemState("readSystemState");
|
}
|
}
|
|
//读取系统参数
|
@JavascriptInterface
|
public void readSystemParam(String index){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).readSystemParam("readSystemParam");
|
}
|
}
|
|
//设置系统参数
|
@JavascriptInterface
|
public void writeSystemParam(String index,String json){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).writeSystemParam("writeSystemParam",json);
|
}
|
}
|
|
//读取电池信息
|
@JavascriptInterface
|
public void readBattMonInfo(String index){
|
int battindex = Integer.parseInt(index);
|
ServiceModel model = new ServiceModel();
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
model.code = 1;
|
model.data = allBattDatt.get(battindex).state;
|
}
|
ActionUtil.SendCallDataToJS("readBattMonInfo",model,webView, ActionUtil.getGson());
|
}
|
|
//启动内阻测试
|
@JavascriptInterface
|
public void startBattResTest(String index){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).startBattResTest("startBattResTest");
|
}
|
}
|
|
//启动内阻测试
|
@JavascriptInterface
|
public void stopBattResTest(String index){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).stopBattResTest("stopBattResTest");
|
}
|
}
|
|
//启动内阻测试
|
@JavascriptInterface
|
public void reStartSystem(String index){
|
int battindex = Integer.parseInt(index);
|
if(battindex>0 && battindex <= MAXCONCENTRATORCOUNT){
|
allBattDatt.get(battindex).reStartSystem("reStartSystem");
|
}
|
}
|
}
|