@@ -4,10 +4,10 @@ | |||
<selectionStates> | |||
<SelectionState runConfigName="app"> | |||
<option name="selectionMode" value="DROPDOWN" /> | |||
<DropdownSelection timestamp="2024-08-15T09:34:12.064478800Z"> | |||
<DropdownSelection timestamp="2024-08-19T06:05:44.263962500Z"> | |||
<Target type="DEFAULT_BOOT"> | |||
<handle> | |||
<DeviceId pluginId="Default" identifier="serial=127.0.0.1:7555;connection=ab909648" /> | |||
<DeviceId pluginId="Default" identifier="serial=127.0.0.1:7555;connection=2f03a5eb" /> | |||
</handle> | |||
</Target> | |||
</DropdownSelection> | |||
@@ -147,31 +147,31 @@ public class UdpHelper { | |||
private class ServerThread extends Thread { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
if (isRuning) { | |||
byte[] receiveData = new byte[1024]; | |||
DatagramPacket dpReceive = null; | |||
dpReceive = new DatagramPacket(receiveData, receiveData.length); | |||
try { | |||
receiveSocket.receive(dpReceive); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
String recIp = dpReceive.getAddress().toString().substring(1); | |||
String port = String.valueOf(dpReceive.getPort()); | |||
String content = ""; | |||
content = new String(receiveData, 0, dpReceive.getLength(), Charset.forName("GBK")); | |||
if (dpReceive != null) { | |||
Message revMessage = Message.obtain(); | |||
revMessage.what = 1; | |||
revMessage.obj = "收到来自" + recIp + ":" + port + "的信息:" + content; | |||
Log.i(TAG, "收到来自" + recIp + ":" + port + "的信息:" + content); | |||
if (myHandler != null) { | |||
myHandler.sendMessage(revMessage); | |||
} | |||
} | |||
} | |||
} | |||
// while (true) { | |||
// if (isRuning) { | |||
// byte[] receiveData = new byte[1024]; | |||
// DatagramPacket dpReceive = null; | |||
// dpReceive = new DatagramPacket(receiveData, receiveData.length); | |||
// try { | |||
// receiveSocket.receive(dpReceive); | |||
// } catch (IOException e) { | |||
// e.printStackTrace(); | |||
// } | |||
// String recIp = dpReceive.getAddress().toString().substring(1); | |||
// String port = String.valueOf(dpReceive.getPort()); | |||
// String content = ""; | |||
// content = new String(receiveData, 0, dpReceive.getLength(), Charset.forName("GBK")); | |||
// if (dpReceive != null) { | |||
// Message revMessage = Message.obtain(); | |||
// revMessage.what = 1; | |||
// revMessage.obj = "收到来自" + recIp + ":" + port + "的信息:" + content; | |||
// Log.i(TAG, "收到来自" + recIp + ":" + port + "的信息:" + content); | |||
// if (myHandler != null) { | |||
// myHandler.sendMessage(revMessage); | |||
// } | |||
// } | |||
// } | |||
// } | |||
} | |||
} | |||
//endregion | |||
@@ -114,6 +114,7 @@ public class HomeFragmentPR extends BaseFragment { | |||
private Context context; | |||
public Activity activity = null; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
@@ -127,11 +128,18 @@ public class HomeFragmentPR extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
context = getContext(); | |||
activity = getActivity(); | |||
isResume = true; | |||
initTopBar(); | |||
SelectTab(1); | |||
EventBus.getDefault().register(this); | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
@SuppressLint("HandlerLeak") | |||
private Handler mHandler = new Handler() { | |||
@Override | |||
@@ -162,15 +170,22 @@ public class HomeFragmentPR extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
mTopBar.removeAllRightViews(); | |||
/*mTopBar.addRightTextButton("设备状态:" + (ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"), R.id.status_image);*/ | |||
} | |||
}); | |||
if(activity!=null){ | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
mTopBar.removeAllRightViews(); | |||
mTopBar.addRightTextButton("设备状态:" + (ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"), R.id.status_image); | |||
try{ | |||
mTopBar.addRightTextButton((ConfigName.getInstance().PlcIsConnect ? activity.getString(R.string.text_deviceconnect) : activity.getString(R.string.text_devicedisconnect)), R.id.status_image); | |||
}catch (Exception e){ | |||
} | |||
} | |||
}); | |||
} | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
} | |||
@@ -7,6 +7,9 @@ import androidx.appcompat.app.AppCompatActivity; | |||
import android.app.Activity; | |||
import android.content.Context; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.text.InputType; | |||
import android.util.Log; | |||
import android.view.LayoutInflater; | |||
@@ -157,6 +160,33 @@ public class HomeFragmentSBKZ extends BaseFragment { | |||
private Context context; | |||
public Activity activity = null; | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
if(msg.what == 1){ | |||
Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度"); | |||
if (val_wd != null) { | |||
chaoguo_wendu.setText(val_wd + "°C"); | |||
} else { | |||
chaoguo_wendu.setText("??°C"); | |||
} | |||
switch (getString(R.string.language)){ | |||
case "en": | |||
plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc4 : R.mipmap.plc3); | |||
plcstatus1.setScaleType(ImageView.ScaleType.FIT_CENTER); | |||
break; | |||
case "zh": | |||
plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc1 : R.mipmap.plc2); | |||
} | |||
if(handler.hasMessages(1)){ | |||
handler.removeMessages(1); | |||
} | |||
handler.sendEmptyMessageDelayed(1,1000); | |||
} | |||
} | |||
}; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_home_sbkz, null); | |||
@@ -164,6 +194,26 @@ public class HomeFragmentSBKZ extends BaseFragment { | |||
return root; | |||
} | |||
@Override | |||
public void setUserVisibleHint(boolean isVisibleToUser) { | |||
super.setUserVisibleHint(isVisibleToUser); | |||
if(isVisibleToUser){ | |||
handler.sendEmptyMessageDelayed(1,1000); | |||
}else { | |||
if(handler!=null){ | |||
handler.removeCallbacksAndMessages(null); | |||
} | |||
} | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
if(handler!=null){ | |||
handler.removeCallbacksAndMessages(null); | |||
} | |||
} | |||
@Override | |||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
super.onViewCreated(view, savedInstanceState); | |||
@@ -355,40 +405,40 @@ public class HomeFragmentSBKZ extends BaseFragment { | |||
* 刷新UI界面 | |||
*/ | |||
public void SxUIThread() { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
try { | |||
if (activity != null && isAdded()) { | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度"); | |||
if (val_wd != null) { | |||
chaoguo_wendu.setText(val_wd + "°C"); | |||
} else { | |||
chaoguo_wendu.setText("??°C"); | |||
} | |||
switch (getString(R.string.language)){ | |||
case "en": | |||
plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc4 : R.mipmap.plc3); | |||
plcstatus1.setScaleType(ImageView.ScaleType.FIT_CENTER); | |||
break; | |||
case "zh": | |||
plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc1 : R.mipmap.plc2); | |||
} | |||
} | |||
}); | |||
} | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
ToastUtils.info("异常信息:" + e.getMessage(),"Exception message:" + e.getMessage()); | |||
} | |||
} | |||
} | |||
}).start(); | |||
// new Thread(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// while (true) { | |||
// try { | |||
// if (activity != null && isAdded()) { | |||
// activity.runOnUiThread(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度"); | |||
// if (val_wd != null) { | |||
// chaoguo_wendu.setText(val_wd + "°C"); | |||
// } else { | |||
// chaoguo_wendu.setText("??°C"); | |||
// } | |||
// switch (getString(R.string.language)){ | |||
// case "en": | |||
// plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc4 : R.mipmap.plc3); | |||
// plcstatus1.setScaleType(ImageView.ScaleType.FIT_CENTER); | |||
// break; | |||
// case "zh": | |||
// plcstatus1.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.plc1 : R.mipmap.plc2); | |||
// } | |||
// | |||
// } | |||
// }); | |||
// } | |||
// Thread.sleep(1000); | |||
// } catch (InterruptedException e) { | |||
// ToastUtils.info("异常信息:" + e.getMessage(),"Exception message:" + e.getMessage()); | |||
// } | |||
// } | |||
// } | |||
// }).start(); | |||
} | |||
@OnClick({ | |||
@@ -132,6 +132,7 @@ public class CookingActivity extends LinearLayout { | |||
private View root; | |||
public Activity activity = null; | |||
private boolean isVisible = false; | |||
//endregion | |||
@@ -143,7 +144,7 @@ public class CookingActivity extends LinearLayout { | |||
ButterKnife.bind(this, root); | |||
initTopBar(); | |||
SxUIThread(); | |||
touliao5.setVisibility(ConfigName.getInstance().is800WithFeeding?VISIBLE:GONE); | |||
} | |||
@@ -205,6 +206,8 @@ public class CookingActivity extends LinearLayout { | |||
touliao_m.setVisibility(View.VISIBLE); | |||
device_image.setImageResource(R.mipmap.device1); | |||
} | |||
isVisible = true; | |||
SxUIThread(); | |||
} | |||
/** | |||
@@ -314,6 +317,7 @@ public class CookingActivity extends LinearLayout { | |||
return; | |||
} | |||
setVisibility(View.GONE); | |||
isVisible = false; | |||
} | |||
}); | |||
} | |||
@@ -344,7 +348,7 @@ public class CookingActivity extends LinearLayout { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isVisible) { | |||
try { | |||
if (activity != null && getVisibility() == View.VISIBLE) { | |||
activity.runOnUiThread(new Runnable() { | |||
@@ -123,6 +123,8 @@ public class CookingSimulatedActivity extends BaseActivity { | |||
@BindView(R.id.showbuttomtop) | |||
RelativeLayout showbuttomtop; | |||
private boolean isResume = true; | |||
public BPA_GOODS goods = new BPA_GOODS(); | |||
public BPA_GOODS_SUBATTRIBUTE_GROUP goodsGroup = new BPA_GOODS_SUBATTRIBUTE_GROUP(); | |||
public ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes = new ArrayList<>(); | |||
@@ -136,7 +138,7 @@ public class CookingSimulatedActivity extends BaseActivity { | |||
setContentView(R.layout.activity_cookingsimulated); | |||
ButterKnife.bind(this); | |||
initTopBar(); | |||
isResume = true; | |||
Intent intent = getIntent(); | |||
String goodId = intent.getStringExtra("goodId"); | |||
String subAttributeGroupId = intent.getStringExtra("subAttributeGroupId"); | |||
@@ -158,6 +160,13 @@ public class CookingSimulatedActivity extends BaseActivity { | |||
} | |||
//endregion | |||
@Override | |||
protected void onDestroy() { | |||
super.onDestroy(); | |||
isResume = false; | |||
} | |||
//region 公共方法 | |||
/** | |||
@@ -317,7 +326,7 @@ public class CookingSimulatedActivity extends BaseActivity { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
@@ -226,12 +226,14 @@ public class DishTestActivity extends BaseActivity { | |||
//region 界面实例 | |||
private Context context; | |||
public Activity activity = null; | |||
private boolean isResume = true; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_dishtest); | |||
ButterKnife.bind(this); | |||
isResume = true; | |||
context = this; | |||
activity = this; | |||
initTopBar(); | |||
@@ -240,6 +242,13 @@ public class DishTestActivity extends BaseActivity { | |||
} | |||
//endregion | |||
@Override | |||
protected void onDestroy() { | |||
super.onDestroy(); | |||
isResume = false; | |||
} | |||
//region 私有方法 | |||
/** | |||
@@ -357,7 +366,7 @@ public class DishTestActivity extends BaseActivity { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
@@ -82,7 +82,7 @@ public class AutoTestMoreFragment extends BaseFragment { | |||
//region 界面 | |||
private Context context; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_auto_test_more, null); | |||
@@ -95,11 +95,24 @@ public class AutoTestMoreFragment extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
isResume = true; | |||
Init(); | |||
RefreshThread(); | |||
} | |||
//endregion | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
isResume =false; | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
//region 公共 | |||
/** | |||
@@ -197,7 +210,7 @@ public class AutoTestMoreFragment extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
if(IsRun) | |||
{ | |||
@@ -214,7 +227,7 @@ public class AutoTestMoreFragment extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
//故障信息 | |||
for (StatusMode item: ConfigName.getInstance().statusModes) | |||
@@ -188,7 +188,7 @@ public class AutoTestOneFragment extends BaseFragment { | |||
//region 界面 | |||
private Context context; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_auto_test_one, null); | |||
@@ -201,11 +201,25 @@ public class AutoTestOneFragment extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
isResume = true; | |||
Init(); | |||
RefreshThread(); | |||
} | |||
//endregion | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume =false; | |||
} | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
isResume=false; | |||
} | |||
//region 公共线程 | |||
public gnleft_adapter adapter = null; | |||
@@ -288,7 +302,7 @@ public class AutoTestOneFragment extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
if (ExecuteTest.IsStart) { | |||
switch (RunIndex) { | |||
@@ -327,7 +341,7 @@ public class AutoTestOneFragment extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
if (ExecuteTest.IsStart) { | |||
switch (RunIndex) { | |||
@@ -47,6 +47,7 @@ public class SystemCsMonitorFragment extends BaseFragment { | |||
private Context context; | |||
monitor_adapter adapter; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_cs_monitor, null); | |||
@@ -60,6 +61,13 @@ public class SystemCsMonitorFragment extends BaseFragment { | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
initData(); | |||
isResume = true; | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
/** | |||
@@ -86,7 +94,7 @@ public class SystemCsMonitorFragment extends BaseFragment { | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
while (isResume) { | |||
try { | |||
Activity activity=getActivity(); | |||
if(activity!=null) | |||
@@ -129,7 +129,7 @@ public class WokSetGKCXFragment extends BaseFragment { | |||
//region 界面 | |||
private Context context; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wok_set_gkcx, null); | |||
@@ -142,11 +142,19 @@ public class WokSetGKCXFragment extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
isResume = true; | |||
Init(); | |||
RefreshThread(); | |||
} | |||
//endregion | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
//region 函数 | |||
/** | |||
@@ -213,7 +221,7 @@ public class WokSetGKCXFragment extends BaseFragment { | |||
@Override | |||
public void run() { | |||
try { | |||
while (true) | |||
while (isResume) | |||
{ | |||
Object o0=ExecuteTheRecipe.ReadPLC("编码器当前位值"); | |||
Object o1=ExecuteTheRecipe.ReadPLC("原点位反馈"); | |||
@@ -84,6 +84,7 @@ public class WokSetTLZZ1Fragment extends BaseFragment { | |||
//region 界面 | |||
private Context context; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
@@ -97,11 +98,19 @@ public class WokSetTLZZ1Fragment extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
isResume = true; | |||
Init(); | |||
RefreshThread(); | |||
} | |||
//endregion | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
//region 公共 | |||
/** | |||
@@ -191,7 +200,7 @@ public class WokSetTLZZ1Fragment extends BaseFragment { | |||
@Override | |||
public void run() { | |||
try { | |||
while (true) { | |||
while (isResume) { | |||
Object o0 = ExecuteTheRecipe.ReadPLC("翻转1-伺服当前值"); | |||
Object o1 = ExecuteTheRecipe.ReadPLC("翻转1-1号位置值"); | |||
Object o2 = ExecuteTheRecipe.ReadPLC("翻转1-2号位置值"); | |||
@@ -99,6 +99,7 @@ public class WokSetTLZZFragment extends BaseFragment { | |||
//region 界面 | |||
private Context context; | |||
private boolean isResume = true; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wok_set_tlzz, null); | |||
@@ -111,11 +112,19 @@ public class WokSetTLZZFragment extends BaseFragment { | |||
super.onViewCreated(view, savedInstanceState); | |||
Logger.d("我的fragment创建"); | |||
context = getContext(); | |||
isResume = true; | |||
Init(); | |||
RefreshThread(); | |||
} | |||
//endregion | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
isResume = false; | |||
} | |||
//region 公共 | |||
/** | |||
@@ -205,7 +214,7 @@ public class WokSetTLZZFragment extends BaseFragment { | |||
@Override | |||
public void run() { | |||
try { | |||
while (true) { | |||
while (isResume) { | |||
Object o0 = ExecuteTheRecipe.ReadPLC("平移-伺服当前值"); | |||
Object o1 = ExecuteTheRecipe.ReadPLC("平移-1号位置值"); | |||
Object o2 = ExecuteTheRecipe.ReadPLC("平移-2号位置值"); | |||
@@ -462,18 +462,6 @@ public class DisplayManager | |||
} | |||
} | |||
/** | |||
* 判断是否需要缩放 避免adapter重绘时多次缩放 | |||
* @param view | |||
* @return | |||
*/ | |||
public static boolean shouldScale(TextView view){ | |||
if(view.getTextSize()> 40 || view.getTextSize()< 36){ | |||
return true; | |||
} | |||
return false; | |||
} | |||
public static void scaleViewRemote(View view) | |||
{ | |||
scaleView(view,(float) mfDeviceScaleRate); | |||