|
@@ -1,566 +0,0 @@
|
|
|
-package com.wdkl.ncs.s433.receiver.led;
|
|
|
-
|
|
|
-import android.app.Application;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.util.Log;
|
|
|
-
|
|
|
-import com.listenvision.LedC2M;
|
|
|
-import com.listenvision.model.VoiceModel;
|
|
|
-import com.wdkl.ncs.s433.receiver.MyApplication;
|
|
|
-import com.wdkl.ncs.s433.receiver.common.Constants;
|
|
|
-import com.wdkl.ncs.s433.receiver.settingconfig.SettingConfig;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.net.DatagramPacket;
|
|
|
-import java.net.DatagramSocket;
|
|
|
-import java.net.InetAddress;
|
|
|
-import java.net.Socket;
|
|
|
-import java.net.SocketException;
|
|
|
-import java.net.UnknownHostException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Locale;
|
|
|
-import java.util.TimerTask;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-import java.util.concurrent.ScheduledExecutorService;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-
|
|
|
-public class LedC2MManager extends LedManager {
|
|
|
- private static final String TAG = "ledC2M";
|
|
|
-
|
|
|
- private Application application;
|
|
|
- private LedC2M ledC2M;
|
|
|
- private static ArrayList<LedItem> ledList = new ArrayList<>();
|
|
|
- private static List<LedProgram> programTextList = new ArrayList<>();
|
|
|
- private static List<String> voiceProgramList = new ArrayList<>();
|
|
|
- private static String voiceText;
|
|
|
- private static String deleteVoiceText;
|
|
|
- private static boolean stopVoice = false;
|
|
|
-
|
|
|
- private static long LED_TIMEOUT = 5*60*1000L;
|
|
|
-
|
|
|
- private final static Object lockObject = new Object();
|
|
|
-
|
|
|
- @Override
|
|
|
- public void init(Application application) {
|
|
|
- ledC2M = new LedC2M();
|
|
|
- ledC2M.init(application);
|
|
|
- this.application = application;
|
|
|
- File file = new File(Constants.C2M_LED_FONT_PATH);
|
|
|
- if (file.exists()) {
|
|
|
- Constants.ledFontExist = true;
|
|
|
- } else {
|
|
|
- copyFont();
|
|
|
- }
|
|
|
-
|
|
|
- //initScheduledExecutor();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void copyFont() {
|
|
|
- super.copyFont();
|
|
|
- if (ledC2M != null) {
|
|
|
- ledC2M.copyFontFile(new LedC2M.LedFontCheck() {
|
|
|
- @Override
|
|
|
- public void onChecked(boolean check) {
|
|
|
- Constants.ledFontExist = check;
|
|
|
- Log.d(TAG, "led font copy end...");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void initScheduledExecutor() {
|
|
|
- TimerTask timerTask = new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (lockObject) {
|
|
|
- //每分钟查询一次点阵屏节目,超过5分钟的将自动移除
|
|
|
- Iterator<LedProgram> iterator = programTextList.iterator();
|
|
|
- long curTime = System.currentTimeMillis();
|
|
|
- boolean update = false;
|
|
|
- while (iterator.hasNext()) {
|
|
|
- if (curTime - iterator.next().getTime() > LED_TIMEOUT) {
|
|
|
- iterator.remove();
|
|
|
- update = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (update) {
|
|
|
- sendProgramStart();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
|
|
- executor.scheduleAtFixedRate(timerTask,60,90, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initIpList() {
|
|
|
- getLedDeviceIpList();
|
|
|
- }
|
|
|
-
|
|
|
- private void getLedDeviceIpList() {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setLedIpList(ArrayList<LedItem> list) {
|
|
|
- ledList.clear();
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
- ledList.addAll(list);
|
|
|
- }
|
|
|
-
|
|
|
- powerOnOff(true);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ArrayList<LedItem> getLedList() {
|
|
|
- return ledList;
|
|
|
- }
|
|
|
-
|
|
|
- private final ExecutorService updateThreadPool = Executors.newSingleThreadExecutor();
|
|
|
- private SendProgramThread programThread;
|
|
|
-
|
|
|
- //语音节目udp
|
|
|
- private void sendVoiceUdp(String ip) {
|
|
|
- int server_port = 9999;
|
|
|
- String text = "";
|
|
|
- byte[] data;
|
|
|
-
|
|
|
- if (stopVoice) {
|
|
|
- data = VoiceModel.getStopVoiceData();
|
|
|
- } else {
|
|
|
- text = voiceText;
|
|
|
- for (int j = 0; j < 2; j++) {
|
|
|
- text = text + "," + voiceText;
|
|
|
- }
|
|
|
- data = VoiceModel.getVoiceData(text);
|
|
|
- }
|
|
|
-
|
|
|
- DatagramSocket s = null;
|
|
|
- try {
|
|
|
- s = new DatagramSocket();
|
|
|
- } catch (SocketException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- InetAddress local = null;
|
|
|
- try {
|
|
|
- local = InetAddress.getByName(ip);
|
|
|
- } catch (UnknownHostException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- if (data != null) {
|
|
|
- Log.d(TAG, "udp send voice text: " + voiceText + ", voice data hex string: " + VoiceModel.bytesToHexString(data));
|
|
|
- DatagramPacket p = new DatagramPacket(data, data.length, local,
|
|
|
- server_port);
|
|
|
- try {
|
|
|
- s.send(p);
|
|
|
- s.close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //语音节目-tcp
|
|
|
- private void sendVoiceTcp(String ip) {
|
|
|
- try {
|
|
|
- byte[] data;
|
|
|
- String text = "";
|
|
|
-
|
|
|
- if (stopVoice) {
|
|
|
- data = VoiceModel.getStopVoiceData();
|
|
|
- } else {
|
|
|
- text = voiceText;
|
|
|
- int loop = SettingConfig.getLedVoiceTimes(MyApplication.getContext()) - 1;
|
|
|
- for (int j = 0; j < loop; j++) {
|
|
|
- text = text + "," + voiceText;
|
|
|
- }
|
|
|
- String volume = Integer.toString(SettingConfig.getLedVoiceVolume(MyApplication.getContext()));
|
|
|
- text = "[v" + volume +"]" + text;
|
|
|
- data = VoiceModel.getVoiceData(text);
|
|
|
- }
|
|
|
-
|
|
|
- Socket socket = new Socket(ip, 10000);
|
|
|
- OutputStream outputStream = socket.getOutputStream();
|
|
|
- Log.d(TAG, "socket connect: " + socket.isConnected());
|
|
|
-
|
|
|
- if (socket.isConnected() && data != null) {
|
|
|
- Log.d(TAG, "tcp send voice text: " + voiceText + ", voice data hex string: " + VoiceModel.bytesToHexString(data));
|
|
|
- outputStream.write(data);
|
|
|
- socket.close();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //文字节目
|
|
|
- public class SendProgramThread implements Runnable {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- //开始组建节目: 如果字体文件不存在则直接返回
|
|
|
- if (!Constants.ledFontExist) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ledList.size() == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- int infoType = SettingConfig.getLedInfoType(application);
|
|
|
- if (programTextList.size() == 0) {
|
|
|
- //默认节目
|
|
|
- for (LedItem ledItem : ledList) {
|
|
|
- if (ledItem != null) {
|
|
|
- //停止语音
|
|
|
- stopVoice = true;
|
|
|
- long h = createDefaultProgram(ledItem.getResolution(), ledItem.getFontSize(), infoType, 3);
|
|
|
- if (h != 0) {
|
|
|
- int result = ledC2M.NetWorkSend(ledItem.getIp(), h);
|
|
|
- //语音节目
|
|
|
- if (ledItem.getVoiceOn()) {
|
|
|
- sendVoiceTcp(ledItem.getIp());
|
|
|
- }
|
|
|
-
|
|
|
- Log.d(TAG, "send default program to " + ledItem.getIp() + ", result: " + result);
|
|
|
- ledC2M.DeleteProgram(h);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //呼叫信息节目
|
|
|
- //当前正在播放的语音和将要移除的语音相同
|
|
|
- if (voiceProgramList.size() > 0) {
|
|
|
- voiceText = voiceProgramList.get(0);
|
|
|
- if (voiceText.equals(deleteVoiceText)) {
|
|
|
- stopVoice = true;
|
|
|
- } else {
|
|
|
- stopVoice = false;
|
|
|
- }
|
|
|
- voiceProgramList.remove(voiceText);
|
|
|
- } else {
|
|
|
- stopVoice = true;
|
|
|
- }
|
|
|
- Log.d(TAG, "voiceText: " + voiceText + ", deleteVoiceText: " + deleteVoiceText);
|
|
|
-
|
|
|
- for (LedItem ledItem : ledList) {
|
|
|
- if (ledItem != null) {
|
|
|
- long h = createCallingProgram(ledItem.getResolution(), ledItem.getFontSize());
|
|
|
- if (h != 0) {
|
|
|
- int result = ledC2M.NetWorkSend(ledItem.getIp(), h);
|
|
|
- //语音节目
|
|
|
- if (ledItem.getVoiceOn()) {
|
|
|
- sendVoiceTcp(ledItem.getIp());
|
|
|
- }
|
|
|
-
|
|
|
- Log.d(TAG, "send calling program to " + ledItem.getIp() + ", result: " + result);
|
|
|
- ledC2M.DeleteProgram(h);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private long createDefaultProgram(String ledResolution, int fontSize, int type, int savaType) {
|
|
|
- long hProgram = 0;
|
|
|
- String language = "zh";
|
|
|
- if (type == 0) {
|
|
|
- //仅显示时间
|
|
|
- if (LedItem.TYPE_64_16.equals(ledResolution)) {
|
|
|
- //64x16
|
|
|
- hProgram = ledC2M.CreateProgram(64, 16, 1,1,savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
-
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 64, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 0, 0, 0, 0, 1, 1, 0,
|
|
|
- 0, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- } else {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 64, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 0, 0, 0, 0, 1, 1, 0,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- }
|
|
|
- } else if (LedItem.TYPE_128_16.equals(ledResolution)) {
|
|
|
- //128x16
|
|
|
- hProgram = ledC2M.CreateProgram(128, 16, 1,1,savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 0,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 0);
|
|
|
- } else {
|
|
|
- //默认为128x32
|
|
|
- hProgram = ledC2M.CreateProgram(128, 32, 1,1, savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 32, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 1,
|
|
|
- 0, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- } else {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 32, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 1,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (type == 1) {
|
|
|
- //显示时间和自定义内容
|
|
|
- String text = SettingConfig.getLedCustomInfo(application);
|
|
|
- if (LedItem.TYPE_64_16.equals(ledResolution)) {
|
|
|
- //64x16
|
|
|
- hProgram = ledC2M.CreateProgram(64, 16, 1,1,savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 64, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 0, 0, 0, 0, 1, 1, 0,
|
|
|
- 0, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- } else {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 64, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 0, 0, 0, 0, 1, 1, 0,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- }
|
|
|
-
|
|
|
- if (!TextUtils.isEmpty(text)) {
|
|
|
- ledC2M.AddProgram(hProgram, 1, 10, 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, 1, 1, 0, 0, 64, 16, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, 1, 1, 0, text, Constants.C2M_LED_FONT_PATH, 16, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- } else if (LedItem.TYPE_128_16.equals(ledResolution)){
|
|
|
- //128x16
|
|
|
- hProgram = ledC2M.CreateProgram(128, 16, 1,1,savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 16, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 0,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 0);
|
|
|
- if (!TextUtils.isEmpty(text)) {
|
|
|
- ledC2M.AddProgram(hProgram, 1, 10, 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, 1, 1, 0, 0, 128, 16, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, 1, 1, 0, text, Constants.C2M_LED_FONT_PATH, fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //128x32
|
|
|
- hProgram = ledC2M.CreateProgram(128, 32, 1,1,savaType);
|
|
|
- ledC2M.AddProgram(hProgram, 0, 10, 1);
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 32, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 1,
|
|
|
- 0, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- } else {
|
|
|
- ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 128, 32, Constants.C2M_LED_FONT_PATH,
|
|
|
- 16, 0xff, 0, 0, 0,
|
|
|
- 1, 0, 1, 1, 1, 1, 1,
|
|
|
- 4, 0xff, 0, 0xff, 2, 0xff, 1);
|
|
|
- }
|
|
|
-
|
|
|
- if (!TextUtils.isEmpty(text)) {
|
|
|
- ledC2M.AddProgram(hProgram, 1, 10, 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, 1, 1, 0, 0, 128, 32, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, 1, 1, 0, text, Constants.C2M_LED_FONT_PATH, fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return hProgram;
|
|
|
- }
|
|
|
-
|
|
|
- private long createCallingProgram(String ledResolution, int fontSize) {
|
|
|
- long hProgram = 0;
|
|
|
- if (LedItem.TYPE_64_16.equals(ledResolution)) {
|
|
|
- //64x16
|
|
|
- hProgram = ledC2M.CreateProgram(64, 16, 1, 1, 3);
|
|
|
- for (int i = 0; i < programTextList.size(); i++) {
|
|
|
- String text = programTextList.get(i).getText();
|
|
|
- ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(MyApplication.getContext()), 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 64, 16, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, text, Constants.C2M_LED_FONT_PATH, 16, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- } else if (LedItem.TYPE_128_16.equals(ledResolution)){
|
|
|
- //128x16
|
|
|
- hProgram = ledC2M.CreateProgram(128, 16, 1, 1, 3);
|
|
|
- for (int i = 0; i < programTextList.size(); i++) {
|
|
|
- ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(MyApplication.getContext()), 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 16, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.C2M_LED_FONT_PATH, fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //128x32
|
|
|
- hProgram = ledC2M.CreateProgram(128, 32, 1, 1, 3);
|
|
|
- for (int i = 0; i < programTextList.size(); i++) {
|
|
|
- ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(MyApplication.getContext()), 1);
|
|
|
- ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 32, 0);
|
|
|
- ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.C2M_LED_FONT_PATH, fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return hProgram;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //更新节目方法: text -- 节目内容,action -- 方式: 1-发送节目,2-删除节目
|
|
|
- @Override
|
|
|
- public synchronized void updateProgram(String text, int action) {
|
|
|
- synchronized (lockObject) {
|
|
|
- if (text == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- switch (action) {
|
|
|
- case 1:
|
|
|
- //先查找列表中是否存在该节目,存在则删除
|
|
|
- Iterator<LedProgram> iterator = programTextList.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- if (text.equals(iterator.next().getText())) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- LedProgram ledProgram = new LedProgram(text, System.currentTimeMillis());
|
|
|
- programTextList.add(0, ledProgram);
|
|
|
- voiceProgramList.add(0, text);
|
|
|
- deleteVoiceText = "";
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- boolean deleted = false;
|
|
|
- Iterator<LedProgram> iterator2 = programTextList.iterator();
|
|
|
- while (iterator2.hasNext()) {
|
|
|
- if (text.equals(iterator2.next().getText())) {
|
|
|
- iterator2.remove();
|
|
|
- deleteVoiceText = text;
|
|
|
- deleted = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!deleted) {
|
|
|
- return;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- //清屏
|
|
|
- programTextList.clear();
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- sendProgramStart();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void sendProgramStart() {
|
|
|
- if (programThread == null) {
|
|
|
- programThread = new SendProgramThread();
|
|
|
- }
|
|
|
- updateThreadPool.execute(programThread);
|
|
|
- }
|
|
|
-
|
|
|
- private void sendDefaultProgram(final boolean needReboot) {
|
|
|
- //停止语音
|
|
|
- stopVoice = true;
|
|
|
-
|
|
|
- new Thread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (lockObject) {
|
|
|
- //如果字体文件不存在则直接返回
|
|
|
- if (!Constants.ledFontExist) {
|
|
|
- Log.e(TAG, "Nooooooo ledFontExist!");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ledList.size() == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- int infoType = SettingConfig.getLedInfoType(application);
|
|
|
- for (LedItem ledItem : ledList) {
|
|
|
- if (ledItem != null) {
|
|
|
- long h = createDefaultProgram(ledItem.getResolution(), ledItem.getFontSize(), infoType, 0);
|
|
|
- if (h != 0) {
|
|
|
- int result = ledC2M.NetWorkSend(ledItem.getIp(), h);
|
|
|
- //语音节目
|
|
|
- //if (Constants.Companion.getLedVoiceOn() == 1) {
|
|
|
- // sendVoiceTcp(ledItem.getIp());
|
|
|
- //}
|
|
|
-
|
|
|
- Log.d(TAG, "send default program to " + ledItem.getIp() + ", result: " + result);
|
|
|
- ledC2M.DeleteProgram(h);
|
|
|
- }
|
|
|
-
|
|
|
- if (needReboot) {
|
|
|
- ledC2M.PowerOnOff(ledItem.getIp(), 2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }).start();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateDefaultProgram() {
|
|
|
- //无呼叫节目时更新默认节目
|
|
|
- if (programTextList.size() == 0) {
|
|
|
- sendDefaultProgram(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void removeAllProgram(boolean reboot) {
|
|
|
- programTextList.clear();
|
|
|
- sendDefaultProgram(reboot);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void syncTime() {
|
|
|
- new Thread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (lockObject) {
|
|
|
- for (int i = 0; i < ledList.size(); i++) {
|
|
|
- ledC2M.AdjustTime(ledList.get(i).getIp());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }).start();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void powerOnOff(final boolean powerOn) {
|
|
|
- new Thread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (lockObject) {
|
|
|
- if (powerOn) {
|
|
|
- for (int i = 0; i < ledList.size(); i++) {
|
|
|
- ledC2M.PowerOnOff(ledList.get(i).getIp(), 0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int i = 0; i < ledList.size(); i++) {
|
|
|
- ledC2M.PowerOnOff(ledList.get(i).getIp(), 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }).start();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void release() {
|
|
|
- programTextList.clear();
|
|
|
- }
|
|
|
-}
|