📄 timecontrol.java
字号:
package net.aetherial.gis.surface;
import net.aetherial.gis.garmin.ConsoleFrame;
import net.aetherial.gis.garmin.DialogSelectComm;
import javax.swing.JOptionPane;
import javax.comm.SerialPort;
import net.aetherial.gis.garmin.LinkPacketConnection;
import net.aetherial.gis.garmin.GarminConfiguration;
public class TimeControl extends Thread{
FrameMain fm =null;
boolean isWaypoint;
Thread t;
public TimeControl(FrameMain fm,boolean isWaypoint,Thread t){
this.fm = fm;
this.isWaypoint =isWaypoint;
this.setName("TimeControl Thread int dowloadData");
this.t =t;
}
public void run() {
this.control(1000);
}
void control(int timeout) {
Thread cThread = Thread.currentThread();
ItemValue.RecieveCount = 0;
String error_message =
"本次操作没有在指定端口获得数据,请按如下步骤进行:\n"+
"1. 检查设备是否开机,电池电量是否充足;\n"+
"2. 请检查数据连接线和是否连接好(如果使用了USB转换线请一起检查);\n"+
"3. 指定其它端口再试一次;\n"+
"4. 如问题依然存在请尽快根据帮助信息中的联系电话与技术人员联系;";
try {
cThread.sleep(timeout);
if (ItemValue.RecieveCount==0) {
ItemValue.deadThread = true;
GarminConfiguration.destroy();
t.stop();
ItemValue.ttyS.close();
ItemValue.ttyS = null;
ConsoleFrame.noInitialize = true;
fm.setButton1_2Enabled(true);
JOptionPane.showMessageDialog(fm, error_message);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
class DowloadDataRun extends Thread{
FrameMain fm = null;
boolean isWaypoint;
ConsoleFrame cf = new ConsoleFrame();
DowloadDataRun(FrameMain fm,boolean isWaypoint){
this.fm = fm;
this.isWaypoint = isWaypoint;
}
public void run() {
//ItemValue.data =0;
if (isWaypoint == true) {//download waypoint
fm.setButton1_2Enabled(false);
cf.downloadWaypoint();
fm.setButton1_2Enabled(true);
if (ItemValue.tracksNum == 0) {
ItemValue.waypointPre = true;
}
//fm.insertGPSText();
fm.dataSave = false;
}
else {//download waypoint and tracks
fm.setButton1_2Enabled(false);
if (ItemValue.waypointNum == 0) {
cf.downloadWaypoint();
}
cf.downloadTracks();
fm.setButton1_2Enabled(true);
if (ItemValue.waypointNum == 0) {
ItemValue.waypointPre = true;
}
//fm.insertGPSText();
fm.dataSave = false;
}
fm.memoryShow();
}
}
class TestComm extends Thread{
ConsoleFrame cf = new ConsoleFrame();
TestComm(ConsoleFrame cf){
this.cf = cf;
}
public void run(){
cf.testComm();
}
}
class DownloadData extends Thread{
FrameMain fm =null;
boolean isWpt;
public DownloadData(FrameMain fm,boolean isWpt){
this.fm =fm;
this.isWpt =isWpt;
}
public void run(){
//fm.setButton1_2Enabled(false);
download(isWpt);
//fm.setButton1_2Enabled(true);
}
void download(boolean isWpt){
DialogSelectComm.setPortEnable();
if(ItemValue.comm==null){
JOptionPane.showMessageDialog(fm,"没有检测到可用的端口,请检查有没有安装好COM端口.");
}else{
DowloadDataRun tc = new DowloadDataRun(fm, isWpt);
TimeControl dd = new TimeControl(fm, isWpt, tc);
tc.start();
dd.start();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -