@@ -677,6 +677,18 @@ public class ExecuteTheRecipe { | |||
} | |||
} | |||
/** | |||
* 获取监听变量 | |||
* @param | |||
* @return | |||
*/ | |||
public static Object getListingValue(String name) { | |||
if (!ListeningValue.containsKey(name)) { | |||
return null; | |||
} | |||
return ListeningValue.get(name); | |||
} | |||
/** | |||
* 读取状态 | |||
*/ | |||
@@ -1,8 +1,10 @@ | |||
package com.bonait.bnframework.modules.home.fragment; | |||
import android.app.Activity; | |||
import android.content.Context; | |||
import android.content.Intent; | |||
import android.graphics.Color; | |||
import android.os.Bundle; | |||
import androidx.annotation.NonNull; | |||
@@ -21,10 +23,12 @@ import android.widget.SeekBar; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.common.base.BaseFragment; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; | |||
import com.bonait.bnframework.common.db.res.StatusMode; | |||
import com.bonait.bnframework.common.helper.ByteHelper; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.I.IWriteCallBack; | |||
@@ -86,11 +90,17 @@ public class Home1Fragment extends BaseFragment { | |||
imagebutton_control zhuandong_control_left;//左转 | |||
@BindView(R.id.zhuandong_control_Rift) | |||
imagebutton_control zhuandong_control_Rift;//右转 | |||
@BindView(R.id.jb_dw) | |||
SeekBar jb_dw;// | |||
@BindView(R.id.zd_dw) | |||
SeekBar zd_dw;// | |||
@BindView(R.id.chaoguo_wendu) | |||
QMUILinkTextView chaoguo_wendu;// | |||
@BindView(R.id.chaoguo_weizhi) | |||
QMUILinkTextView chaoguo_weizhi;// | |||
@BindView(R.id.plc_zhuangtai) | |||
QMUILinkTextView plc_zhuangtai;// | |||
public boolean Status = false; | |||
/** | |||
* 当前制作商品信息 | |||
@@ -311,40 +321,88 @@ public class Home1Fragment extends BaseFragment { | |||
public void MakeThread() | |||
{ | |||
ExecuteTheRecipe.context=context; | |||
ThreadManager.Get().StartLong("商品制作线程-2023", true, new IThread() { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
if(Status && good!=null) | |||
{ | |||
try | |||
{ | |||
//获取工艺 | |||
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); | |||
for(BPA_GOODSRECIPE item:goodsrecipes) | |||
{ | |||
public void run() { | |||
while (true) { | |||
try { | |||
ExecuteTheRecipe.Execute(item); | |||
} | |||
}catch (Exception ex) | |||
{ | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
}finally { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
SetBottonStatus(false); | |||
if(Status && good!=null) | |||
{ | |||
try | |||
{ | |||
//获取工艺 | |||
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); | |||
for(BPA_GOODSRECIPE item:goodsrecipes) | |||
{ | |||
ExecuteTheRecipe.Execute(item); | |||
} | |||
}catch (Exception ex) | |||
{ | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
}finally { | |||
Activity activity=getActivity(); | |||
if(activity!=null) | |||
{ | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
SetBottonStatus(false); | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
} | |||
SxUI(); | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
ToastUtils.info("异常信息:" + e.getMessage()); | |||
} | |||
} | |||
Thread.sleep(1000); | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
}).start(); | |||
} | |||
/** | |||
* 刷新UI界面 | |||
*/ | |||
public void SxUI() | |||
{ | |||
Activity activity=getActivity(); | |||
if(activity!=null) | |||
{ | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
Object val_wd= ExecuteTheRecipe.getListingValue("当前锅底温度"); | |||
Object val_wz= ExecuteTheRecipe.getListingValue("编码器当前位值"); | |||
if(val_wd!=null) | |||
{ | |||
chaoguo_wendu.setText(val_wd+""); | |||
}else | |||
{ | |||
chaoguo_wendu.setText("未知"); | |||
} | |||
if(val_wz!=null) | |||
{ | |||
chaoguo_weizhi.setText(val_wz+""); | |||
}else | |||
{ | |||
chaoguo_weizhi.setText("未知"); | |||
} | |||
plc_zhuangtai.setText(ConfigName.getInstance().PlcIsConnect?"已连接":"断开"); | |||
plc_zhuangtai.setTextColor(ConfigName.getInstance().PlcIsConnect? Color.GREEN:Color.BLACK); | |||
SetBottonStatus(false); | |||
} | |||
}); | |||
} | |||
} | |||
/** | |||
* 设置进度条百分比 | |||
* | |||
@@ -1,5 +1,6 @@ | |||
package com.bonait.bnframework.modules.home.fragment.from.fragment; | |||
import android.app.Activity; | |||
import android.content.Context; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
@@ -83,26 +84,31 @@ public class SystemCsMonitorFragment extends BaseFragment { | |||
public void run() { | |||
while (true) { | |||
try { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
for (StatusMode item:ConfigName.getInstance().statusModes) | |||
{ | |||
item.Status= ExecuteTheRecipe.getConcurrentHash(item.sort); | |||
} | |||
jiaobandianji.setText( ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("搅拌电机"))); | |||
fanzhuandianji.setText( ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("翻转电机"))); | |||
adapter.refresh(); | |||
} catch (Exception e) { | |||
Activity activity=getActivity(); | |||
if(activity!=null) | |||
{ | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
for (StatusMode item:ConfigName.getInstance().statusModes) | |||
{ | |||
item.Status= ExecuteTheRecipe.getConcurrentHash(item.sort); | |||
} | |||
jiaobandianji.setText( ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("搅拌电机"))); | |||
fanzhuandianji.setText( ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("翻转电机"))); | |||
adapter.refresh(); | |||
} catch (Exception e) { | |||
} | |||
} | |||
} | |||
}); | |||
}); | |||
} | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
throw new RuntimeException(e); | |||
ToastUtils.info("异常信息:" + e.getMessage()); | |||
} | |||
} | |||
} | |||
@@ -59,7 +59,7 @@ public class fragment_plc extends LinearLayout { | |||
{ | |||
if (model.address.equals("-------------")) | |||
{ | |||
name.setText("\n"+model.name+":"); | |||
name.setText(model.name+":"); | |||
edittext_plc.setVisibility(View.GONE); | |||
update_plc.setVisibility(View.GONE); | |||
check_isread.setVisibility(View.GONE); | |||
@@ -67,7 +67,7 @@ public class fragment_plc_control extends LinearLayout { | |||
{ | |||
if (model.address.equals("-------------")) | |||
{ | |||
name.setText("\n"+model.name+":"); | |||
name.setText(model.name+":"); | |||
wenben.setVisibility(View.GONE); | |||
kaiguan.setVisibility(View.GONE); | |||
zhidu.setVisibility(View.GONE); | |||
@@ -87,13 +87,13 @@ public class fragment_plc_control extends LinearLayout { | |||
if(val!=null) | |||
{ | |||
control_switch.setChecked((boolean)val); | |||
if ((boolean)val) | |||
{ | |||
control_switch.setText("打开"); | |||
}else | |||
{ | |||
control_switch.setText("关闭"); | |||
} | |||
// if ((boolean)val) | |||
// { | |||
// control_switch.setText("打开"); | |||
// }else | |||
// { | |||
// control_switch.setText("关闭"); | |||
// } | |||
} | |||
} | |||
} else //文本 | |||
@@ -128,13 +128,13 @@ public class fragment_plc_control extends LinearLayout { | |||
@Override | |||
public void onClick(View view) { | |||
boolean ischick= control_switch.isChecked(); | |||
if (ischick) | |||
{ | |||
control_switch.setText("打开"); | |||
}else | |||
{ | |||
control_switch.setText("关闭"); | |||
} | |||
// if (ischick) | |||
// { | |||
// control_switch.setText("打开"); | |||
// }else | |||
// { | |||
// control_switch.setText("关闭"); | |||
// } | |||
ExecuteTheRecipe.WritePLC(model.name,ischick,null); | |||
ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭")); | |||
@@ -971,12 +971,24 @@ android:orientation="vertical"> | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:id="@+id/chaoguo_wendu" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:textSize="24dp" | |||
android:textColor="@color/red_primary" | |||
android:text="39°C"/> | |||
android:text="39"/> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:textSize="24dp" | |||
android:textColor="@color/red_primary" | |||
android:text="°C"/> | |||
</RelativeLayout> | |||
<!--边框分割细线--> | |||
@@ -1008,6 +1020,7 @@ android:orientation="vertical"> | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:id="@+id/chaoguo_weizhi" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
@@ -1016,6 +1029,44 @@ android:orientation="vertical"> | |||
android:text="10168"/> | |||
</RelativeLayout> | |||
<!--边框分割细线--> | |||
<RelativeLayout | |||
android:layout_marginLeft="5dp" | |||
android:layout_marginRight="5dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:layout_width="1dp" | |||
android:layout_height="50dp" | |||
android:layout_centerInParent="true" | |||
android:background="@color/activity_background" /> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:textSize="16dp" | |||
android:text="PLC状态"/> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:id="@+id/plc_zhuangtai" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:textSize="24dp" | |||
android:textColor="@color/teal_primary_dark" | |||
android:text="未连接"/> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
@@ -30,24 +30,29 @@ | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:visibility="gone" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:id="@+id/wenben" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<EditText | |||
android:id="@+id/edittext_plc" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入变量" | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_weight="1" | |||
android:inputType="number" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" | |||
android:text="0"/> | |||
android:layout_height="match_parent"> | |||
<EditText | |||
android:id="@+id/edittext_plc" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入变量" | |||
android:inputType="number" | |||
android:layout_centerVertical="true" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" | |||
android:text="0"/> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginLeft="10dp" | |||
@@ -73,7 +78,6 @@ | |||
</LinearLayout> | |||
<RelativeLayout | |||
android:visibility="gone" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:id="@+id/kaiguan" | |||
android:layout_width="wrap_content" | |||
@@ -82,9 +86,6 @@ | |||
android:id="@+id/control_switch" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:background="@drawable/qs_switch" | |||
android:text="关闭" | |||
android:layout_margin="5dp" | |||
android:focusable="true" | |||
/> | |||
</RelativeLayout> | |||
@@ -8,7 +8,7 @@ | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:orientation="horizontal"> | |||
<RelativeLayout | |||
android:layout_width="130dp" | |||
android:layout_width="80dp" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:id="@+id/name" | |||
@@ -17,7 +17,7 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true" | |||
android:layout_centerVertical="true" | |||
android:text=""/> | |||
android:text="料仓1号"/> | |||
</RelativeLayout> | |||
<EditText | |||