kopia lustrzana https://github.com/N0BOY/FT8CN
Delete ft8cn/app/src/main/java/com/bg7yoz/ft8cn directory
rodzic
db5c112690
commit
7d046a0a5e
|
@ -1,5 +0,0 @@
|
|||
package com.bg7yoz.ft8cn.database;
|
||||
|
||||
public interface AfterInsertQSLData {
|
||||
void doAfterInsert(boolean isInvalid,boolean isNewQSL);
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package com.bg7yoz.ft8cn.html;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.bg7yoz.ft8cn.GeneralVariables;
|
||||
import com.bg7yoz.ft8cn.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ImportTaskList extends HashMap<Integer, ImportTaskList.ImportTask> {
|
||||
|
||||
/**
|
||||
* 获取上传的任务,以session为key
|
||||
*
|
||||
* @param session session
|
||||
* @return 任务的HTML
|
||||
*/
|
||||
public String getTaskHTML(int session) {
|
||||
ImportTask task = this.get(session);
|
||||
if (task == null) {
|
||||
return GeneralVariables.getStringFromResource(R.string.null_task_html);
|
||||
}
|
||||
return task.getHtml();
|
||||
}
|
||||
public void cancelTask(int session){
|
||||
ImportTask task = this.get(session);
|
||||
if (task != null) {
|
||||
task.setStatus(ImportState.CANCELED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查任务是不是在运行。
|
||||
*
|
||||
* @param session 任务ID
|
||||
* @return false 没有任务或任务结束
|
||||
*/
|
||||
public boolean checkTaskIsRunning(int session) {
|
||||
ImportTask task = this.get(session);
|
||||
if (task == null) {
|
||||
return false;
|
||||
} else {
|
||||
return task.status == ImportState.STARTING || task.status == ImportState.IMPORTING;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务到列表,要确保线程安全
|
||||
*
|
||||
* @param session session
|
||||
* @param task 任务
|
||||
*/
|
||||
public synchronized ImportTask addTask(int session, ImportTask task) {
|
||||
this.put(session, task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public ImportTask addTask(int session) {
|
||||
return addTask(session, new ImportTask(session));
|
||||
}
|
||||
|
||||
|
||||
enum ImportState {
|
||||
STARTING, IMPORTING, FINISHED, CANCELED
|
||||
}
|
||||
|
||||
public static class ImportTask {
|
||||
|
||||
|
||||
int session;//session,用于记录上传会话,是一个hash
|
||||
public int count = 0;//解析出总的数据量
|
||||
public int importedCount = 0;//导入的数量
|
||||
public int readErrorCount = 0;//读取数据错误数量
|
||||
public int processCount = 0;
|
||||
public int updateCount = 0;//更新的数量
|
||||
public int invalidCount = 0;//无效的QSL
|
||||
public int newCount = 0;//新导入的数量
|
||||
public ImportState status = ImportState.STARTING;//状态:0:开始,1:运行,2:结束,3:取消
|
||||
String message = "";//任务消息描述
|
||||
String errorMsg = "";
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public String getHtml() {
|
||||
String htmlHeader = "<table bgcolor=#a1a1a1 border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
|
||||
String htmlEnder = "</table>\n";
|
||||
String progress = String.format("<FONT COLOR=\"BLUE\">%s %.1f%%(%d/%d)</FONT>\n", GeneralVariables.getStringFromResource(R.string.import_progress_html)
|
||||
, count == 0 ? 0 : processCount * 100f / count, processCount, count);
|
||||
String cell = "<tr><td>%s</td></tr>\n";
|
||||
String errorHtml = status == ImportState.FINISHED || status == ImportState.CANCELED ? errorMsg : "";
|
||||
String doCancelButton = status == ImportState.FINISHED || status == ImportState.CANCELED ? ""
|
||||
: String.format("<br><a href=\"cancelTask?session=%d\"><button>%s</button></a><br>"
|
||||
, session,GeneralVariables.getStringFromResource(R.string.import_cancel_button));
|
||||
return htmlHeader
|
||||
+ String.format(cell, progress)
|
||||
+ String.format(cell, String.format(GeneralVariables.getStringFromResource(R.string.import_read_error_count_html), readErrorCount))
|
||||
+ String.format(cell, String.format(GeneralVariables.getStringFromResource(R.string.import_new_count_html), newCount))
|
||||
+ String.format(cell, String.format(GeneralVariables.getStringFromResource(R.string.import_update_count_html), updateCount))
|
||||
+ String.format(cell, String.format(GeneralVariables.getStringFromResource(R.string.import_invalid_count_html), invalidCount))
|
||||
+ String.format(cell, String.format(GeneralVariables.getStringFromResource(R.string.import_readed_html), importedCount))
|
||||
+ String.format(cell, message)
|
||||
+ String.format(cell, errorHtml)
|
||||
+ htmlEnder
|
||||
+ doCancelButton;
|
||||
}
|
||||
|
||||
public ImportTask(int session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public void setStatus(ImportState status) {
|
||||
this.status = status;
|
||||
setStateMSG(status);
|
||||
}
|
||||
|
||||
private void setStateMSG(ImportState state) {
|
||||
switch (state) {
|
||||
case IMPORTING:
|
||||
this.message = String.format("<FONT COLOR=\"BLUE\"><B>%s</B></FONT>"
|
||||
,GeneralVariables.getStringFromResource(R.string.log_importing_html));
|
||||
break;
|
||||
case FINISHED:
|
||||
this.message = String.format("<FONT COLOR=\"GREEN\"><B>%s</B></FONT>"
|
||||
,GeneralVariables.getStringFromResource(R.string.log_import_finished_html));
|
||||
break;
|
||||
case CANCELED:
|
||||
this.message = String.format("<FONT COLOR=\"RED\"><B>%s</B></FONT>"
|
||||
,GeneralVariables.getStringFromResource(R.string.import_canceled_html));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
package com.bg7yoz.ft8cn.rigs;
|
||||
|
||||
import static com.bg7yoz.ft8cn.GeneralVariables.QUERY_FREQ_TIMEOUT;
|
||||
import static com.bg7yoz.ft8cn.GeneralVariables.START_QUERY_FREQ_DELAY;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.bg7yoz.ft8cn.GeneralVariables;
|
||||
import com.bg7yoz.ft8cn.R;
|
||||
import com.bg7yoz.ft8cn.database.ControlMode;
|
||||
import com.bg7yoz.ft8cn.ui.ToastMessage;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* wolf 的cat指令集兼容yaesu 450d,但是有的ham在实际测试中发现,450d默认是dig-u,此模式在wolf上测试无法满功率发射,
|
||||
* 而采用usb模式就可以满功率发射,故增加一个usb模式的选项
|
||||
* 在创建rig时,用布尔参数是否时USB模式
|
||||
*/
|
||||
public class Wolf_sdr_450Rig extends BaseRig {
|
||||
private static final String TAG = "Wolf_sdr_450Rig";
|
||||
private final StringBuilder buffer = new StringBuilder();
|
||||
private int swr = 0;
|
||||
private int alc = 0;
|
||||
private boolean alcMaxAlert = false;
|
||||
private boolean swrAlert = false;
|
||||
|
||||
private Timer readFreqTimer = new Timer();
|
||||
private boolean isUsbMode=true;
|
||||
|
||||
private TimerTask readTask() {
|
||||
return new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!isConnected()) {
|
||||
readFreqTimer.cancel();
|
||||
readFreqTimer.purge();
|
||||
readFreqTimer = null;
|
||||
return;
|
||||
}
|
||||
if (isPttOn()) {
|
||||
readMeters();
|
||||
} else {
|
||||
readFreqFromRig();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFreq error:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 读取Meter RM;
|
||||
*/
|
||||
private void readMeters() {
|
||||
if (getConnector() != null) {
|
||||
clearBufferData();//清空一下缓存
|
||||
getConnector().sendData(Yaesu3RigConstant.setRead39Meters_ALC());
|
||||
getConnector().sendData(Yaesu3RigConstant.setRead39Meters_SWR());
|
||||
}
|
||||
}
|
||||
|
||||
private void showAlert() {
|
||||
if (swr >= Yaesu3RigConstant.swr_39_alert_max) {
|
||||
if (!swrAlert) {
|
||||
swrAlert = true;
|
||||
ToastMessage.show(GeneralVariables.getStringFromResource(R.string.swr_high_alert));
|
||||
}
|
||||
} else {
|
||||
swrAlert = false;
|
||||
}
|
||||
if (alc > Yaesu3RigConstant.alc_39_alert_max) {//网络模式下不警告ALC
|
||||
if (!alcMaxAlert) {
|
||||
alcMaxAlert = true;
|
||||
ToastMessage.show(GeneralVariables.getStringFromResource(R.string.alc_high_alert));
|
||||
}
|
||||
} else {
|
||||
alcMaxAlert = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
private void clearBufferData() {
|
||||
buffer.setLength(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPTT(boolean on) {
|
||||
super.setPTT(on);
|
||||
if (getConnector() != null) {
|
||||
switch (getControlMode()) {
|
||||
case ControlMode.CAT://以CIV指令
|
||||
getConnector().setPttOn(Yaesu3RigConstant.setPTT_TX_On(on));//针对YAESU 450指令
|
||||
break;
|
||||
case ControlMode.RTS:
|
||||
case ControlMode.DTR:
|
||||
getConnector().setPttOn(on);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
if (getConnector() == null) {
|
||||
return false;
|
||||
}
|
||||
return getConnector().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsbModeToRig() {
|
||||
if (getConnector() != null) {
|
||||
//getConnector().sendData(Yaesu3RigConstant.setOperationDATA_U_Mode());
|
||||
//getConnector().sendData(Yaesu3RigConstant.setOperationUSB_Data_Mode());
|
||||
if (isUsbMode) {//usb模式
|
||||
getConnector().sendData(Yaesu3RigConstant.setOperationUSBMode());
|
||||
}else {//dig-u模式
|
||||
getConnector().sendData(Yaesu3RigConstant.setOperationDATA_U_Mode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreqToRig() {
|
||||
if (getConnector() != null) {
|
||||
getConnector().sendData(Yaesu3RigConstant.setOperationFreq8Byte(getFreq()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveData(byte[] data) {
|
||||
String s = new String(data);
|
||||
//ToastMessage.showDebug("39 YAESU 读数据:"+new String(Yaesu3RigConstant.setReadOperationFreq()));
|
||||
|
||||
if (!s.contains(";")) {
|
||||
buffer.append(s);
|
||||
if (buffer.length()>1000) clearBufferData();
|
||||
//return;//说明数据还没接收完。
|
||||
} else {
|
||||
if (s.indexOf(";") > 0) {//说明接到结束的数据了,并且不是第一个字符是;
|
||||
buffer.append(s.substring(0, s.indexOf(";")));
|
||||
}
|
||||
|
||||
//开始分析数据
|
||||
Yaesu3Command yaesu3Command = Yaesu3Command.getCommand(buffer.toString());
|
||||
clearBufferData();//清一下缓存
|
||||
//要把剩下的数据放到缓存里
|
||||
buffer.append(s.substring(s.indexOf(";") + 1));
|
||||
|
||||
if (yaesu3Command == null) {
|
||||
return;
|
||||
}
|
||||
//long tempFreq = Yaesu3Command.getFrequency(yaesu3Command);
|
||||
//if (tempFreq != 0) {//如果tempFreq==0,说明频率不正常
|
||||
// setFreq(Yaesu3Command.getFrequency(yaesu3Command));
|
||||
//}
|
||||
|
||||
if (yaesu3Command.getCommandID().equalsIgnoreCase("FA")
|
||||
|| yaesu3Command.getCommandID().equalsIgnoreCase("FB")) {
|
||||
long tempFreq = Yaesu3Command.getFrequency(yaesu3Command);
|
||||
if (tempFreq != 0) {//如果tempFreq==0,说明频率不正常
|
||||
setFreq(Yaesu3Command.getFrequency(yaesu3Command));
|
||||
}
|
||||
} else if (yaesu3Command.getCommandID().equalsIgnoreCase("RM")) {//METER
|
||||
if (Yaesu3Command.isSWRMeter38(yaesu3Command)) {
|
||||
swr = Yaesu3Command.getALCOrSWR38(yaesu3Command);
|
||||
}
|
||||
if (Yaesu3Command.isALCMeter38(yaesu3Command)) {
|
||||
alc = Yaesu3Command.getALCOrSWR38(yaesu3Command);
|
||||
}
|
||||
showAlert();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFreqFromRig() {
|
||||
if (getConnector() != null) {
|
||||
clearBufferData();//清空一下缓存
|
||||
getConnector().sendData(Yaesu3RigConstant.setReadOperationFreq());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "WOLF SDR";
|
||||
}
|
||||
|
||||
public Wolf_sdr_450Rig(boolean usbMode) {
|
||||
isUsbMode=usbMode;
|
||||
readFreqTimer.schedule(readTask(), START_QUERY_FREQ_DELAY,QUERY_FREQ_TIMEOUT);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue