@@ -25,6 +25,8 @@ import com.example.bpa.service.BusinessServer; | |||||
import com.example.bpa.view.mode.AlertLogEnum; | import com.example.bpa.view.mode.AlertLogEnum; | ||||
import com.example.bpa.view.mode.UserLogEnum; | import com.example.bpa.view.mode.UserLogEnum; | ||||
import java.util.ArrayList; | |||||
import pub.devrel.easypermissions.EasyPermissions; | import pub.devrel.easypermissions.EasyPermissions; | ||||
public class BootInit { | public class BootInit { | ||||
@@ -153,7 +155,7 @@ public class BootInit { | |||||
QueryDB.AddUser(user); | QueryDB.AddUser(user); | ||||
//10个料仓+ 11 12 两个果糖料仓 | //10个料仓+ 11 12 两个果糖料仓 | ||||
if (QueryDB.GetSilosALL().size() == 0) { | if (QueryDB.GetSilosALL().size() == 0) { | ||||
for (int i = 0; i < 12; i++) { | |||||
for (int i = 0; i < 13; i++) { | |||||
BPA_SILOS silo = new BPA_SILOS(); | BPA_SILOS silo = new BPA_SILOS(); | ||||
silo.id = java.util.UUID.randomUUID().toString(); | silo.id = java.util.UUID.randomUUID().toString(); | ||||
silo.num = i + 1; | silo.num = i + 1; | ||||
@@ -172,6 +174,8 @@ public class BootInit { | |||||
silo.name="酱油仓"; | silo.name="酱油仓"; | ||||
}else if (i==11) { | }else if (i==11) { | ||||
silo.name="猪油仓"; | silo.name="猪油仓"; | ||||
}else if (i==12) { | |||||
silo.name="高汤仓"; | |||||
} | } | ||||
QueryDB.AddSilos(silo); | QueryDB.AddSilos(silo); | ||||
QueryDB.AddSilosAndMaterial(sm); | QueryDB.AddSilosAndMaterial(sm); | ||||
@@ -180,6 +184,41 @@ public class BootInit { | |||||
} | } | ||||
} | } | ||||
public static void DeleteSilos() | |||||
{ | |||||
ArrayList<BPA_SILOS> sol= QueryDB.GetSilosALL(); | |||||
for (BPA_SILOS item:sol) | |||||
{ | |||||
QueryDB.DeleteSilos(item); | |||||
QueryDB.DeleteSilosAndMaterial(item.id); | |||||
} | |||||
for (int i = 0; i < 13; i++) { | |||||
BPA_SILOS silo = new BPA_SILOS(); | |||||
silo.id = java.util.UUID.randomUUID().toString(); | |||||
silo.num = i + 1; | |||||
silo.thrsoleValue=ConfigName.getInstance().SiloAlarmThreshold; | |||||
silo.warningValue=ConfigName.getInstance().SiloFeedThreshold; | |||||
BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); | |||||
sm.silosID = silo.id; | |||||
sm.materialID = ""; | |||||
if(i<6) | |||||
{ | |||||
silo.name="外置仓"; | |||||
} else if (i>=6 && i<10) { | |||||
silo.name="粉料仓"; | |||||
}else if (i==10) { | |||||
silo.name="酱油仓"; | |||||
}else if (i==11) { | |||||
silo.name="猪油仓"; | |||||
}else if (i==12) { | |||||
silo.name="高汤仓"; | |||||
} | |||||
QueryDB.AddSilos(silo); | |||||
QueryDB.AddSilosAndMaterial(sm); | |||||
} | |||||
} | |||||
/** | /** | ||||
* 删除子订单表-重新生成新表 | * 删除子订单表-重新生成新表 | ||||
*/ | */ | ||||
@@ -182,7 +182,7 @@ public class DeviceData { | |||||
* @param ch 需要写入的通道编号,1--10 | * @param ch 需要写入的通道编号,1--10 | ||||
*/ | */ | ||||
public void setCalibrationValue(short value, int ch, IWriteCallBack callback) { | public void setCalibrationValue(short value, int ch, IWriteCallBack callback) { | ||||
if (ch >= 1 && ch <= 12) { | |||||
if (ch >= 1 && ch <= 13) { | |||||
String add = "VW" + (-2 + ch * 2); | String add = "VW" + (-2 + ch * 2); | ||||
ModbusTcpServer.get().WriteShort(add, value, callback); | ModbusTcpServer.get().WriteShort(add, value, callback); | ||||
} | } | ||||
@@ -213,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 <= 12) { | |||||
if (ch >= 1 && ch <= 13) { | |||||
String add = "VW" + (298 + ch * 2); | String add = "VW" + (298 + ch * 2); | ||||
ModbusTcpServer.get().WriteShort(add, value, callback); | ModbusTcpServer.get().WriteShort(add, value, callback); | ||||
} | } | ||||
@@ -227,7 +227,7 @@ public class DeviceData { | |||||
* @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) { | ||||
if (ch >= 1 && ch <= 12) { | |||||
if (ch >= 1 && ch <= 13) { | |||||
String add=""; | String add=""; | ||||
if(ch==9) | if(ch==9) | ||||
{ | { | ||||
@@ -241,6 +241,10 @@ public class DeviceData { | |||||
}else if(ch==12) | }else if(ch==12) | ||||
{ | { | ||||
add="M3.3"; | add="M3.3"; | ||||
} | |||||
else if(ch==13) | |||||
{ | |||||
add="M3.4"; | |||||
}else | }else | ||||
{ | { | ||||
add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch); | add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch); | ||||
@@ -39,12 +39,12 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
*/ | */ | ||||
TextView gongneng_title; | TextView gongneng_title; | ||||
//通道校准值 | //通道校准值 | ||||
EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12; | |||||
EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12,passwayText_13; | |||||
//校准基准时间 | //校准基准时间 | ||||
EditText timeText; | 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_11, Switch_12; | |||||
Switch Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12,Switch_13; | |||||
List<Switch> switchLists = new ArrayList<Switch>(); | List<Switch> switchLists = new ArrayList<Switch>(); | ||||
//开始校准 | //开始校准 | ||||
Button StartButton; | Button StartButton; | ||||
@@ -106,8 +106,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
passwayText_10 = findViewById(R.id.passwayText_10); | passwayText_10 = findViewById(R.id.passwayText_10); | ||||
passwayText_11 = findViewById(R.id.passwayText_11); | passwayText_11 = findViewById(R.id.passwayText_11); | ||||
passwayText_12 = findViewById(R.id.passwayText_12); | passwayText_12 = findViewById(R.id.passwayText_12); | ||||
passwayText_13 = findViewById(R.id.passwayText_13); | |||||
editTextLists = Arrays.asList(passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12); | |||||
editTextLists = Arrays.asList(passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12, passwayText_13); | |||||
//校准开关 | //校准开关 | ||||
Switch_1 = findViewById(R.id.Switch_1); | Switch_1 = findViewById(R.id.Switch_1); | ||||
@@ -122,7 +123,8 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
Switch_10 = findViewById(R.id.Switch_10); | Switch_10 = findViewById(R.id.Switch_10); | ||||
Switch_11 = findViewById(R.id.Switch_11); | Switch_11 = findViewById(R.id.Switch_11); | ||||
Switch_12 = findViewById(R.id.Switch_12); | Switch_12 = findViewById(R.id.Switch_12); | ||||
switchLists = Arrays.asList(Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12); | |||||
Switch_13 = findViewById(R.id.Switch_13); | |||||
switchLists = Arrays.asList(Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12, Switch_13); | |||||
//校准按钮 | //校准按钮 | ||||
StartButton = findViewById(R.id.StartButton); | StartButton = findViewById(R.id.StartButton); | ||||
@@ -149,7 +151,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
public void Initdata() { | public void Initdata() { | ||||
//初始化标准值数据 | //初始化标准值数据 | ||||
try { | try { | ||||
for (int i = 0; i < 12; i++) { | |||||
for (int i = 0; i < 13; i++) { | |||||
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); | String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); | ||||
editTextLists.get(i).setText(String.format ("%.1f", (Double.parseDouble(s)/10))); | editTextLists.get(i).setText(String.format ("%.1f", (Double.parseDouble(s)/10))); | ||||
} | } | ||||
@@ -204,7 +206,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
} | } | ||||
}); | }); | ||||
for (int i = 0; i < 12; i++) { | |||||
for (int i = 0; i < 13; i++) { | |||||
if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准 | if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准 | ||||
{ | { | ||||
String value = editTextLists.get(i).getText().toString(); | String value = editTextLists.get(i).getText().toString(); | ||||
@@ -220,7 +222,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
} | } | ||||
} | } | ||||
//写开关状态 数值 | //写开关状态 数值 | ||||
for (int i = 0; i < 12; i++) { | |||||
for (int i = 0; i < 13; i++) { | |||||
String value = editTextLists.get(i).getText().toString(); | String value = editTextLists.get(i).getText().toString(); | ||||
Short val = 0; | Short val = 0; | ||||
try { | try { | ||||
@@ -241,7 +243,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList | |||||
break; | break; | ||||
case R.id.StartButton://开始校准 | case R.id.StartButton://开始校准 | ||||
//写开关状态 数值 | //写开关状态 数值 | ||||
for (int i = 0; i < 12; i++) { | |||||
for (int i = 0; i < 13; i++) { | |||||
//1.写入开关状态 | //1.写入开关状态 | ||||
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() { | DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() { | ||||
@Override | @Override | ||||
@@ -466,6 +466,45 @@ | |||||
android:thumb="@drawable/switch_custom_thumb_selector" | android:thumb="@drawable/switch_custom_thumb_selector" | ||||
android:track="@drawable/switch_custom_track_selector"/> | android:track="@drawable/switch_custom_track_selector"/> | ||||
</TableRow> | </TableRow> | ||||
<!-- Table7--> | |||||
<TableRow | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:layout_margin="5dp"> | |||||
<TextView | |||||
android:layout_marginRight="15dp" | |||||
android:text="高汤仓:" | |||||
android:textColor="@color/white" | |||||
android:textStyle="bold"/> | |||||
<EditText | |||||
android:id="@+id/passwayText_13" | |||||
android:minWidth="60dp" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginRight="15dp" | |||||
android:inputType="number|numberDecimal" | |||||
android:theme="@style/MyEditText_num" | |||||
android:maxLines="1" | |||||
android:singleLine="true" | |||||
android:textColor="@color/white" | |||||
android:backgroundTint="@color/colorAccent"/> | |||||
<Switch | |||||
android:id="@+id/Switch_13" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="校准开关 " | |||||
android:layout_marginRight="40dp" | |||||
android:textOff="关" | |||||
android:textOn="开" | |||||
android:showText="true" | |||||
android:switchTextAppearance="@style/myTextAppearance" | |||||
android:textColor="@color/white" | |||||
android:thumb="@drawable/switch_custom_thumb_selector" | |||||
android:track="@drawable/switch_custom_track_selector"/> | |||||
</TableRow> | |||||
</TableLayout> | </TableLayout> | ||||
@@ -523,7 +562,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="校准基准时间(s):" | |||||
android:textColor="@color/white" | android:textColor="@color/white" | ||||
android:textStyle="bold" | android:textStyle="bold" | ||||
android:gravity="center" | android:gravity="center" | ||||
@@ -550,7 +589,7 @@ | |||||
android:id="@+id/savetime" | android:id="@+id/savetime" | ||||
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:layout_gravity="center" | android:layout_gravity="center" | ||||
android:layout_marginLeft="5dp" | android:layout_marginLeft="5dp" | ||||
android:textColor="@color/white" | android:textColor="@color/white" | ||||
@@ -559,6 +598,7 @@ | |||||
android:background="@drawable/settingbutton"/> | android:background="@drawable/settingbutton"/> | ||||
</TableRow> | </TableRow> | ||||
<TableRow | <TableRow | ||||
android:visibility="gone" | |||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:layout_gravity="center" | android:layout_gravity="center" | ||||