@@ -199,11 +199,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||||
{ | { | ||||
//ping 不通 | //ping 不通 | ||||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1); | boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1); | ||||
if(status) | |||||
{ | |||||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||||
ModbusTcpServer.ConnectPLC(); | |||||
}else | |||||
if(!status) //ping 不通 连接 | |||||
{ | { | ||||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | ||||
DataBus.getInstance().PlcIsConnect=false; | DataBus.getInstance().PlcIsConnect=false; | ||||
@@ -11,6 +11,7 @@ import com.example.bpa.config.DataBus; | |||||
import com.example.bpa.db.QueryDB; | import com.example.bpa.db.QueryDB; | ||||
import com.example.bpa.db.file.DBHelper; | import com.example.bpa.db.file.DBHelper; | ||||
import com.example.bpa.db.mode.BPA_ALERTLOG; | import com.example.bpa.db.mode.BPA_ALERTLOG; | ||||
import com.example.bpa.db.mode.BPA_GOODSRECIPE; | |||||
import com.example.bpa.db.mode.BPA_LOG; | import com.example.bpa.db.mode.BPA_LOG; | ||||
import com.example.bpa.db.mode.BPA_SILOS; | import com.example.bpa.db.mode.BPA_SILOS; | ||||
import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | ||||
@@ -42,10 +43,13 @@ public class BootInit { | |||||
ToastUtil.init(app); | ToastUtil.init(app); | ||||
//2.初始化SD卡,数据库DB | //2.初始化SD卡,数据库DB | ||||
SdCart.getInstance().initSD(); | SdCart.getInstance().initSD(); | ||||
//3.初始化数据 | //3.初始化数据 | ||||
InitDBdata(); | InitDBdata(); | ||||
//4.初始化Main | //4.初始化Main | ||||
Main.getInstance(); | Main.getInstance(); | ||||
//BusinessServer.Get().test(); | //BusinessServer.Get().test(); | ||||
//MessageLog.ShowAlertMessage(AlertLogEnum.传感器异常日志,"传感器异常"); | //MessageLog.ShowAlertMessage(AlertLogEnum.传感器异常日志,"传感器异常"); | ||||
//MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志,"异常订单未制作日志"); | //MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志,"异常订单未制作日志"); | ||||
@@ -179,8 +183,16 @@ public class BootInit { | |||||
/** | /** | ||||
* 删除子订单表-重新生成新表 | * 删除子订单表-重新生成新表 | ||||
*/ | */ | ||||
public void DBdelete() | |||||
public static void DBdelete() | |||||
{ | { | ||||
DBHelper.getInstance(ConfigName.getInstance().dishesCon).DeleteCreateTables(BPA_SUBORDER.class,null); | DBHelper.getInstance(ConfigName.getInstance().dishesCon).DeleteCreateTables(BPA_SUBORDER.class,null); | ||||
} | } | ||||
/** | |||||
* 更新数据库字段 | |||||
*/ | |||||
public static void UpdateTablezd() | |||||
{ | |||||
DBHelper.getInstance(ConfigName.getInstance().dishesCon).UpdateTbalezd(BPA_GOODSRECIPE.class,null,"value","text"); | |||||
} | |||||
} | } |
@@ -204,7 +204,7 @@ public class ConfigName { | |||||
//硬件设备 初始化 | //硬件设备 初始化 | ||||
add(new Res_PLCADDRESS("-------------","","出料口",1,0)); | add(new Res_PLCADDRESS("-------------","","出料口",1,0)); | ||||
add(new Res_PLCADDRESS("M51.6","M101.6","出料口振动器",1,1)); | |||||
add(new Res_PLCADDRESS("M41.6","M101.6","出料口振动器",1,1)); | |||||
add(new Res_PLCADDRESS("-------------","","酱油仓/猪油仓",1,0)); | add(new Res_PLCADDRESS("-------------","","酱油仓/猪油仓",1,0)); | ||||
add(new Res_PLCADDRESS("M52.7","M102.7","酱油仓控制",0,1)); | add(new Res_PLCADDRESS("M52.7","M102.7","酱油仓控制",0,1)); | ||||
@@ -221,18 +221,18 @@ public class ConfigName { | |||||
add(new Res_PLCADDRESS("M50.4","M100.4","外置仓正转(5)",1,1)); | add(new Res_PLCADDRESS("M50.4","M100.4","外置仓正转(5)",1,1)); | ||||
add(new Res_PLCADDRESS("M50.5","M100.5","外置仓正转(6)",1,1)); | add(new Res_PLCADDRESS("M50.5","M100.5","外置仓正转(6)",1,1)); | ||||
add(new Res_PLCADDRESS("M51.0","M101.0","外置仓反转(1)",1,1)); | |||||
add(new Res_PLCADDRESS("M51.1","M101.1","外置仓反转(2)",1,1)); | |||||
add(new Res_PLCADDRESS("M51.2","M101.2","外置仓反转(3)",1,1)); | |||||
add(new Res_PLCADDRESS("M51.3","M101.3","外置仓反转(4)",1,1)); | |||||
add(new Res_PLCADDRESS("M51.4","M101.4","外置仓反转(5)",1,1)); | |||||
add(new Res_PLCADDRESS("M51.5","M101.5","外置仓反转(6)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.0","M101.0","外置仓反转(1)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.1","M101.1","外置仓反转(2)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.2","M101.2","外置仓反转(3)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.3","M101.3","外置仓反转(4)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.4","M101.4","外置仓反转(5)",1,1)); | |||||
add(new Res_PLCADDRESS("M41.5","M101.5","外置仓反转(6)",1,1)); | |||||
add(new Res_PLCADDRESS("-------------","","粉料仓",0,0)); | add(new Res_PLCADDRESS("-------------","","粉料仓",0,0)); | ||||
add(new Res_PLCADDRESS("M52.2","M102.2","粉料仓控制(1)",0,1)); | add(new Res_PLCADDRESS("M52.2","M102.2","粉料仓控制(1)",0,1)); | ||||
add(new Res_PLCADDRESS("M52.3","M102.3","粉料仓控制(1)",0,1)); | |||||
add(new Res_PLCADDRESS("M52.4","M102.4","粉料仓控制(1)",0,1)); | |||||
add(new Res_PLCADDRESS("M52.5","M102.5","粉料仓控制(1)",0,1)); | |||||
add(new Res_PLCADDRESS("M52.3","M102.3","粉料仓控制(2)",0,1)); | |||||
add(new Res_PLCADDRESS("M52.4","M102.4","粉料仓控制(3)",0,1)); | |||||
add(new Res_PLCADDRESS("M52.5","M102.5","粉料仓控制(4)",0,1)); | |||||
add(new Res_PLCADDRESS("-------------","","水池",1,0)); | add(new Res_PLCADDRESS("-------------","","水池",1,0)); | ||||
add(new Res_PLCADDRESS("M50.6","M100.6","水池排水阀",1,1)); | add(new Res_PLCADDRESS("M50.6","M100.6","水池排水阀",1,1)); | ||||
@@ -320,31 +320,31 @@ public class DataBus { | |||||
public ResultA InspectMaterial(String GoodId) | public ResultA InspectMaterial(String GoodId) | ||||
{ | { | ||||
ResultA resultA=new ResultA(); | ResultA resultA=new ResultA(); | ||||
boolean IsMake=true; | |||||
String message=""; | |||||
// boolean IsMake=true; | |||||
// String message=""; | |||||
try | try | ||||
{ | { | ||||
ArrayList<ResGoodsRecipe> goodsRecipes = QueryDB.GetGoodsSrecipeList(GoodId); | |||||
for (ResGoodsRecipe recipe:goodsRecipes) | |||||
{ | |||||
BPA_SILOS silos=null; | |||||
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); | |||||
for (BPA_SILOS si:siloslist) | |||||
{ | |||||
if(DeviceData.Get().getCallCurrentWeight(si.num)>=recipe.value){silos=si;break;} | |||||
} | |||||
if(silos==null) | |||||
{ | |||||
IsMake=false; | |||||
message+=recipe.materialName+","; | |||||
} | |||||
} | |||||
resultA.IsMake=IsMake; | |||||
resultA.Message="【" +message+"】物料不足,请检查料仓物料!"; | |||||
// ArrayList<ResGoodsRecipe> goodsRecipes = QueryDB.GetGoodsSrecipeList(GoodId); | |||||
// for (ResGoodsRecipe recipe:goodsRecipes) | |||||
// { | |||||
// BPA_SILOS silos=null; | |||||
// List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); | |||||
// for (BPA_SILOS si:siloslist) | |||||
// { | |||||
// if(DeviceData.Get().getCallCurrentWeight(si.num)>=recipe.value){silos=si;break;} | |||||
// } | |||||
// if(silos==null) | |||||
// { | |||||
// IsMake=false; | |||||
// message+=recipe.materialName+","; | |||||
// } | |||||
// } | |||||
// resultA.IsMake=IsMake; | |||||
// resultA.Message="【" +message+"】物料不足,请检查料仓物料!"; | |||||
return resultA; | return resultA; | ||||
}catch(Exception e){ | }catch(Exception e){ | ||||
resultA.IsMake=false; | |||||
resultA.Message=e.getMessage(); | |||||
// resultA.IsMake=false; | |||||
// resultA.Message=e.getMessage(); | |||||
return resultA; | return resultA; | ||||
} | } | ||||
} | } | ||||
@@ -2066,7 +2066,7 @@ public class QueryDB { | |||||
//私有 | //私有 | ||||
((BPA_GOODSRECIPE) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); | ((BPA_GOODSRECIPE) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); | ||||
((BPA_GOODSRECIPE) data).materialID = cursor.getString((int) cursor.getColumnIndex("materialID")); | ((BPA_GOODSRECIPE) data).materialID = cursor.getString((int) cursor.getColumnIndex("materialID")); | ||||
((BPA_GOODSRECIPE) data).value = cursor.getInt((int) cursor.getColumnIndex("value")); | |||||
((BPA_GOODSRECIPE) data).value = cursor.getString((int) cursor.getColumnIndex("value")); | |||||
((BPA_GOODSRECIPE) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | ((BPA_GOODSRECIPE) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | ||||
((BPA_GOODSRECIPE) data).materialType = cursor.getInt((int) cursor.getColumnIndex("materialType")); | ((BPA_GOODSRECIPE) data).materialType = cursor.getInt((int) cursor.getColumnIndex("materialType")); | ||||
break; | break; | ||||
@@ -2141,11 +2141,13 @@ public class QueryDB { | |||||
//私有 | //私有 | ||||
((BPA_SUGAR) data).sugarName = cursor.getString((int) cursor.getColumnIndex("sugarName")); | ((BPA_SUGAR) data).sugarName = cursor.getString((int) cursor.getColumnIndex("sugarName")); | ||||
((BPA_SUGAR) data).plcvar = cursor.getString((int) cursor.getColumnIndex("plcvar")); | ((BPA_SUGAR) data).plcvar = cursor.getString((int) cursor.getColumnIndex("plcvar")); | ||||
break; | |||||
case "BPA_CRAFT": | case "BPA_CRAFT": | ||||
data = new BPA_CRAFT(); | data = new BPA_CRAFT(); | ||||
//私有 | //私有 | ||||
((BPA_CRAFT) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | ((BPA_CRAFT) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | ||||
((BPA_CRAFT) data).name = cursor.getString((int) cursor.getColumnIndex("name")); | ((BPA_CRAFT) data).name = cursor.getString((int) cursor.getColumnIndex("name")); | ||||
break; | |||||
case "BPA_CRAFTPROCESS": | case "BPA_CRAFTPROCESS": | ||||
data = new BPA_CRAFTPROCESS(); | data = new BPA_CRAFTPROCESS(); | ||||
//私有 | //私有 | ||||
@@ -2153,7 +2155,7 @@ public class QueryDB { | |||||
((BPA_CRAFTPROCESS) data).pfid = cursor.getString((int) cursor.getColumnIndex("pfid")); | ((BPA_CRAFTPROCESS) data).pfid = cursor.getString((int) cursor.getColumnIndex("pfid")); | ||||
((BPA_CRAFTPROCESS) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | ((BPA_CRAFTPROCESS) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | ||||
((BPA_CRAFTPROCESS) data).value = cursor.getInt((int) cursor.getColumnIndex("value")); | ((BPA_CRAFTPROCESS) data).value = cursor.getInt((int) cursor.getColumnIndex("value")); | ||||
break; | |||||
} | } | ||||
((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); | ((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); | ||||
((ModeBase) data).createTime = cursor.getString((int) cursor.getColumnIndex("createTime")); | ((ModeBase) data).createTime = cursor.getString((int) cursor.getColumnIndex("createTime")); | ||||
@@ -215,4 +215,60 @@ public class DBHelper extends SQLiteOpenHelper { | |||||
db.setTransactionSuccessful(); | db.setTransactionSuccessful(); | ||||
db.endTransaction(); | db.endTransaction(); | ||||
} | } | ||||
/** | |||||
* 更新数据库字段 | |||||
* @param c | |||||
* @param premarykey | |||||
* @param newname | |||||
* @param newtype | |||||
*/ | |||||
public void UpdateTbalezd(Class c,String premarykey,String newname,String newtype) | |||||
{ | |||||
SQLiteDatabase db =this.getWritableDatabase(); | |||||
db.beginTransaction(); | |||||
String TabName= c.getSimpleName();//表名称 | |||||
Table t = new Table(TabName); // 创建表名称 | |||||
Table t1 = new Table(TabName+"LAO"); // 创建表名称 | |||||
String zd=""; | |||||
for (Field field : c.getFields()){ | |||||
String name=field.getName(); | |||||
String type=field.getType().getSimpleName(); | |||||
if(type.equals("String") || type.equals("Date")) | |||||
{ | |||||
type="text"; | |||||
} | |||||
t.addFeild(new Feild(name, type)); // 字段名称 | |||||
if(name.equals(newname)) | |||||
{ | |||||
t1.addFeild(new Feild(name, newtype)); | |||||
}else | |||||
{ | |||||
t1.addFeild(new Feild(name, type)); | |||||
} | |||||
zd+=name+","; | |||||
} | |||||
db.execSQL(t1.createSQL(premarykey));//创建临时表 | |||||
// 2. 复制数据到临时表 | |||||
//"INSERT INTO new_table (column1, column2) " | |||||
// + "SELECT column1, column2 " | |||||
// + "FROM original_table;" | |||||
String _sql=String.format("INSERT INTO %s (%s) SELECT %s FROM %s", | |||||
TabName+"LAO", | |||||
zd.trim().replaceAll(",$", ""), | |||||
zd.trim().replaceAll(",$", ""), | |||||
TabName | |||||
); | |||||
db.execSQL(_sql); | |||||
db.execSQL(t.deleteSql()); | |||||
db.execSQL("ALTER TABLE "+TabName+"LAO RENAME TO "+TabName+";");//重新命名 | |||||
db.setTransactionSuccessful(); | |||||
db.endTransaction(); | |||||
} | |||||
} | } |
@@ -41,7 +41,10 @@ public class Table { | |||||
sb.append(" "); | sb.append(" "); | ||||
sb.append(f.type); | sb.append(f.type); | ||||
sb.append(" "); | sb.append(" "); | ||||
if (premarykey.equals(f.name)) {sb.append("PRIMARY KEY");}//主键 | |||||
if(premarykey!=null) | |||||
{ | |||||
if (premarykey.equals(f.name)) {sb.append("PRIMARY KEY");}//主键 | |||||
} | |||||
sb.append(","); | sb.append(","); | ||||
} | } | ||||
sb.deleteCharAt(sb.length()-1); | sb.deleteCharAt(sb.length()-1); | ||||
@@ -10,7 +10,7 @@ public class BPA_GOODSRECIPE extends ModeBase { | |||||
//物料ID | //物料ID | ||||
public String materialID; | public String materialID; | ||||
//出料数值:20g | //出料数值:20g | ||||
public int value; | |||||
public String value; | |||||
//排序 | //排序 | ||||
public int sort; | public int sort; | ||||
//物料类型 | //物料类型 | ||||
@@ -0,0 +1,14 @@ | |||||
package com.example.bpa.db.mode; | |||||
public class BPA_GOODSRECIPELAO extends ModeBase { | |||||
//商品ID | |||||
public String goodsID; | |||||
//物料ID | |||||
public String materialID; | |||||
//出料数值:20g | |||||
public String value; | |||||
//排序 | |||||
public int sort; | |||||
//物料类型 | |||||
public int materialType; | |||||
} |
@@ -135,7 +135,8 @@ public class BusinessServer { | |||||
} else { | } else { | ||||
liaochang.add(silos.num); | liaochang.add(silos.num); | ||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); | ||||
DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() { | |||||
int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10)); | |||||
DeviceData.Get().setDemandValue((short) _val, silos.num, new IWriteCallBack() { | |||||
@Override | @Override | ||||
public void onSuccess() { | public void onSuccess() { | ||||
MessageLog.ShowInfo(message + "下发成功!"); | MessageLog.ShowInfo(message + "下发成功!"); | ||||
@@ -155,19 +156,20 @@ public class BusinessServer { | |||||
ModbusTcpServer.get().WriteBool(bs.plcvar, false); | ModbusTcpServer.get().WriteBool(bs.plcvar, false); | ||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发成功!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发成功!"); | ||||
} | } | ||||
//将其余料仓出料设置为0,重置 | |||||
for (int k = 1; k <= 12; k++) { | |||||
if (!liaochang.contains(k)) { | |||||
DeviceData.Get().setDemandValue((short) 0, k, new IWriteCallBack() { | |||||
@Override | |||||
public void onSuccess() { | |||||
} | |||||
} | |||||
@Override | |||||
public void onFailure(String ErrorMsg) { | |||||
} | |||||
}); | |||||
} | |||||
//将其余料仓出料设置为0,重置 | |||||
for (int k = 1; k <= 12; k++) { | |||||
if (!liaochang.contains(k)) { | |||||
DeviceData.Get().setDemandValue((short) 0, k, new IWriteCallBack() { | |||||
@Override | |||||
public void onSuccess() { | |||||
} | |||||
@Override | |||||
public void onFailure(String ErrorMsg) { | |||||
} | |||||
}); | |||||
} | } | ||||
} | } | ||||
@@ -68,6 +68,14 @@ public class DeviceData { | |||||
JRX_FructoseTemperature=ints[1]; | JRX_FructoseTemperature=ints[1]; | ||||
}); | }); | ||||
//获取温度设置 | |||||
ModbusTcpServer.get().ReadInt("VD372", 1, ints -> { | |||||
BWX_FructoseTemperature_sz=ints[0]; | |||||
}); | |||||
ModbusTcpServer.get().ReadInt("VD380", 1, ints -> { | |||||
JRX_FructoseTemperature_sz=ints[0]; | |||||
}); | |||||
//获取校准模式 | //获取校准模式 | ||||
ModbusTcpServer.get().ReadBool("M1.0", 1, booleans -> { | ModbusTcpServer.get().ReadBool("M1.0", 1, booleans -> { | ||||
WeightCalibrationMode = booleans[0]; | WeightCalibrationMode = booleans[0]; | ||||
@@ -98,7 +106,7 @@ public class DeviceData { | |||||
ModbusTcpServer.get().ReadBool("M105.0", 6, booleans -> { | ModbusTcpServer.get().ReadBool("M105.0", 6, booleans -> { | ||||
for (int i=0;i<booleans.length;i++) | for (int i=0;i<booleans.length;i++) | ||||
{ | { | ||||
AutomationValue.put(i,booleans[i]); | |||||
CompensateValue.put(i,booleans[i]); | |||||
} | } | ||||
}); | }); | ||||
@@ -205,7 +213,7 @@ public class DeviceData { | |||||
* @param ch 需要写入的通道编号,1--10 | * @param ch 需要写入的通道编号,1--10 | ||||
*/ | */ | ||||
public void setDemandValue(short value, int ch, IWriteCallBack callback) { | public void setDemandValue(short value, int ch, IWriteCallBack callback) { | ||||
if (ch >= 1 && ch <= 10) { | |||||
if (ch >= 1 && ch <= 12) { | |||||
String add = "VW" + (298 + ch * 2); | String add = "VW" + (298 + ch * 2); | ||||
ModbusTcpServer.get().WriteShort(add, value, callback); | ModbusTcpServer.get().WriteShort(add, value, callback); | ||||
} | } | ||||
@@ -215,7 +223,7 @@ public class DeviceData { | |||||
* 设置通道校准开关 | * 设置通道校准开关 | ||||
* ,PLC 地址 M2.0--M3.1 | * ,PLC 地址 M2.0--M3.1 | ||||
* | * | ||||
* @param value 需要写入的值 | |||||
* @param value 需要写入的值122 | |||||
* @param ch 需要写入的通道编号,1--10 | * @param ch 需要写入的通道编号,1--10 | ||||
*/ | */ | ||||
public void setChCalibrationSwitch(boolean value, int ch, IWriteCallBack callback) { | public void setChCalibrationSwitch(boolean value, int ch, IWriteCallBack callback) { | ||||
@@ -314,7 +314,7 @@ public class OrderServer { | |||||
da.id=info.Id; | da.id=info.Id; | ||||
Batchingstechnology gy= chnology.get(info.Id); | Batchingstechnology gy= chnology.get(info.Id); | ||||
da.materialID = info.BatchingId; | da.materialID = info.BatchingId; | ||||
da.value = (int)info.BomQty; | |||||
da.value =String.format ("%.1f", info.BomQty); | |||||
if(gy!=null) | if(gy!=null) | ||||
{ | { | ||||
da.sort =gy.Sort; | da.sort =gy.Sort; | ||||
@@ -352,7 +352,7 @@ public class OrderServer { | |||||
{ | { | ||||
da.id=java.util.UUID.randomUUID().toString(); | da.id=java.util.UUID.randomUUID().toString(); | ||||
da.materialID = a.BatchingId; | da.materialID = a.BatchingId; | ||||
da.value = Integer.valueOf(a.ActionValue) ; | |||||
da.value =String.format ("%.1f", a.ActionValue); | |||||
da.sort =Integer.parseInt(actions.Sort); | da.sort =Integer.parseInt(actions.Sort); | ||||
QueryDB.AddGoodsSrecipe(da); | QueryDB.AddGoodsSrecipe(da); | ||||
} | } | ||||
@@ -139,7 +139,7 @@ public class pf_adapter extends ArrayAdapter<ResGoodsRecipe> { | |||||
T.show(view.getContext(), "不能为空!"); | T.show(view.getContext(), "不能为空!"); | ||||
return; | return; | ||||
} | } | ||||
resGoodsRecipe.value=Integer.parseInt(so); | |||||
resGoodsRecipe.value=String.format ("%.1f", Double.parseDouble(so)); | |||||
datas.set(position,resGoodsRecipe); | datas.set(position,resGoodsRecipe); | ||||
} | } | ||||
}); | }); | ||||
@@ -67,10 +67,12 @@ public class clsf_control extends LinearLayout { | |||||
@Override | @Override | ||||
public void run() { | public void run() { | ||||
try { | try { | ||||
switch1.setChecked(DeviceData.Get().getAutomationValue(in)); | |||||
switch1.setChecked(DeviceData.Get().getAutomationValue(in-1)); | |||||
bc_text1.setText(DeviceData.Get().ReadAutomationValue(sf.H_address)+""); | bc_text1.setText(DeviceData.Get().ReadAutomationValue(sf.H_address)+""); | ||||
bc_text2.setText(DeviceData.Get().ReadAutomationValue(sf.L_address)+""); | bc_text2.setText(DeviceData.Get().ReadAutomationValue(sf.L_address)+""); | ||||
bc_text3.setText(DeviceData.Get().ReadAutomationValue(sf.time_address)+""); | |||||
int time=DeviceData.Get().ReadAutomationValue(sf.time_address); | |||||
bc_text3.setText(String.format ("%.1f", time/10.0)+""); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
} | } | ||||
@@ -107,7 +109,9 @@ public class clsf_control extends LinearLayout { | |||||
try { | try { | ||||
H=Short.parseShort(bc_text1.getText().toString()) ; | H=Short.parseShort(bc_text1.getText().toString()) ; | ||||
L=Short.parseShort(bc_text2.getText().toString()) ; | L=Short.parseShort(bc_text2.getText().toString()) ; | ||||
time=Short.parseShort(bc_text3.getText().toString()) ; | |||||
//time=(Short)Math.round(); | |||||
int ftime = (int)Math.round((Double.parseDouble(bc_text3.getText().toString()) * 10)); | |||||
time=(short) ftime; | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -140,19 +144,45 @@ public class clsf_control extends LinearLayout { | |||||
T.show(view.getContext(), "出料重量不能为空!"); | T.show(view.getContext(), "出料重量不能为空!"); | ||||
return; | return; | ||||
} | } | ||||
int zl = 0; | |||||
double zl = 0; | |||||
try { | try { | ||||
zl = Integer.parseInt(zltext); | |||||
zl = Double.parseDouble(zltext); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
T.show(view.getContext(), "出料重量获取异常!" + e.getMessage()); | T.show(view.getContext(), "出料重量获取异常!" + e.getMessage()); | ||||
return; | return; | ||||
} | } | ||||
int finalZl = zl; | |||||
DeviceData.Get().setDemandValue((short) zl, index, new IWriteCallBack() { | |||||
if(zl<=1) | |||||
{ | |||||
T.show(view.getContext(), "出料重量至少大于1g!"); | |||||
return; | |||||
} | |||||
double finalZl = zl; | |||||
//将其余料仓出料设置为0,重置 | |||||
for (int k = 1; k <= 12; k++) { | |||||
if (k!=index) { | |||||
DeviceData.Get().setDemandValue((short) 0, k,null); | |||||
} | |||||
} | |||||
DeviceData.Get().setDemandValue((short) ((int)(zl*10)), index, new IWriteCallBack() { | |||||
@Override | @Override | ||||
public void onSuccess() { | public void onSuccess() { | ||||
MessageLog.ShowInfo( "模拟物料下发成功!克数:"+ finalZl +"g"); | MessageLog.ShowInfo( "模拟物料下发成功!克数:"+ finalZl +"g"); | ||||
T.show(view.getContext(), "模拟物料下发成功!克数:"+ finalZl +"g"); | |||||
DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { | |||||
@Override | |||||
public void onSuccess() { | |||||
MessageLog.ShowInfo( "开始出料!克数:"+ finalZl +"g"); | |||||
T.show(view.getContext(), "开始出料!克数:"+ finalZl +"g"); | |||||
} | |||||
@Override | |||||
public void onFailure(String ErrorMsg) { | |||||
MessageLog.ShowInfo( "出料失败!克数:"+ finalZl +"g"); | |||||
T.show(view.getContext(), "出料失败!克数:"+ finalZl +"g"); | |||||
} | |||||
}); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -160,9 +190,6 @@ public class clsf_control extends LinearLayout { | |||||
MessageLog.ShowInfo( "模拟物料下发失败!"); | MessageLog.ShowInfo( "模拟物料下发失败!"); | ||||
} | } | ||||
}); | }); | ||||
//启动配料 | |||||
DeviceData.Get().setChargeMixtureStart(null); | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -63,7 +63,7 @@ public class sdkz_control extends LinearLayout { | |||||
aSwitch.setTag(item.zd_address); | aSwitch.setTag(item.zd_address); | ||||
aSwitch.setChecked(DeviceData.Get().getAutomationValue(item.address)); | aSwitch.setChecked(DeviceData.Get().getAutomationValue(item.address)); | ||||
} | } | ||||
aSwitch.setHeight(40); | |||||
aSwitch.setHeight(55); | |||||
aSwitch.setBackground(ConfigName.getInstance().dishesCon.getResources().getDrawable(R.drawable.qs_switch)); | aSwitch.setBackground(ConfigName.getInstance().dishesCon.getResources().getDrawable(R.drawable.qs_switch)); | ||||
aSwitch.setOnClickListener(new OnClickListener() { | aSwitch.setOnClickListener(new OnClickListener() { | ||||
@Override | @Override | ||||
@@ -286,6 +286,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi | |||||
recipe1.sort=1; | recipe1.sort=1; | ||||
recipe1.materialName = wuliaolist_spinner.getSelectedItem().toString(); | recipe1.materialName = wuliaolist_spinner.getSelectedItem().toString(); | ||||
recipe1.materialID = material_map.get(recipe1.materialName); | recipe1.materialID = material_map.get(recipe1.materialName); | ||||
recipe1.value="0"; | |||||
bpa_pf.add(recipe1); | bpa_pf.add(recipe1); | ||||
DataTab(); | DataTab(); | ||||
break; | break; | ||||
@@ -296,6 +297,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi | |||||
recipe.materialType = 2; | recipe.materialType = 2; | ||||
recipe.materialName = guotanglist_spinner.getSelectedItem().toString(); | recipe.materialName = guotanglist_spinner.getSelectedItem().toString(); | ||||
recipe.materialID = sugar_map.get(recipe.materialName); | recipe.materialID = sugar_map.get(recipe.materialName); | ||||
recipe.value="0"; | |||||
bpa_pf.add(recipe); | bpa_pf.add(recipe); | ||||
DataTab(); | DataTab(); | ||||
break; | break; | ||||
@@ -151,11 +151,11 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
try { | try { | ||||
for (int i = 0; i < 12; i++) { | for (int i = 0; i < 12; i++) { | ||||
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); | String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); | ||||
editTextLists.get(i).setText(s); | |||||
editTextLists.get(i).setText(String.format ("%.1f", (Double.parseDouble(s)/10))); | |||||
} | } | ||||
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime()); | String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime()); | ||||
//校准时间 | //校准时间 | ||||
timeText.setText(time); | |||||
timeText.setText(String.format ("%.1f", (Double.parseDouble(time)/10))); | |||||
//设置手动模式 | //设置手动模式 | ||||
DeviceData.Get().setHandOrAutoSwitch(false, null); | DeviceData.Get().setHandOrAutoSwitch(false, null); | ||||
@@ -186,7 +186,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
} | } | ||||
int ftime = 0; | int ftime = 0; | ||||
try { | try { | ||||
ftime = Integer.parseInt(stime); | |||||
ftime = (int)Math.round((Double.parseDouble(stime) * 10)); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
T.show(lsjy_activity.this, "校准基准时间异常!" + e.getMessage()); | T.show(lsjy_activity.this, "校准基准时间异常!" + e.getMessage()); | ||||
return; | return; | ||||
@@ -210,7 +210,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
String value = editTextLists.get(i).getText().toString(); | String value = editTextLists.get(i).getText().toString(); | ||||
Short val = 0; | Short val = 0; | ||||
try { | try { | ||||
val = Short.parseShort(value); | |||||
val =(short)Math.round((Double.parseDouble(value) * 10)); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
} | } | ||||
if (val <= 0) { | if (val <= 0) { | ||||
@@ -224,7 +224,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
String value = editTextLists.get(i).getText().toString(); | String value = editTextLists.get(i).getText().toString(); | ||||
Short val = 0; | Short val = 0; | ||||
try { | try { | ||||
val = Short.parseShort(value); | |||||
val =(short)Math.round((Double.parseDouble(value) * 10)); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
} | } | ||||
DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() { | DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() { | ||||
@@ -2,6 +2,6 @@ | |||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||||
android:shape="rectangle" | android:shape="rectangle" | ||||
> | > | ||||
<solid android:color="#9F14EA09"/> | |||||
<corners android:radius="25dp"/> | |||||
<solid android:color="#B74626A2"/> | |||||
<corners android:radius="35dp"/> | |||||
</shape> | </shape> |
@@ -79,8 +79,8 @@ | |||||
android:layout_centerVertical="true" | android:layout_centerVertical="true" | ||||
android:layout_marginLeft="20dp" | android:layout_marginLeft="20dp" | ||||
android:layout_alignParentLeft="true" | android:layout_alignParentLeft="true" | ||||
android:inputType="text" | |||||
android:digits="0123456789" | |||||
android:inputType="number|numberDecimal" | |||||
android:digits="0123456789." | |||||
android:padding="3dp" | android:padding="3dp" | ||||
android:textColor="@color/foreground" | android:textColor="@color/foreground" | ||||
android:theme="@style/MyEditText1" | android:theme="@style/MyEditText1" | ||||
@@ -523,7 +523,7 @@ | |||||
<TextView | <TextView | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="校准基准时间:" | |||||
android:text="校准基准时间():" | |||||
android:textColor="@color/white" | android:textColor="@color/white" | ||||
android:textStyle="bold" | android:textStyle="bold" | ||||
android:gravity="center" | android:gravity="center" | ||||
@@ -6,7 +6,7 @@ | |||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
android:background="@mipmap/bg_f3" | |||||
android:background="@mipmap/bg_f2" | |||||
android:layout_marginTop="5dp" | android:layout_marginTop="5dp" | ||||
android:layout_marginRight="10dp" | android:layout_marginRight="10dp" | ||||
android:layout_marginLeft="10dp" | android:layout_marginLeft="10dp" | ||||
@@ -29,38 +29,38 @@ | |||||
android:adjustViewBounds="true" | android:adjustViewBounds="true" | ||||
android:alpha="0.8" | android:alpha="0.8" | ||||
android:scaleType="centerCrop" | android:scaleType="centerCrop" | ||||
android:src="@mipmap/milktea_1" /> | |||||
android:src="@mipmap/milktea_2" /> | |||||
<RelativeLayout | <RelativeLayout | ||||
android:layout_margin="0dp" | android:layout_margin="0dp" | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
android:background="@mipmap/bg_text1"> | |||||
android:background="@mipmap/bg_f1"> | |||||
<TextView | <TextView | ||||
android:id="@+id/goodname" | android:id="@+id/goodname" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:layout_marginLeft="25dp" | |||||
android:layout_marginTop="32dp" | |||||
android:layout_marginLeft="28dp" | |||||
android:layout_marginTop="22dp" | |||||
android:text="原味奶茶" | android:text="原味奶茶" | ||||
android:textColor="@color/white" | |||||
android:textSize="20dp" | |||||
android:textColor="@color/colorPrimaryDark" | |||||
android:textSize="@dimen/TitleSize" | |||||
android:textStyle="bold" | android:textStyle="bold" | ||||
android:typeface="serif" /> | android:typeface="serif" /> | ||||
<Button | <Button | ||||
android:id="@+id/goodmake" | android:id="@+id/goodmake" | ||||
android:layout_width="80dp" | |||||
android:layout_height="24dp" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="34dp" | |||||
android:layout_gravity="center_vertical" | android:layout_gravity="center_vertical" | ||||
android:layout_alignParentBottom="true" | android:layout_alignParentBottom="true" | ||||
android:layout_alignParentRight="true" | android:layout_alignParentRight="true" | ||||
android:layout_marginLeft="28dp" | |||||
android:layout_marginRight="18dp" | |||||
android:layout_marginBottom="28dp" | |||||
android:textColor="@color/white" | |||||
android:layout_marginLeft="38dp" | |||||
android:layout_marginRight="38dp" | |||||
android:layout_marginBottom="20dp" | |||||
android:textColor="@color/foreground" | |||||
android:background="@drawable/ripple_goods" | android:background="@drawable/ripple_goods" | ||||
android:text="配料" /> | |||||
android:text="开始配料" /> | |||||
</RelativeLayout> | </RelativeLayout> | ||||
</RelativeLayout> | </RelativeLayout> | ||||
</LinearLayout> | </LinearLayout> | ||||