瀏覽代碼

signal navi add

shjung 2 年之前
父節點
當前提交
2f0f7ab103

+ 17 - 0
.idea/deploymentTargetDropDown.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetDropDown">
+    <targetSelectedWithDropDown>
+      <Target>
+        <type value="QUICK_BOOT_TARGET" />
+        <deviceKey>
+          <Key>
+            <type value="VIRTUAL_DEVICE_PATH" />
+            <value value="C:\Users\OpenValue\.android\avd\Nexus_10_API_30.avd" />
+          </Key>
+        </deviceKey>
+      </Target>
+    </targetSelectedWithDropDown>
+    <timeTargetWasSelectedWithDropDown value="2022-04-14T01:24:01.411664300Z" />
+  </component>
+</project>

+ 3 - 1
.idea/misc.xml

@@ -63,7 +63,9 @@
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/dialog_node_cross.xml" value="0.3197463768115942" />
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/dialog_title.xml" value="0.3134057971014493" />
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_area_cross.xml" value="0.36614583333333334" />
-        <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_direction_signal.xml" value="0.31929347826086957" />
+        <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_direction_nav_signal.xml" value="0.36141304347826086" />
+        <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_direction_navi_signal.xml" value="0.36141304347826086" />
+        <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_direction_signal.xml" value="0.33" />
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_signal.xml" value="0.3278985507246377" />
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/fragment_user_signal.xml" value="0.36614583333333334" />
         <entry key="..\:/UTIC-2021/tsi-navi/app/src/main/res/layout/item_area_cross.xml" value="0.36614583333333334" />

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 2 - 2
app/build.gradle

@@ -18,8 +18,8 @@ android {
         applicationId "com.tsi.navi"
         minSdkVersion 24
         targetSdkVersion 30
-        versionCode 12
-        versionName "1.2"
+        versionCode 13
+        versionName "1.3"
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }

+ 35 - 1
app/src/main/java/com/tsi/navi/activity/MainActivity.java

@@ -57,6 +57,7 @@ import com.tsi.navi.activity.dialog.IDialogClickListener;
 import com.tsi.navi.activity.dialog.MapSettingDialog;
 import com.tsi.navi.activity.dialog.NodeCrossDialog;
 import com.tsi.navi.activity.fragment.AreaCrossFragment;
+import com.tsi.navi.activity.fragment.DirectionNaviSignalFragment;
 import com.tsi.navi.activity.fragment.DirectionSignalFragment;
 import com.tsi.navi.activity.fragment.UserSignalFragment;
 import com.tsi.navi.activity.model.NodeCrossItem;
@@ -133,6 +134,7 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
 
     private FragmentManager fragmentManager;
     private DirectionSignalFragment directionSignalFragment;
+    private DirectionNaviSignalFragment directionNaviSignalFragment;
     private UserSignalFragment userSignalFragment;
     private AreaCrossFragment areaCrossFragment;
     private String lastTopics;
@@ -180,6 +182,9 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                     if (directionSignalFragment.isVisible() && directionSignalFragment.getNodeId() == status.getA()) {
                         directionSignalFragment.updateSignal(status);
                     }
+                    if (directionNaviSignalFragment.isVisible() && directionNaviSignalFragment.getNodeId() == status.getA()) {
+                        directionNaviSignalFragment.updateSignal(status);
+                    }
                     if (userSignalFragment.isVisible() && userSignalFragment.getNodeId() == status.getA()) {
                         userSignalFragment.updateSignal(status, 10);
                     }
@@ -207,6 +212,9 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                 if (this.directionSignalFragment.isVisible()) {
                     this.fragmentManager.beginTransaction().hide(this.directionSignalFragment).commit();
                 }
+                if (this.directionNaviSignalFragment.isVisible()) {
+                    this.fragmentManager.beginTransaction().hide(this.directionNaviSignalFragment).commit();
+                }
             }
         } catch (Exception e) {
             Log.e(TAG, "Request topic error: " + e.getMessage());
@@ -312,13 +320,16 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
 
         this.areaCrossFragment = new AreaCrossFragment();
         this.directionSignalFragment = new DirectionSignalFragment();
+        this.directionNaviSignalFragment = new DirectionNaviSignalFragment();
         this.userSignalFragment = new UserSignalFragment();
 
         transaction.add(R.id.frame_area_cross, areaCrossFragment, "AreaCross");
         transaction.add(R.id.frame_direction_signal, this.directionSignalFragment, "DirectionSignal");
+        transaction.add(R.id.frame_direction_navi_signal, this.directionNaviSignalFragment, "DirectionNaviSignal");
         transaction.add(R.id.frame_user_signal, this.userSignalFragment, "UserSignal");
         transaction.hide(areaCrossFragment);
         transaction.hide(this.directionSignalFragment);
+        transaction.hide(this.directionNaviSignalFragment);
         transaction.hide(this.userSignalFragment);
         transaction.commit();
         /*this.areaCrossFragment.setOnItemClickListener(item -> {
@@ -465,6 +476,10 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                                         this.fragmentManager.beginTransaction().show(this.directionSignalFragment).commit();
                                         this.directionSignalFragment.setNodeCross(this.selectedNode, 10);
                                     }
+                                    if (!this.directionNaviSignalFragment.isVisible()) {
+                                        this.fragmentManager.beginTransaction().show(this.directionNaviSignalFragment).commit();
+                                        this.directionNaviSignalFragment.setNodeCross(this.selectedNode, 10);
+                                    }
                                 }
                             }
                             else {
@@ -472,6 +487,10 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                                     //this.fragmentManager.beginTransaction().hide(this.directionSignalFragment).commit();
                                     this.directionSignalFragment.setNodeCross(null, 10);
                                 }
+                                if (this.directionNaviSignalFragment.isVisible()) {
+                                    //this.fragmentManager.beginTransaction().hide(this.directionNaviSignalFragment).commit();
+                                    this.directionNaviSignalFragment.setNodeCross(null, 10);
+                                }
                             }
                         }
                         break;
@@ -483,9 +502,11 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                             if (this.gpsTracking.getRequestNode() != null) {
                                 requestTopicMessage("x");
                                 this.directionSignalFragment.setNodeCross(null, 10);
+                                this.directionNaviSignalFragment.setNodeCross(null, 10);
                             }
                             if (this.directionSignalFragment.isVisible()) {
                                 this.fragmentManager.beginTransaction().hide(this.directionSignalFragment).commit();
+                                this.fragmentManager.beginTransaction().hide(this.directionNaviSignalFragment).commit();
                             }
                         }
                         break;
@@ -971,12 +992,16 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
 
         this.userSignalFragment.setNodeCross(null);
         this.directionSignalFragment.setNodeCross(node, directionCode);
+        this.directionNaviSignalFragment.setNodeCross(node, directionCode);
 
         requestTopicMessage(String.valueOf(nodeId));
 
         if (!this.directionSignalFragment.isVisible()) {
             this.fragmentManager.beginTransaction().show(this.directionSignalFragment).commit();
         }
+        if (!this.directionNaviSignalFragment.isVisible()) {
+            this.fragmentManager.beginTransaction().show(this.directionNaviSignalFragment).commit();
+        }
         if (userSignalFragment.isVisible()) {
             this.fragmentManager.beginTransaction().hide(this.userSignalFragment).commit();
         }
@@ -1100,11 +1125,18 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
                     //TODO Log.e(TAG, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: " + this.selectedNode);
                     if (this.selectedNode != null) this.fragmentManager.beginTransaction().show(this.directionSignalFragment).commit();
                 }
+                if (!this.directionNaviSignalFragment.isVisible()) {
+                    //TODO Log.e(TAG, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: " + this.selectedNode);
+                    if (this.selectedNode != null) this.fragmentManager.beginTransaction().show(this.directionNaviSignalFragment).commit();
+                }
             }
             else {
                 if (this.directionSignalFragment.isVisible()) {
                     //this.fragmentManager.beginTransaction().hide(this.directionSignalFragment).commit();
                 }
+                if (this.directionNaviSignalFragment.isVisible()) {
+                    //this.fragmentManager.beginTransaction().hide(this.directionNaviSignalFragment).commit();
+                }
             }
         }
     }
@@ -1115,6 +1147,7 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
 
             this.userSignalFragment.setNodeCross(this.selectedNode);
             this.directionSignalFragment.setNodeCross(this.selectedNode, 10);
+            this.directionNaviSignalFragment.setNodeCross(this.selectedNode, 10);
             requestTopicMessage(String.valueOf(this.selectedNode.getNodeId()));
         }
     }
@@ -1168,7 +1201,8 @@ public class MainActivity extends AppCompatActivity implements OnMapReadyCallbac
     @Override
     public void onBackPressed() {
         if (this.userSignalFragment.isVisible() ||
-            (!this.isTrackingMode && this.directionSignalFragment.isVisible())) {
+            ( !this.isTrackingMode && this.directionSignalFragment.isVisible() || !this.isTrackingMode && this.directionSignalFragment.isVisible() )
+        ) {
             requestTopicMessage("x");
             return;
         }

+ 397 - 0
app/src/main/java/com/tsi/navi/activity/fragment/DirectionNaviSignalFragment.java

@@ -0,0 +1,397 @@
+package com.tsi.navi.activity.fragment;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+import com.tsi.navi.R;
+import com.tsi.navi.TsiNaviApplication;
+import com.tsi.navi.activity.model.CpuControl;
+import com.tsi.navi.activity.model.SignalItem;
+import com.tsi.navi.dto.CpuNodeStatusDTO;
+import com.tsi.navi.util.TsiUtils;
+import com.tsi.navi.vo.NodeVo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class DirectionNaviSignalFragment extends Fragment {
+    private static final String TAG = DirectionNaviSignalFragment.class.getSimpleName();
+
+    private Context context;
+
+    private NodeVo node;
+    private long nodeId;
+    private CpuControl cpuControl;
+
+    private TextView tvCycle;
+
+    private ImageView[] imgSignal = new ImageView[4];
+
+    private int directionCode;
+    private boolean first;
+    private Set<String> directions = new HashSet();
+
+    private final  int MAX_SIGNAL = 4;
+    private int[] sigIdx = new int[MAX_SIGNAL];
+
+    private int[][] signalId = {
+            {   // RED
+                    R.drawable.ic_sig_off,
+                    R.drawable.ic_sig_red,
+            },
+            {   // YELLOW
+                    R.drawable.ic_sig_off,
+                    R.drawable.ic_sig_yellow,
+            },
+            {   // LEFT
+                    R.drawable.ic_sig_left_off,
+                    R.drawable.ic_sig_left_on,
+            },
+            {   // STRAIGHT
+                    R.drawable.ic_sig_off,
+                    R.drawable.ic_sig_green,
+            },
+    };
+    private int[][] signalIdUn = {
+            {   // none
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+                    R.drawable.rect_none,                  // 데이터 없음.
+            },
+            {   // 직진
+                    R.drawable.ic_signal_straight_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_straight_red_un,      // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_straight_yellow_un,   // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_straight_green_un,    // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_straight_red_un,      // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_straight_yellow_un,   // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_straight_green_un,    // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 좌회전
+                    R.drawable.ic_signal_left_off_un,          // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_left_red_un,          // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_left_yellow_un,       // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_left_green_un,        // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_left_red_un,          // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_left_yellow_un,       // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_left_green_un,        // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 보행자
+                    R.drawable.ic_signal_walk_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_walk_red_un,        // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_walk_yellow_un,     // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_walk_green_un,         // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_walk_red_un,        // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_walk_yellow_un,     // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_walk_green_un,         // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 자전거
+                    R.drawable.ic_signal_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_red_un,            // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_green_un,       // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_red_un,            // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_green_un,       // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 우회전
+                    R.drawable.ic_signal_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_red_un,            // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_green_un,       // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_red_un,            // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_green_un,       // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 버스
+                    R.drawable.ic_signal_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_red_un,            // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_green_un,       // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_red_un,            // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_yellow_un,         // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_green_un,       // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+            {   // 유턴
+                    R.drawable.ic_signal_uturn_off_un,      // LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
+                    R.drawable.ic_signal_uturn_red_un,            // RED_SOLID    (1, "RED_SOLID"),      //적색점등
+                    R.drawable.ic_signal_uturn_yellow_un,         // YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
+                    R.drawable.ic_signal_uturn_green_un,       // GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
+                    R.drawable.ic_signal_uturn_red_un,            // RED_BLINK    (4, "RED_BLINK"),      //적색점멸
+                    R.drawable.ic_signal_uturn_yellow_un,         // YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
+                    R.drawable.ic_signal_uturn_green_un,       // GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸
+                    R.drawable.rect_none,                   // 데이터 없음.
+            },
+    };
+
+    private SignalItem signalCurr = null;
+    private SignalItem signalPrev = null;
+
+    // 소등(0), 적색점등(1), 황색점등(2), 녹색점등(3), 적색점멸(4), 황색점멸(5), 녹색점멸(6)
+    // 미지정(0), 직진(1), 좌회전(2), 보행자(3), 자전거(4), 우회전(5), 버스(6), 유턴(7)
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        this.context = context;
+    }
+
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        View v = inflater.inflate(R.layout.fragment_direction_navi_signal, container, false);
+
+        this.tvCycle = v.findViewById(R.id.tv_cycle);
+        this.tvCycle.setOnClickListener(view -> {
+            if (this.directions.size() == 0) {
+                return;
+            }
+            Log.e("Direction", this.directions.toString());
+            List<String> directionList = new ArrayList(this.directions);
+            Collections.sort(directionList);
+            String[] dirs = new String[directionList.size()];
+            for(int ii = 0; ii  < directionList.size(); ii++) {
+                dirs[ii] = TsiNaviApplication.getDirection().getName(Integer.parseInt(directionList.get(ii)));
+            }
+            Log.e("Direction", dirs.toString());
+
+            AlertDialog.Builder builder = new AlertDialog.Builder(context);
+            builder.setTitle("방향코드 선택");
+            builder.setItems(dirs, (dialog, which) -> {
+                int selDirection = TsiNaviApplication.getDirection().getNameCode(dirs[which]);
+                if (selDirection != directionCode) {
+                    initStatus();
+                    setDirectionCode(selDirection);
+                }
+                }
+            );
+            builder.show();
+        });
+
+        this.imgSignal[0] = (ImageView) v.findViewById(R.id.img_red);
+        this.imgSignal[1] = (ImageView) v.findViewById(R.id.img_yellow);
+        this.imgSignal[2] = (ImageView) v.findViewById(R.id.img_left);
+        this.imgSignal[3] = (ImageView) v.findViewById(R.id.img_straight);
+
+        this.first = false;
+        this.directionCode = 0;
+
+        if (this.signalCurr == null) {
+            this.signalCurr = new SignalItem();
+        }
+        if (this.signalPrev == null) {
+            this.signalPrev = new SignalItem();
+        }
+
+        this.cpuControl = new CpuControl();
+        this.nodeId = 0;
+
+        init(0);
+
+        return v;
+    }
+
+    protected void setDirectionCode(int directionCode) {
+        this.directionCode = directionCode;
+        String name = TsiNaviApplication.getDirection().getName(this.directionCode);
+        this.signalCurr.setDirection(this.directionCode);
+        this.signalPrev.setDirection(this.directionCode);
+    }
+
+    protected void init(int directionCode) {
+        if (this.node != null) {
+            this.nodeId = this.node.getNodeId();
+        }
+        else {
+            this.nodeId = 0;
+        }
+
+        initStatus();
+        setDirectionCode(directionCode);
+    }
+    @SuppressLint("ObsoleteSdkInt")
+    public void initStatus() {
+        this.cpuControl.init();
+
+        for (int ii = 0; ii < this.MAX_SIGNAL; ii++) {
+            if (this.imgSignal[ii] != null) {
+                if (this.imgSignal[ii].getAnimation() != null) {
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+                        this.imgSignal[ii].getAnimation().cancel();
+                    }
+                    this.imgSignal[ii].clearAnimation();
+                    this.imgSignal[ii].setAnimation(null);
+                }
+                this.imgSignal[ii].setImageResource(signalId[ii][0]);
+            }
+        }
+
+        this.signalCurr.initStatus();
+        this.signalPrev.initStatus();
+    }
+    public long getNodeId() {
+        return this.nodeId;
+    }
+
+    public void setNodeCross(NodeVo node, int directionCode) {
+        this.first = true;
+        this.node = node;
+        init(directionCode);
+    }
+
+    @SuppressLint("ObsoleteSdkInt")
+    public void updateSignal(CpuNodeStatusDTO status) {
+        if (this.node == null || this.nodeId != status.getA()) {
+            return;
+        }
+
+        if (this.first) {
+            this.directions.clear();
+            int directionCode = this.directionCode;
+            for (int ii = 0; ii < status.getG().size(); ii++) {
+                this.directions.add(String.valueOf(status.getG().get(ii).getH()));
+                if (ii == 0) {
+                    directionCode = status.getG().get(ii).getH();
+                }
+                if (this.directionCode == status.getG().get(ii).getH()) {
+                    directionCode = this.directionCode;
+                }
+            }
+            // 프로그램에서 설정한 방향코드가 수집한 상태정보의 방향코드에 존재하지 않으면 첫번째 방향코드로 변경한다.
+            if (this.directionCode != directionCode) {
+                setDirectionCode(directionCode);
+            }
+
+            this.first = false;
+        }
+
+        this.cpuControl.updateStatus(status.getD());
+        // 방향코드에 맞는 데이터 표출
+        for (int ii = 0; ii < status.getG().size(); ii++) {
+            if (status.getG().get(ii).getH() == this.directionCode) {
+                this.signalCurr.setStatus(status.getG().get(ii));
+            }
+        }
+
+        int lightStatus;
+        int remainSeconds;
+
+        for (int ii = 0; ii < this.MAX_SIGNAL; ii++) {
+            this.sigIdx[ii] = 0;
+        }
+        boolean isBlink = false;
+        remainSeconds = this.signalCurr.getRemainTime(TsiUtils.SIGNAL_STRAIGHT);
+        lightStatus = this.signalCurr.getLightStatus(TsiUtils.SIGNAL_STRAIGHT);
+        switch (lightStatus) {
+            case 0: // light out
+                break;
+            case 1: // red solid
+                this.sigIdx[0] = 1;
+                break;
+            case 4: // red blink
+                this.sigIdx[0] = 1;
+                isBlink = true;
+                break;
+            case 2: // yellow solid
+                this.sigIdx[1] = 1;
+                break;
+            case 5: // yellow blink
+                this.sigIdx[1] = 1;
+                isBlink = true;
+                break;
+            case 3: // green solid
+                this.sigIdx[3] = 1;
+                break;
+            case 6: // green blink
+                this.sigIdx[3] = 1;
+                isBlink = true;
+                break;
+        }
+        lightStatus = this.signalCurr.getLightStatus(TsiUtils.SIGNAL_LEFT_TURN);
+        switch (lightStatus) {
+            case 0: // light out
+                break;
+            case 1: // red solid
+                this.sigIdx[0] = 1;
+                break;
+            case 4: // red blink
+                this.sigIdx[0] = 1;
+                isBlink = true;
+                break;
+            case 2: // yellow solid
+                this.sigIdx[1] = 1;
+                break;
+            case 5: // yellow blink
+                this.sigIdx[1] = 1;
+                isBlink = true;
+                break;
+            case 3: // green solid
+                this.sigIdx[2] = 1;
+                break;
+            case 6: // green blink
+                this.sigIdx[2] = 1;
+                isBlink = true;
+                break;
+        }
+        if (lightStatus == 2 || lightStatus == 5) {
+            // YELLOW 일때
+            if (this.sigIdx[0] == 1) {
+                remainSeconds = this.signalCurr.getRemainTime(TsiUtils.SIGNAL_LEFT_TURN);
+            }
+        }
+        if (this.sigIdx[2] == 1 && this.sigIdx[0] == 1) {
+            // 좌회전, 레드가 모구 켜져있으면 좌회전 신호 표출
+            this.sigIdx[0] = 0;
+            remainSeconds = this.signalCurr.getRemainTime(TsiUtils.SIGNAL_LEFT_TURN);
+        }
+        if (this.sigIdx[1] == 1 && this.sigIdx[0] == 1) {
+            // 레드, 옐로우 켜져 있으면 옐로우 신호 표출
+            this.sigIdx[0] = 0;
+        }
+
+        if (remainSeconds < 0) remainSeconds = 255;
+        this.tvCycle.setText(" " +String.valueOf(remainSeconds));
+        for (int ii = 0; ii < this.MAX_SIGNAL; ii++) {
+            if (this.imgSignal[ii].getAnimation() != null) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+                    this.imgSignal[ii].getAnimation().cancel();
+                }
+                this.imgSignal[ii].clearAnimation();
+                this.imgSignal[ii].setAnimation(null);
+            }
+            this.imgSignal[ii].setImageResource(signalId[ii][this.sigIdx[ii]]);
+            if (isBlink && this.sigIdx[ii] == 1) {
+                Animation animation = AnimationUtils.loadAnimation(this.context, R.anim.blink);
+                this.imgSignal[ii].startAnimation(animation);
+            }
+        }
+    }
+}

二進制
app/src/main/res/drawable/ic_sig_green.png


二進制
app/src/main/res/drawable/ic_sig_left_off.png


二進制
app/src/main/res/drawable/ic_sig_left_on.png


二進制
app/src/main/res/drawable/ic_sig_off.png


二進制
app/src/main/res/drawable/ic_sig_red.png


二進制
app/src/main/res/drawable/ic_sig_yellow.png


+ 14 - 5
app/src/main/res/layout/activity_main.xml

@@ -26,17 +26,26 @@
         android:layout_marginEnd="0dp"
         android:background="@drawable/frame_background"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        app:layout_constraintTop_toTopOf="parent" >
+    </FrameLayout>
+
+    <FrameLayout
+        android:id="@+id/frame_direction_navi_signal"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="1dp"
+        android:layout_marginLeft="2dp"
+        android:layout_marginEnd="0dp"
+        android:background="@drawable/frame_background"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/frame_direction_signal"></FrameLayout>
 
     <FrameLayout
         android:id="@+id/frame_area_cross"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginStart="0dp"
-        android:layout_marginTop="0dp"
         android:background="#30000000"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/frame_direction_signal" />
+        app:layout_constraintStart_toStartOf="parent" />
 
     <FrameLayout
         android:id="@+id/frame_user_signal"

+ 91 - 0
app/src/main/res/layout/fragment_direction_navi_signal.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="270dp"
+    android:layout_height="wrap_content"
+    android:layout_centerVertical="true"
+    android:orientation="vertical"
+    android:paddingTop="4dp"
+    android:paddingLeft="4dp"
+    android:paddingRight="4dp"
+    android:paddingBottom="4dp"
+    android:background="@color/rect_title">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:orientation="horizontal"
+        android:weightSum="11"/>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/rect_title"
+        android:paddingTop="2dp" />
+
+    <!-- 신호등 이미지 -->
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="40dp"
+        android:gravity="center"
+        android:orientation="horizontal"
+        android:weightSum="11">
+
+        <ImageView
+            android:id="@+id/img_red"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:layout_weight="2"
+            android:background="@color/rect_title"
+            android:src="@drawable/ic_sig_off" />
+
+        <ImageView
+            android:id="@+id/img_yellow"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:layout_weight="2"
+            android:background="@color/rect_title"
+            android:src="@drawable/ic_sig_off" />
+
+        <ImageView
+            android:id="@+id/img_left"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:layout_weight="2"
+            android:background="@color/rect_title"
+            android:src="@drawable/ic_sig_left_off" />
+
+        <ImageView
+            android:id="@+id/img_straight"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:layout_weight="2"
+            android:background="@color/rect_title"
+            android:src="@drawable/ic_sig_off" />
+
+        <TextView
+            android:id="@+id/tv_cycle"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="3"
+            android:background="@color/rect_title"
+            android:text="10"
+            android:textAlignment="center"
+            android:textColor="@color/rect_normal_color"
+            android:textSize="@dimen/time_font_size"
+            android:textStyle="bold" />
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/rect_title"
+        android:paddingTop="2dp" />
+
+</LinearLayout>

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -8,6 +8,7 @@
 
     <dimen name="speed_font_size">45sp</dimen>
     <dimen name="title_font_size">18sp</dimen>
+    <dimen name="time_font_size">22sp</dimen>
     <dimen name="item_font_size">16sp</dimen>
     <dimen name="data_font_size">16sp</dimen>