2021与蓝度共同重构项目,服务端
liuhaonan
2022-11-10 6554fd4bf83e50d39fc75f1c4ac3fbf6675f1962
ximon-admin/src/main/java/com/sandu/ximon/admin/newnova/utils/APITest.java
@@ -1,6 +1,7 @@
package com.sandu.ximon.admin.newnova.utils;
import com.sun.jna.Native;
/*
* 使用前阅读:
* 1 关于可能发生的搜索不到T卡的原因:
@@ -24,26 +25,23 @@
public class APITest {
    static Boolean g_bAPIReturn = false;
    static int g_code = 0;
   static String g_sn = "BZSA79353N1310006847"; //BZSA07313J0350000997
    static String g_sn = "MZVA51930N2113017308"; //BZSA07313J0350000997
    static void waitAPIReturn() throws InterruptedException
    {
        while (!g_bAPIReturn)
        {
    static void waitAPIReturn() throws InterruptedException {
        while (!g_bAPIReturn) {
            Thread.sleep(1000);
        }
        g_bAPIReturn = false;
    }
    static void testApi() throws InterruptedException
        {
    static void testApi() throws InterruptedException {
         System.setProperty("jna.encoding", "UTF-8");
         ViplexCore instance = (ViplexCore) Native.loadLibrary("viplexcore",ViplexCore.class);
//         ViplexCore instance = (ViplexCore) Native.loadLibrary("viplexcore",ViplexCore.class);
         //当需要集成到项目中时,请修改上面加载库的位置为你下载的sdk库的绝对路径,windows下如:
         //ViplexCore instance = (ViplexCore) Native.loadLibrary("D:\\ViplexCore3.3.0.01_x64\\bin\\viplexcore.dll",ViplexCore.class);
        ViplexCore instance = (ViplexCore) Native.loadLibrary("C:\\Users\\Administrator\\Desktop\\novaWin\\bin\\viplexcore.dll", ViplexCore.class);
            
         //当需要集成到项目中时,请修改此处加载库的位置为你下载的sdk库的绝对路径,linux下如:
         //ViplexCore instance = (ViplexCore) Native.loadLibrary("home/user/desktop/ViplexCore_3.3.0.01_CentOS/bin/libviplexcore.so",ViplexCore.class);
//         ViplexCore instance = (ViplexCore) Native.loadLibrary("C:\\Users\\Administrator\\Desktop\\novaLinux\\bin\\libviplexcore.so",ViplexCore.class);
            ViplexCore.CallBack callBack = new ViplexCore.CallBack() {
                @Override
@@ -60,43 +58,38 @@
            };
            String rootDir = System.getProperty("user.dir") + "/temp";
        System.out.println("保存路径:" + rootDir);
            rootDir = rootDir.replaceAll( "\\\\","/");
            String createProgram = "{\"name\":\"Demo\",\"width\":500,\"height\":500,\"tplID\":1,\"winInfo\":{\"height\":100,\"width\":100,\"left\":0,\"top\":0,\"zindex\":0,\"index\":0}}";
            String editProgram = "{\"programID\":1,\"pageID\":1,\"pageInfo\":{\"name\":\"节目\",\"widgetContainers\":[{\"audioGroup\":\"\",\"backgroundColor\":\"#00000000\",\"backgroundDrawable\":\"\",\"contents\":{\"widgetGroups\":[],\"widgets\":[{\"id\":1,\"enable\":true,\"repeatCount\":1,\"layout\":{\"y\":\"0\",\"height\":\"100%\",\"x\":\"0\",\"width\":\"100%\"},\"backgroundColor\":\"#00000000\",\"backgroundDrawable\":\"\",\"backgroundMusic\":\"\",\"zOrder\":0,\"displayRatio\":\"FULL\",\"outAnimation\":{\"type\":0,\"duration\":0},\"dataSource\":\"62ea7e60c493c1f860ae256eef8ec89c.png\",\"type\":\"PICTURE\",\"constraints\":[{\"cron\":[],\"endTime\":\"4017-12-30T23:59:59Z+8:00\",\"startTime\":\"1970-01-01T00:00:00Z+8:00\"}],\"border\":{\"borderThickness\":\"2px,3px,5%,6\",\"style\":0,\"backgroundColor\":\"#ff000000\",\"name\":\"border\",\"cornerRadius\":\"2%\",\"effects\":{\"headTailSpacing\":\"\",\"isHeadTail\":false,\"speedByPixelEnable\":true,\"speed\":0,\"animation\":\"CLOCK_WISE\"}},\"inAnimation\":{\"type\":0,\"duration\":1000},\"duration\":3605000,\"name\":\"test.png\",\"originalDataSource\":\"./test.png\",\"functionStorage\":\"\",\"isSupportSpecialEffects\":false}]},\"enable\":true,\"id\":1,\"itemsSource\":\"\",\"layout\":{\"height\":\"1.0\",\"width\":\"1.0\",\"x\":\"0.0\",\"y\":\"0.0\"},\"name\":\"widgetContainers1\",\"pickCount\":0,\"pickPolicy\":\"ORDER\",\"zOrder\":0}]}}";
        String createProgram = "{\"name\":\"jiemu1\",\"width\":240,\"height\":144}";
        String editProgram = "{\"programID\":13,\"pageID\":1,\"pageInfo\":{\"name\":\"节目01\",\"widgetContainers\":[{\"contents\":{\"widgets\":[{\"constraints\":[{\"cron\":[\"0 0 0 ? * 1,2,3,4,5,6,7\"],\"endTime\":\"4017-12-30T23:59:59Z+8:00\",\"startTime\":\"1970-01-01T00:00:00Z+8:00\"}],\"duration\":5000,\"dataSource\":\"62ea7e60c493c1f860ae256eef8ec89c.png\",\"type\":\"PICTURE\",\"name\":\"test.png\",\"originalDataSource\":\"C:/Users/Administrator/Desktop/novaWin/demo/java/test.png\"}]},\"id\":1,\"name\":\"widgetContainers1\"}]}}";
            String genrateProgram = String.format(
                "{\"programID\":1,\"outPutPath\":\"%s/\",\"mediasPath\":[{\"oldPath\":\"test\",\"newPath\":\"test\"}]}",
                "{\"programID\":13,\"outPutPath\":\"%s/\"}",
                rootDir);
            String trasfromProgram = String.format(
            "{\"sn\": \"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program1\",\"mediasPath\": {\"./test.png\": \"test.png\"}},\"programName\": \"program1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
                "{\"sn\": \"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program13\",\"mediasPath\": {\"C:/Users/Administrator/Desktop/novaWin/demo/java/test.png\": \"test.png\"}},\"programName\": \"jiemu1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
            g_sn,
                rootDir);
            
            
      Boolean bTestVideo = false;
      if (bTestVideo)
      {
         editProgram = "{\"programID\":1,\"pageID\":1,\"pageInfo\":{\"name\":\"Demo\",\"widgetContainers\":[{\"contents\":{\"widgets\":[{\"constraints\":[{\"cron\":[\"0 0 0 ? * 1,2,3,4,5,6,7\"],\"endTime\":\"4017-12-30T23:59:59Z 8:00\",\"startTime\":\"1970-01-01T00:00:00Z 8:00\"}],\"duration\":5000,\"dataSource\":\"219c7dd3260d6bf98ebf61b6da440ffd.avi\",\"type\":\"VIDEO\",\"name\":\"test.vai\",\"originalDataSource\":\"./test.avi\"}]},\"id\":1,\"name\":\"widgetContainers1\"}]}}";
         trasfromProgram = String.format(
         "{\"sn\":\"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program1\",\"mediasPath\": {\"./test.avi\": \"test.avi\"}},\"programName\": \"program1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
         g_sn,
         rootDir);
      }
         Boolean testText = false;
         if (testText) {
            editProgram = "{\"programID\":1,\"pageID\":1,\"pageInfo\":{\"name\":\"jiemu\",\"widgetContainers\":[{\"contents\":{\"widgets\":[{\"constraints\":[{\"cron\":[\"0 0 0 ? * 1,2,3,4,5,6,7\"],\"endTime\":\"4017-12-30T23:59:59Z+8:00\",\"startTime\":\"1970-01-01T00:00:00Z+8:00\"}],\"duration\":5000,\"metadata\":{\"content\":{\"autoPaging\":true,\"backgroundMusic\":{\"duration\":0,\"isTextSync\":false},\"displayStyle\":{\"scrollAttributes\":{\"effects\":{\"animation\":\"MARQUEE_LEFT\",\"speed\":3}},\"type\":\"SCROLL\"},\"paragraphs\":[{\"backgroundColor\":\"#00000000\",\"horizontalAlignment\":\"CENTER\",\"letterSpacing\":0,\"lineSpacing\":0,\"lines\":[{\"segs\":[{\"content\":\"简体繁體日本語한국어.English123\"}]}],\"verticalAlignment\":\"CENTER\"}],\"textAttributes\":[{\"backgroundColor\":\"#ff000000\",\"attributes\":{\"font\":{\"family\":[\"Arial\"],\"isUnderline\":false,\"size\":20,\"style\":\"NORMAL\"},\"letterSpacing\":0,\"textColor\":\"#ffff0000\"}}]}},\"name\":\"text\",\"type\":\"ARCH_TEXT\"}]},\"id\":1,\"name\":\"widgetContainers1\"}]}}";
            trasfromProgram = String.format(
               "{\"sn\": \"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program1\",\"mediasPath\": {}},\"programName\": \"program1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
               g_sn,
               rootDir);
         }
//        Boolean bTestVideo = false;
//        if (bTestVideo) {
//            editProgram = "{\"programID\":1,\"pageID\":1,\"pageInfo\":{\"name\":\"Demo\",\"widgetContainers\":[{\"contents\":{\"widgets\":[{\"constraints\":[{\"cron\":[\"0 0 0 ? * 1,2,3,4,5,6,7\"],\"endTime\":\"4017-12-30T23:59:59Z 8:00\",\"startTime\":\"1970-01-01T00:00:00Z 8:00\"}],\"duration\":5000,\"dataSource\":\"219c7dd3260d6bf98ebf61b6da440ffd.avi\",\"type\":\"VIDEO\",\"name\":\"test.vai\",\"originalDataSource\":\"./test.avi\"}]},\"id\":1,\"name\":\"widgetContainers1\"}]}}";
//
//            trasfromProgram = String.format(
//                    "{\"sn\":\"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program1\",\"mediasPath\": {\"./test.avi\": \"test.avi\"}},\"programName\": \"program1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
//                    g_sn,
//                    rootDir);
//        }
//
//
//        Boolean testText = false;
//        if (testText) {
//            editProgram = "{\"programID\":1,\"pageID\":1,\"pageInfo\":{\"name\":\"jiemu\",\"widgetContainers\":[{\"contents\":{\"widgets\":[{\"constraints\":[{\"cron\":[\"0 0 0 ? * 1,2,3,4,5,6,7\"],\"endTime\":\"4017-12-30T23:59:59Z+8:00\",\"startTime\":\"1970-01-01T00:00:00Z+8:00\"}],\"duration\":5000,\"metadata\":{\"content\":{\"autoPaging\":true,\"backgroundMusic\":{\"duration\":0,\"isTextSync\":false},\"displayStyle\":{\"scrollAttributes\":{\"effects\":{\"animation\":\"MARQUEE_LEFT\",\"speed\":3}},\"type\":\"SCROLL\"},\"paragraphs\":[{\"backgroundColor\":\"#00000000\",\"horizontalAlignment\":\"CENTER\",\"letterSpacing\":0,\"lineSpacing\":0,\"lines\":[{\"segs\":[{\"content\":\"简体繁體日本語한국어.English123\"}]}],\"verticalAlignment\":\"CENTER\"}],\"textAttributes\":[{\"backgroundColor\":\"#ff000000\",\"attributes\":{\"font\":{\"family\":[\"Arial\"],\"isUnderline\":false,\"size\":20,\"style\":\"NORMAL\"},\"letterSpacing\":0,\"textColor\":\"#ffff0000\"}}]}},\"name\":\"text\",\"type\":\"ARCH_TEXT\"}]},\"id\":1,\"name\":\"widgetContainers1\"}]}}";
//            trasfromProgram = String.format(
//                    "{\"sn\": \"%s\",\"iconPath\": \"\",\"iconName\": \"\",\"sendProgramFilePaths\": {\"programPath\": \"%s/program1\",\"mediasPath\": {}},\"programName\": \"program1\",\"deviceIdentifier\": \"Demo\",\"startPlayAfterTransferred\": true,\"insertPlay\": true}",
//                    g_sn,
//                    rootDir);
//        }
         
            String companyInfo = "{\"company\":\"NovaStar\",\"phone\":\"029-68216000\",\"email\":\"hr@novastar.tech\"}";
            instance.nvSetDevLang("Java");
@@ -113,12 +106,13 @@
            // Thread.sleep(2000);
            System.out.println("ViplexCore Demo nvLoginAsync(登录) begin... ");
         String loginParam = String.format("{\"sn\":\"%s\",\"username\":\"admin\",\"rememberPwd\":1,\"password\":\"1234567890\",\"loginType\":0}"
        String loginParam = String.format("{\"sn\":\"MZVA51930N2113017308\",\"ip\":\"\",\"username\":\"admin\",\"rememberPwd\":0,\"password\":\"123456\",\"loginType\":0}"
         , g_sn);
            instance.nvLoginAsync(loginParam, callBack);
            waitAPIReturn();
            if (g_code != 0) {
            System.out.println("ViplexCore Demo nvLoginAsync(登录) 失败!");
            System.out.println("错误码:" + g_code);
                return;
            }
            System.out.println("ViplexCore Demo nvCreateProgramAsync(创建节目) begin... ");
@@ -126,7 +120,7 @@
            waitAPIReturn();
            String requestDatapath = "{\"filePath\":\"./test.png\"}";
        String requestDatapath = "{\"filePath\":\"C:/Users/Administrator/Desktop/novaWin/demo/java/test.png\"}";
            System.out.println("ViplexCore Demo nvGetFileMD5Async(获取MD5) begin... ");
            instance.nvGetFileMD5Async(requestDatapath, callBack);
            waitAPIReturn();
@@ -140,6 +134,7 @@
            waitAPIReturn();
            System.out.println("ViplexCore Demo nvStartTransferProgramAsync(发送节目) begin... ");
        System.out.println(trasfromProgram);
            instance.nvStartTransferProgramAsync(trasfromProgram, callBack);
            Thread.sleep(10000);
            g_bAPIReturn = false;
@@ -148,16 +143,16 @@
            String requestDatasn = String.format("{\"sn\":\"%s\"}", g_sn);
            instance.nvGetProgramInfoAsync(requestDatasn, callBack);
            waitAPIReturn();
            System.out.println("ViplexCore Demo nvSetVolumeAsync(设置音量) begin... ");
         String setVolumeParam = String.format("{\"sn\":\"%s\",\"volumeInfo\":{\"ratio\":60.0}}", g_sn);
            instance.nvSetVolumeAsync(setVolumeParam, callBack);
            waitAPIReturn();
            System.out.println("ViplexCore Demo nvGetVolumeAsync(获取音量) begin... ");
         String getVolumeParam = String.format("{\"sn\":\"%s\"}", g_sn);
            instance.nvGetVolumeAsync(getVolumeParam, callBack);
            waitAPIReturn();
//
//        System.out.println("ViplexCore Demo nvSetVolumeAsync(设置音量) begin... ");
//        String setVolumeParam = String.format("{\"sn\":\"%s\",\"volumeInfo\":{\"ratio\":60.0}}", g_sn);
//        instance.nvSetVolumeAsync(setVolumeParam, callBack);
//        waitAPIReturn();
//
//        System.out.println("ViplexCore Demo nvGetVolumeAsync(获取音量) begin... ");
//        String getVolumeParam = String.format("{\"sn\":\"%s\"}", g_sn);
//        instance.nvGetVolumeAsync(getVolumeParam, callBack);
//        waitAPIReturn();
        }
    public static void main(String[] args) throws InterruptedException{