浏览代码

兼容192x32点阵屏

weizhengliang 2 年之前
父节点
当前提交
ddffe23dcd

+ 123 - 27
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/led/LedC2MManager.java

@@ -30,6 +30,8 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+import static com.wdkl.ncs.android.lib.utils.ExtendMethodsKt.debugLog;
+
 public class LedC2MManager extends LedManager {
     private static final String TAG = "ledC2M";
 
@@ -42,7 +44,7 @@ public class LedC2MManager extends LedManager {
     private static String deleteVoiceText;
     private static boolean stopVoice = false;
 
-    private static long LED_TIMEOUT = 5*60*1000L;
+    private static long LED_TIMEOUT = 30*60*1000L;
 
     private final static Object lockObject = new Object();
 
@@ -289,10 +291,30 @@ public class LedC2MManager extends LedManager {
         String language = LocaleMangerUtils.getApplicationLocale().getLanguage();
         if (type == 0) {
             //仅显示时间
-            if (LedItem.TYPE_64_16.equals(ledResolution)) {
+            if (LedItem.TYPE_192_32.equals(ledResolution)) {
+                //192x32
+                hProgram = ledC2M.CreateProgram(192, 32, 1,1, savaType);
+                ledC2M.AddProgram(hProgram, 0, 10, 1);
+                if (Locale.CHINESE.getLanguage().equals(language)) {
+                    //左边添加一个静字
+                    ledC2M.AddImageTextArea(hProgram, 0, 1, 0, 0, 48, 32, 0);
+                    ledC2M.AddStaticTextToImageTextArea(hProgram, 0, 1, 0, "静", Constants.Companion.getC2M_LED_FONT_PATH(), 28, 0xff, 1, 0, 0, 0, 1, 1);
+                    //时间
+                    ledC2M.AddDigitalClockArea(hProgram, 0, 2, 48, 0, 144, 32, Constants.Companion.getC2M_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, 192, 32, Constants.Companion.getC2M_LED_FONT_PATH(),
+                            16, 0xff, 0, 0, 0,
+                            1, 0, 1, 1, 1, 1, 1,
+                            4, 0xff, 0, 0xff, 2, 0xff, 1);
+                }
+            } else 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.Companion.getC2M_LED_FONT_PATH(),
                             16, 0xff, 0, 0, 0,
@@ -331,7 +353,28 @@ public class LedC2MManager extends LedManager {
         } else if (type == 1) {
             //显示时间和自定义内容
             String text = SettingConfig.getLedCustomInfo(application);
-            if (LedItem.TYPE_64_16.equals(ledResolution)) {
+            if (LedItem.TYPE_192_32.equals(ledResolution)) {
+                //192x32
+                hProgram = ledC2M.CreateProgram(192, 32, 1,1,savaType);
+                ledC2M.AddProgram(hProgram, 0, 10, 1);
+                if (Locale.CHINESE.getLanguage().equals(language)) {
+                    ledC2M.AddDigitalClockArea(hProgram, 0, 1, 0, 0, 192, 32, Constants.Companion.getC2M_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, 192, 32, Constants.Companion.getC2M_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, 192, 32, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, 1, 1, 0, text, Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+                }
+            } else if (LedItem.TYPE_64_16.equals(ledResolution)) {
                 //64x16
                 hProgram = ledC2M.CreateProgram(64, 16, 1,1,savaType);
                 ledC2M.AddProgram(hProgram, 0, 10, 1);
@@ -346,6 +389,7 @@ public class LedC2MManager extends LedManager {
                             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);
@@ -393,31 +437,79 @@ public class LedC2MManager extends LedManager {
 
     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(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 64, 16, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, text, Constants.Companion.getC2M_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(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 16, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_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(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 32, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+        try {
+            if (LedItem.TYPE_192_32.equals(ledResolution)) {
+                //192x32,双行显示
+                hProgram = ledC2M.CreateProgram(192, 32, 1, 1, 3);
+                int programTextCount = programTextList.size(); //呼叫信息数量
+                if (programTextCount == 1) {
+                    ledC2M.AddProgram(hProgram, 0, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                    //左边添加一个静字
+                    ledC2M.AddImageTextArea(hProgram, 0, 1, 0, 0, 48, 32, 0);
+                    ledC2M.AddStaticTextToImageTextArea(hProgram, 0, 1, 0, "静", Constants.Companion.getC2M_LED_FONT_PATH(), 28, 0xff, 1, 0, 0, 0, 1, 1);
+
+                    ledC2M.AddImageTextArea(hProgram, 0, 2, 48, 0, 144, 16, 0);
+                    //ledC2M.AddSinglelineTextToImageTextArea(hProgram, 0, 1, 0, programTextList.get(0).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, 0, 2, 0, programTextList.get(0).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+                } else {
+                    //一个节目分上下两块区域显示,一个区域显示一个呼叫信息,所以一共需要显示(pSize/2)个节目
+                    int pSize;
+                    if (programTextCount % 2 == 0) {
+                        pSize = programTextCount / 2;
+                    } else {
+                        pSize = programTextCount / 2 + 1;
+                    }
+
+                    Log.e(TAG, "programTextCount= " + programTextCount + ", pSize= " + pSize);
+                    for (int i = 0; i < pSize; i++) {
+                        int textIndex = i * 2;
+                        ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                        //左边添加一个静字
+                        ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 48, 32, 0);
+                        ledC2M.AddStaticTextToImageTextArea(hProgram, i, 1, 0, "静", Constants.Companion.getC2M_LED_FONT_PATH(), 28, 0xff, 1, 0, 0, 0, 1, 1);
+
+                        //上面一行
+                        ledC2M.AddImageTextArea(hProgram, i, 2, 48, 0, 144, 16, 0);
+                        //ledC2M.AddSinglelineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(textIndex).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                        ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 2, 0, programTextList.get(textIndex).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+
+                        if (textIndex + 1 < programTextCount) {
+                            //下面一行
+                            ledC2M.AddImageTextArea(hProgram, i, 3, 48, 16, 144, 16, 0);
+                            //ledC2M.AddSinglelineTextToImageTextArea(hProgram, i, 2, 0, programTextList.get(textIndex + 1).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                            ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 3, 0, programTextList.get(textIndex + 1).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+                        }
+                    }
+                }
+            } else 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(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 64, 16, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, text, Constants.Companion.getC2M_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(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 16, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_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(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 32, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+                }
             }
+        } catch (Exception e) {
+            Log.e(TAG, "createCallingProgram call exception...");
+            e.printStackTrace();
         }
 
         return hProgram;
@@ -506,6 +598,10 @@ public class LedC2MManager extends LedManager {
                                 if (Constants.Companion.getDEBUG()) {
                                     Log.d(TAG, "send default program to " + ledItem.getIp() + ", result: " + result);
                                 }
+                                if (result != 0) {
+                                    //节目发送失败
+                                    debugLog(TAG,"send default program to: " + ledItem.getIp() + ", result: " + result);
+                                }
                                 ledC2M.DeleteProgram(h);
                             }
 

+ 1 - 0
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/led/LedItem.java

@@ -6,6 +6,7 @@ public class LedItem {
     * type:点阵屏类型,128x32代表128x32点阵,64x16代表64x16点阵,默认为128x32
      */
 
+    public static final String TYPE_192_32 = "192x32";
     public static final String TYPE_128_32 = "128x32";
     public static final String TYPE_128_16 = "128x16";
     public static final String TYPE_64_16 = "64x16";