@@ -375,6 +375,22 @@ public class QueryDB { | |||
return Delete(BPA_SILOSANDMATERIAL.class, data.id); | |||
} | |||
/** | |||
* 删除料仓物料关联:根据料仓id 删除料仓与物料关联 | |||
* add fengyoufu 20230413 | |||
* @return 是否成功 | |||
*/ | |||
public static boolean DeleteSilosAndMaterial(String id) { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and silosID=?"; | |||
String[] args = new String[]{"0", id}; | |||
ArrayList<String> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_SILOSANDMATERIAL.class, where, args, orderby); | |||
for (Object k : obj) { | |||
Delete(BPA_SILOSANDMATERIAL.class, ((BPA_SILOSANDMATERIAL) k).id); | |||
} | |||
return true; | |||
} | |||
/** | |||
* 获取所有料仓物料关联 | |||
* | |||
@@ -28,95 +28,26 @@ public class FlashHelper { | |||
public static FlashHelper getInstance() { | |||
return FlashHelper.Holder.instance; | |||
} | |||
public List<Integer> listviews = new ArrayList<Integer>(); | |||
public List<Integer> listviews1 = new ArrayList<Integer>(); | |||
public List<View> listview = new ArrayList<View>(); | |||
public List<View> listview1 = new ArrayList<View>(); | |||
/**开启View闪烁效果**/ | |||
public void startFlick( View view ,Integer key) { | |||
if (null == view) { | |||
return; | |||
} | |||
if(!listviews.contains(key)) | |||
{ | |||
view.setVisibility(View.VISIBLE); | |||
Animation alphaAnimation = new AlphaAnimation(1, 0); | |||
alphaAnimation.setDuration(300); | |||
alphaAnimation.setInterpolator(new LinearInterpolator()); | |||
alphaAnimation.setRepeatCount(Animation.INFINITE); | |||
alphaAnimation.setRepeatMode(Animation.REVERSE); | |||
view.startAnimation(alphaAnimation); | |||
listviews.add(key); | |||
listview.add(view); | |||
} | |||
} | |||
/**取消View闪烁效果**/ | |||
public void stopFlick( View view ,Integer key ) { | |||
if (null == view) { | |||
return; | |||
} | |||
if(listviews.contains(key)) | |||
{ | |||
view.setVisibility(View.GONE); | |||
view.clearAnimation(); | |||
listviews.remove(key); | |||
listview.remove(view); | |||
} | |||
} | |||
/**开启View闪烁效果**/ | |||
public void startFlick1( View view ,Integer key) { | |||
public void startFlick( View view) { | |||
if (null == view) { | |||
return; | |||
} | |||
if(!listviews1.contains(key)) | |||
{ | |||
view.setVisibility(View.VISIBLE); | |||
Animation alphaAnimation = new AlphaAnimation(1, 0); | |||
alphaAnimation.setDuration(300); | |||
alphaAnimation.setInterpolator(new LinearInterpolator()); | |||
alphaAnimation.setRepeatCount(Animation.INFINITE); | |||
alphaAnimation.setRepeatMode(Animation.REVERSE); | |||
view.startAnimation(alphaAnimation); | |||
listviews1.add(key); | |||
listview1.add(view); | |||
} | |||
Animation alphaAnimation = new AlphaAnimation(1, 0); | |||
alphaAnimation.setDuration(300); | |||
alphaAnimation.setInterpolator(new LinearInterpolator()); | |||
alphaAnimation.setRepeatCount(Animation.INFINITE); | |||
alphaAnimation.setRepeatMode(Animation.REVERSE); | |||
view.startAnimation(alphaAnimation); | |||
} | |||
/**取消View闪烁效果**/ | |||
public void stopFlick1( View view ,Integer key ) { | |||
public void stopFlick( View view) { | |||
if (null == view) { | |||
return; | |||
} | |||
if(listviews1.contains(key)) | |||
{ | |||
view.setVisibility(View.GONE); | |||
view.clearAnimation(); | |||
listviews1.remove(key); | |||
listview1.remove(view); | |||
} | |||
} | |||
public void Close() | |||
{ | |||
listviews1.clear(); | |||
listviews.clear(); | |||
for (View item: listview1) | |||
{ | |||
item.clearAnimation(); | |||
} | |||
for (View item: listview) | |||
{ | |||
item.clearAnimation(); | |||
} | |||
view.clearAnimation(); | |||
} | |||
} |
@@ -17,6 +17,7 @@ import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.example.bpa.R; | |||
import com.example.bpa.helper.FlashHelper; | |||
import com.example.bpa.view.control.MainMeunAdapter; | |||
import com.example.bpa.view.inteface.MyClickListener; | |||
import com.example.bpa.view.mode.MenuMode; | |||
@@ -102,7 +103,30 @@ public class lc_item_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolde | |||
silosmargin = (TextView) view.findViewById(R.id.lc_item_silosmargin); | |||
image_yj = (RelativeLayout) view.findViewById(R.id.image_yj); | |||
image_gj = (RelativeLayout) view.findViewById(R.id.image_gj); | |||
FlashHelper.getInstance().startFlick(image_yj); | |||
FlashHelper.getInstance().startFlick(image_gj); | |||
} | |||
public int getNum() | |||
{ | |||
try { | |||
return Integer.parseInt(num.getText().toString()); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
public void startFlick() | |||
{ | |||
FlashHelper.getInstance().startFlick(image_yj); | |||
FlashHelper.getInstance().startFlick(image_gj); | |||
} | |||
public void stopFlick() | |||
{ | |||
FlashHelper.getInstance().stopFlick(image_yj); | |||
FlashHelper.getInstance().stopFlick(image_gj); | |||
} | |||
} | |||
} |
@@ -59,11 +59,12 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
//materiallist父控件 | |||
View material_parent; | |||
//物料列表 | |||
ArrayList<BPA_MATERIAL> bpa_materials=new ArrayList<>(); | |||
ArrayList<BPA_MATERIAL> bpa_materials = new ArrayList<>(); | |||
//当前选中的料仓id | |||
lc_item_adapter.MyLCViewHolder currentSilo; | |||
//当前料仓集合 | |||
List<lcMode> datas = new ArrayList<lcMode>(); | |||
//region 私有函数 | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
@@ -76,7 +77,6 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
@Override | |||
protected void onDestroy() { | |||
FlashHelper.getInstance().Close(); | |||
super.onDestroy(); | |||
} | |||
@@ -96,7 +96,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
//横向排列 | |||
recyclerView = this.findViewById(R.id.lc_view); | |||
materiallist = this.findViewById(R.id.materials); | |||
material_parent =(View) materiallist.getParent(); | |||
material_parent = (View) materiallist.getParent(); | |||
try { | |||
//加载 recyclercview数据 | |||
MyLayoutManager layout = new MyLayoutManager(); | |||
@@ -104,10 +104,10 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
layout.setAutoMeasureEnabled(true); | |||
recyclerView.setLayoutManager(layout); | |||
//获取料仓数据 | |||
ArrayList<BPA_SILOS> bpa_silos =QueryDB.GetSilosALL(); | |||
ArrayList<BPA_SILOS> bpa_silos = QueryDB.GetSilosALL(); | |||
//加载materials数据 | |||
if(bpa_silos.size()>0){ | |||
for (BPA_SILOS silo : bpa_silos){ | |||
if (bpa_silos.size() > 0) { | |||
for (BPA_SILOS silo : bpa_silos) { | |||
// String resmaterialid = QueryDB.GetMaterialList(silo.id).size()==0? "-1" : QueryDB.GetMaterialList(silo.id).get(0); | |||
// String material_name = "未设置"; | |||
// String material_id = ""; | |||
@@ -120,10 +120,10 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
// | |||
// } | |||
List<BPA_MATERIAL> m = QueryDB.GetMaterialBySilosID(silo.id); | |||
if(m.size()>0) { | |||
datas.add(new lcMode(silo.id, silo.num, m.get(0).name, "0", m.get(0).id,silo.warningValue,silo.thrsoleValue)); | |||
}else { | |||
datas.add(new lcMode(silo.id, silo.num, "未设置", "0", "",silo.warningValue,silo.thrsoleValue)); | |||
if (m.size() > 0) { | |||
datas.add(new lcMode(silo.id, silo.num, m.get(0).name, "0", m.get(0).id, silo.warningValue, silo.thrsoleValue)); | |||
} else { | |||
datas.add(new lcMode(silo.id, silo.num, "未设置", "0", "", silo.warningValue, silo.thrsoleValue)); | |||
} | |||
} | |||
@@ -133,7 +133,12 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
recyclerView.setAdapter(adapter); | |||
//加载listview 数据 | |||
bpa_materials= QueryDB.GetMaterialALL(); | |||
bpa_materials = QueryDB.GetMaterialALL(); | |||
BPA_MATERIAL wsz=new BPA_MATERIAL(); | |||
wsz.name="未设置"; | |||
wsz.id=""; | |||
bpa_materials.add(wsz); | |||
selectitem_adapter selectadapter = new selectitem_adapter(lcsz_activity.this, R.layout.selectitem_item, bpa_materials); | |||
materiallist.setAdapter(selectadapter); | |||
@@ -171,30 +176,29 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
@Override | |||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||
ArrayAdapter viewHolder = (ArrayAdapter)materiallist.getAdapter(); | |||
if (viewHolder instanceof selectitem_adapter){ | |||
ArrayAdapter viewHolder = (ArrayAdapter) materiallist.getAdapter(); | |||
if (viewHolder instanceof selectitem_adapter) { | |||
material_parent.setVisibility(View.GONE);//隐藏父控件 | |||
if (currentSilo!=null){ | |||
BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); | |||
if (currentSilo != null) { | |||
BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); | |||
BPA_MATERIAL material= ((selectitem_adapter) viewHolder).getItem(position); | |||
item.silosID = currentSilo.id; | |||
item.materialID = ((selectitem_adapter)viewHolder).getItem(position).id;; | |||
item.materialID = material.id; | |||
//更新 | |||
if(QueryDB.UpdateSilosAndMaterial(item)){ | |||
currentSilo.materialName.setText(((selectitem_adapter)viewHolder).getItem(position).name); | |||
T.show(lcsz_activity.this,"更新成功"); | |||
datas.get(position).materialId= item.materialID; | |||
datas.get(position).materialName= ((selectitem_adapter)viewHolder).getItem(position).name; | |||
} | |||
if (QueryDB.UpdateSilosAndMaterial(item)) { | |||
currentSilo.materialName.setText(material.name); | |||
T.show(lcsz_activity.this, "更新成功"); | |||
datas.get(currentSilo.getNum()-1).materialId = item.materialID; | |||
datas.get(currentSilo.getNum()-1).materialName =material.name; | |||
currentSilo.startFlick(); | |||
} | |||
} | |||
} | |||
} | |||
}); | |||
//region materials父控件点击事件 | |||
material_parent.setOnClickListener(new View.OnClickListener(){ | |||
material_parent.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View v) { | |||
material_parent.setVisibility(View.GONE);//隐藏materiallist | |||
@@ -206,6 +210,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
/** | |||
* 页面点击事件 | |||
* | |||
* @param v | |||
*/ | |||
@Override | |||
@@ -224,8 +229,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
/** | |||
* 实时显示线程 | |||
*/ | |||
public void Run() | |||
{ | |||
public void Run() { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
@@ -235,40 +239,42 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
@Override | |||
public void run() { | |||
for (int i=0;i<datas.size();i++) | |||
{ | |||
int num=datas.get(i).num; | |||
float val= DeviceData.Get().getCallCurrentWeight(num); | |||
for (int i = 0; i < datas.size(); i++) { | |||
int num = datas.get(i).num; | |||
float val = DeviceData.Get().getCallCurrentWeight(num); | |||
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i); | |||
if(viewHolder!=null) | |||
{ | |||
if (viewHolder != null) { | |||
lc_item_adapter.MyLCViewHolder hold = (lc_item_adapter.MyLCViewHolder) viewHolder; | |||
//hold.silosmargin.setText(new java.text.DecimalFormat("#.00").format(val)+"g"); | |||
hold.silosmargin.setText(val+"g"); | |||
hold.silosmargin.setText(val + "g"); | |||
if(!datas.get(i).materialId.isEmpty()) | |||
{ | |||
if(val<datas.get(i).warningValue)//补料 | |||
{ | |||
FlashHelper.getInstance().startFlick1(hold.image_yj,num); | |||
}else | |||
if (!datas.get(i).materialId.isEmpty()) { | |||
if (val < datas.get(i).warningValue)//补料 | |||
{ | |||
FlashHelper.getInstance().stopFlick1(hold.image_yj,num); | |||
hold.image_yj.setVisibility(View.VISIBLE); | |||
} else { | |||
hold.image_yj.setVisibility(View.GONE); | |||
FlashHelper.getInstance().stopFlick(hold.image_yj); | |||
} | |||
if(val<datas.get(i).thrsoleValue)//告警 | |||
if (val < datas.get(i).thrsoleValue)//告警 | |||
{ | |||
FlashHelper.getInstance().startFlick(hold.image_gj,num); | |||
}else | |||
{ | |||
FlashHelper.getInstance().stopFlick(hold.image_gj,num); | |||
hold.image_gj.setVisibility(View.VISIBLE); | |||
} else { | |||
hold.image_gj.setVisibility(View.GONE); | |||
FlashHelper.getInstance().stopFlick(hold.image_gj); | |||
} | |||
}else | |||
{ | |||
hold.image_yj.setVisibility(View.GONE); | |||
hold.image_gj.setVisibility(View.GONE); | |||
hold.stopFlick(); | |||
} | |||
} | |||
} | |||
} | |||
}); | |||
Thread.sleep(100); | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
throw new RuntimeException(e); | |||
} | |||
@@ -24,10 +24,12 @@ import com.example.bpa.helper.T; | |||
import com.example.bpa.view.adapter.lsjy_adapter; | |||
import com.example.bpa.view.adapter.wl_adapter; | |||
import com.example.bpa.view.inteface.MyClickListener; | |||
import com.example.bpa.view.mode.ResGoodsRecipe; | |||
import com.example.bpa.view.mode.ResSilosMode; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
/** | |||
@@ -43,36 +45,18 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
* 标题设置 | |||
*/ | |||
TextView gongneng_title; | |||
// LinearLayout mylayout; | |||
//通道校准值 | |||
EditText passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9,passwayText_10; | |||
EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10; | |||
//校准基准时间 | |||
EditText timeText; | |||
List<EditText> editTextLists = new ArrayList<EditText>(); | |||
List<EditText> editTextLists = new ArrayList<EditText>(); | |||
//通道校准开关 | |||
Switch Switch_1,Switch_2,Switch_3,Switch_4,Switch_5,Switch_6,Switch_7,Switch_8,Switch_9,Switch_10; | |||
Switch Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10; | |||
List<Switch> switchLists = new ArrayList<Switch>(); | |||
//开始校准 | |||
Button StartButton; | |||
//保存 | |||
Button SaveButton; | |||
/** | |||
* 表格显示 | |||
*/ | |||
// ListView datatab; | |||
/** | |||
* 料仓数据 | |||
*/ | |||
// ArrayList<ResSilosMode> resSilosModes=new ArrayList<>(); | |||
//endregion | |||
//region 私有函数 | |||
@@ -91,18 +75,13 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
/** | |||
* 初始化 | |||
*/ | |||
private void Init(){ | |||
private void Init() { | |||
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui); | |||
gongneng_title = this.findViewById(R.id.gongneng_title); | |||
// datatab= this.findViewById(R.id.datatab); | |||
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 | |||
String msg=getIntent().getStringExtra("data"); | |||
String msg = getIntent().getStringExtra("data"); | |||
gongneng_title.setText(msg); | |||
// mylayout = findViewById(R.id.lcparameter_layout); | |||
// mylayout.setBackgroundColor(Color.TRANSPARENT); | |||
//校准数值 | |||
passwayText_1 = findViewById(R.id.passwayText_1); | |||
passwayText_2 = findViewById(R.id.passwayText_2); | |||
passwayText_3 = findViewById(R.id.passwayText_3); | |||
@@ -113,7 +92,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
passwayText_8 = findViewById(R.id.passwayText_8); | |||
passwayText_9 = findViewById(R.id.passwayText_9); | |||
passwayText_10 = findViewById(R.id.passwayText_10); | |||
editTextLists = Arrays.asList(passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9,passwayText_10); | |||
editTextLists = Arrays.asList(passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10); | |||
//校准开关 | |||
Switch_1 = findViewById(R.id.Switch_1); | |||
@@ -126,13 +105,12 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
Switch_8 = findViewById(R.id.Switch_8); | |||
Switch_9 = findViewById(R.id.Switch_9); | |||
Switch_10 = findViewById(R.id.Switch_10); | |||
switchLists = Arrays.asList(Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10); | |||
//校准按钮 | |||
StartButton = findViewById(R.id.StartButton); | |||
timeText = findViewById(R.id.edi_time); | |||
SaveButton = findViewById(R.id.savetime); | |||
} | |||
/** | |||
@@ -140,104 +118,144 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
*/ | |||
private void initEvents() { | |||
gongneng_fanhui.setOnClickListener(this); | |||
StartButton.setOnClickListener(this); | |||
SaveButton.setOnClickListener(this); | |||
//switch | |||
Switch_1.setOnCheckedChangeListener(this); | |||
Switch_2.setOnCheckedChangeListener(this); | |||
Switch_3.setOnCheckedChangeListener(this); | |||
Switch_4.setOnCheckedChangeListener(this); | |||
Switch_5.setOnCheckedChangeListener(this); | |||
Switch_6.setOnCheckedChangeListener(this); | |||
Switch_7.setOnCheckedChangeListener(this); | |||
Switch_8.setOnCheckedChangeListener(this); | |||
Switch_9.setOnCheckedChangeListener(this); | |||
Switch_10.setOnCheckedChangeListener(this); | |||
StartButton.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View v) { | |||
DeviceData.Get().setChStartCalibration(new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
T.show(lsjy_activity.this,"通道开始校准"); | |||
} | |||
// Switch_1.setOnCheckedChangeListener(this); | |||
// Switch_2.setOnCheckedChangeListener(this); | |||
// Switch_3.setOnCheckedChangeListener(this); | |||
// Switch_4.setOnCheckedChangeListener(this); | |||
// Switch_5.setOnCheckedChangeListener(this); | |||
// Switch_6.setOnCheckedChangeListener(this); | |||
// Switch_7.setOnCheckedChangeListener(this); | |||
// Switch_8.setOnCheckedChangeListener(this); | |||
// Switch_9.setOnCheckedChangeListener(this); | |||
// Switch_10.setOnCheckedChangeListener(this); | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
T.show(lsjy_activity.this,"通道开始校准失败"); | |||
} | |||
}); | |||
/** | |||
* 初始化数据加载 | |||
*/ | |||
public void Initdata() { | |||
//初始化标准值数据 | |||
try { | |||
for (int i = 0; i < 10; i++) { | |||
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); | |||
editTextLists.get(i).setText(s); | |||
} | |||
}); | |||
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime()); | |||
//校准时间 | |||
timeText.setText(time); | |||
} catch (Exception e) { | |||
} | |||
} | |||
//endregion | |||
SaveButton.setOnClickListener(new View.OnClickListener(){ | |||
@Override | |||
public void onClick(View v) { | |||
//region 点击事件 | |||
/** | |||
* 本页面点击事件监听 | |||
* | |||
* @param v | |||
*/ | |||
@Override | |||
public void onClick(View v) { | |||
switch (v.getId()) { | |||
case R.id.gongneng_fanhui://返回按钮 | |||
this.finish(); | |||
break; | |||
case R.id.savetime://校准基准时间保存 | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
String stime = timeText.getText().toString(); | |||
if(stime.equals("")){return;} | |||
if (stime.equals("")) { | |||
T.show(lsjy_activity.this, "校准基准时间不能为空!"); | |||
return; | |||
} | |||
Float ftime = Float.parseFloat(stime); | |||
DeviceData.Get().setCalibrationReferenceTime(ftime,new IWriteCallBack() { | |||
DeviceData.Get().setCalibrationReferenceTime(ftime, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
T.show(lsjy_activity.this,"校准时间写入成功"); | |||
T.show(lsjy_activity.this, "校准时间写入成功"); | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
T.show(lsjy_activity.this,"校准时间写入失败"); | |||
T.show(lsjy_activity.this, "校准时间写入失败"); | |||
} | |||
}); | |||
}catch (ArithmeticException e) { | |||
} catch (ArithmeticException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
}); | |||
break; | |||
case R.id.StartButton://开始校准 | |||
//检验数据正确性 | |||
for (int i = 0; i < 10; i++) { | |||
if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准 | |||
{ | |||
String value = editTextLists.get(i).getText().toString(); | |||
Short val = 0; | |||
try { | |||
val = Short.parseShort(value); | |||
} catch (Exception e) { | |||
} | |||
if (val <= 0) { | |||
T.show(lsjy_activity.this, "请检查[通道" + (i + 1) + "]数值不能小于0"); | |||
return; | |||
} | |||
} | |||
} | |||
//写开关状态 数值 | |||
for (int i = 0; i < 10; i++) { | |||
//1.写入开关状态 | |||
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
} | |||
}); | |||
//2.校准开关打开后,允许校准 | |||
if (switchLists.get(i).isChecked() == true) { | |||
String value = editTextLists.get(i).getText().toString(); | |||
Short val = 0; | |||
try { | |||
val = Short.parseShort(value); | |||
} catch (Exception e) { | |||
} | |||
} | |||
}); | |||
} | |||
/** | |||
* 初始化数据加载 | |||
*/ | |||
public void Initdata() | |||
{ | |||
//初始化标准值数据 | |||
try{ | |||
for (int i = 0; i <10;i++){ | |||
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i+1)); | |||
editTextLists.get(i).setText(s); | |||
} | |||
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime()); | |||
//校准时间 | |||
timeText.setText(time); | |||
}catch(Exception e){ | |||
} | |||
} | |||
//endregion | |||
DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
} | |||
//region 点击事件 | |||
/** | |||
* 本页面点击事件监听 | |||
* | |||
* @param v | |||
*/ | |||
@Override | |||
public void onClick(View v) { | |||
switch (v.getId()) { | |||
case R.id.gongneng_fanhui://返回按钮 | |||
this.finish(); | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
} | |||
}); | |||
} | |||
} | |||
//写开始校准 | |||
DeviceData.Get().setChStartCalibration(new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
T.show(lsjy_activity.this, "通道开始校准"); | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
T.show(lsjy_activity.this, "通道开始校准失败"); | |||
} | |||
}); | |||
break; | |||
} | |||
} | |||
int k=404; | |||
/** | |||
* 本页面switch点击事件监听 | |||
* | |||
@@ -245,52 +263,54 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
*/ | |||
@Override | |||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||
switch (buttonView.getId()){ | |||
case R.id.Switch_1: | |||
SwitchClick(1,isChecked); | |||
break; | |||
case R.id.Switch_2: | |||
SwitchClick(2,isChecked); | |||
break; | |||
case R.id.Switch_3: | |||
SwitchClick(3,isChecked); | |||
break; | |||
case R.id.Switch_4: | |||
SwitchClick(4,isChecked); | |||
break; | |||
case R.id.Switch_5: | |||
SwitchClick(5,isChecked); | |||
break; | |||
case R.id.Switch_6: | |||
SwitchClick(6,isChecked); | |||
break; | |||
case R.id.Switch_7: | |||
SwitchClick(7,isChecked); | |||
break; | |||
case R.id.Switch_8: | |||
SwitchClick(8,isChecked); | |||
break; | |||
case R.id.Switch_9: | |||
SwitchClick(9,isChecked); | |||
break; | |||
case R.id.Switch_10: | |||
SwitchClick(10,isChecked); | |||
break; | |||
} | |||
// switch (buttonView.getId()) { | |||
// case R.id.Switch_1: | |||
// SwitchClick(1, isChecked); | |||
// break; | |||
// case R.id.Switch_2: | |||
// SwitchClick(2, isChecked); | |||
// break; | |||
// case R.id.Switch_3: | |||
// SwitchClick(3, isChecked); | |||
// break; | |||
// case R.id.Switch_4: | |||
// SwitchClick(4, isChecked); | |||
// break; | |||
// case R.id.Switch_5: | |||
// SwitchClick(5, isChecked); | |||
// break; | |||
// case R.id.Switch_6: | |||
// SwitchClick(6, isChecked); | |||
// break; | |||
// case R.id.Switch_7: | |||
// SwitchClick(7, isChecked); | |||
// break; | |||
// case R.id.Switch_8: | |||
// SwitchClick(8, isChecked); | |||
// break; | |||
// case R.id.Switch_9: | |||
// SwitchClick(9, isChecked); | |||
// break; | |||
// case R.id.Switch_10: | |||
// SwitchClick(10, isChecked); | |||
// break; | |||
// } | |||
} | |||
//switch切换 | |||
private void SwitchClick(int index, boolean isChecked){ | |||
/** | |||
* switch切换 | |||
* | |||
* @param index | |||
* @param isChecked | |||
*/ | |||
private void SwitchClick(int index, boolean isChecked) { | |||
StringBuffer sb = new StringBuffer("PLC写入:"); | |||
new Thread (new Runnable() { | |||
new Thread(new Runnable() { | |||
public void run() { | |||
if (isChecked){ //校准开关开启状态才会写入值 | |||
String value = editTextLists.get(index-1).getText().toString(); | |||
DeviceData.Get().setCalibrationValue(Short.parseShort(value),index, new IWriteCallBack() { | |||
if (isChecked) { //校准开关开启状态才会写入值 | |||
String value = editTextLists.get(index - 1).getText().toString(); | |||
DeviceData.Get().setCalibrationValue(Short.parseShort(value), index, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
sb.append("通道"); | |||
@@ -312,7 +332,6 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
sb.append("通道"); | |||
sb.append(index); | |||
sb.append("校准开关成功;"); | |||
} | |||
@Override | |||
@@ -320,31 +339,11 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||
sb.append("通道"); | |||
sb.append(index); | |||
sb.append("校准开关失败;"); | |||
} | |||
}); | |||
} | |||
}); | |||
T.show(lsjy_activity.this, sb.toString()); | |||
} | |||
/** | |||
* 接口方法,响应ListView按钮点击事件 | |||
*/ | |||
// @Override | |||
// public void clickListener(View v,Object data) { | |||
// switch (v.getId()) | |||
// { | |||
// case R.id.button_item://校验 | |||
// k=k+1; | |||
// T.show(this,((ResSilosMode)data).id); | |||
// QueryDB.UpdateJYZ(((ResSilosMode)data).id,k); | |||
// Initdata(); | |||
// break; | |||
// } | |||
// } | |||
//endregion | |||
} |