<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_EnvironmentLifecycle" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:collaboration id="Collaboration_EnvironmentLifecycle">
    <bpmn:participant id="Participant_Platform" name="日夜環境｜固定截止強制關閉，留線索早上查" processRef="Process_EnvironmentLifecycle" />
  </bpmn:collaboration>
  <bpmn:process id="Process_EnvironmentLifecycle" name="日夜環境｜固定截止強制關閉，留線索早上查" isExecutable="false">
    <bpmn:laneSet id="LaneSet_EnvironmentLifecycle">
      <bpmn:lane id="Lane_Control" name="環境控制（部署責任待核對）">
        <bpmn:flowNodeRef>Event_Start</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Start</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_Mode</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Close</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_Night</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_Force</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_Forced</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_People" name="同仁與平台維護者">
        <bpmn:flowNodeRef>Activity_Day</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_Day</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_Run" name="夜間執行與證據保存（控制設計）">
        <bpmn:flowNodeRef>Activity_Window</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_Cutoff</bpmn:flowNodeRef>
      </bpmn:lane>
    </bpmn:laneSet>
    <bpmn:startEvent id="Event_Start" name="早晨或夜間時段到達">
      <bpmn:outgoing>Flow_StartToStart</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_StartToStart" sourceRef="Event_Start" targetRef="Activity_Start" />
    <bpmn:serviceTask id="Activity_Start" name="啟用共用 EKS 測試環境">
      <bpmn:incoming>Flow_StartToStart</bpmn:incoming>
      <bpmn:outgoing>Flow_StartToMode</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_StartToMode" sourceRef="Activity_Start" targetRef="Gateway_Mode" />
    <bpmn:exclusiveGateway id="Gateway_Mode" name="本次使用時段?" default="Flow_ModeToWindow">
      <bpmn:incoming>Flow_StartToMode</bpmn:incoming>
      <bpmn:outgoing>Flow_ModeToDay</bpmn:outgoing>
      <bpmn:outgoing>Flow_ModeToWindow</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_ModeToDay" name="早晨" sourceRef="Gateway_Mode" targetRef="Activity_Day">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">morning</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_ModeToWindow" name="夜間" sourceRef="Gateway_Mode" targetRef="Activity_Window" />
    <bpmn:userTask id="Activity_Day" name="早上使用環境或查昨夜線索">
      <bpmn:incoming>Flow_ModeToDay</bpmn:incoming>
      <bpmn:outgoing>Flow_DayToDay</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_DayToDay" sourceRef="Activity_Day" targetRef="Event_Day" />
    <bpmn:endEvent id="Event_Day" name="白天使用；舊結果保留">
      <bpmn:incoming>Flow_DayToDay</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:subProcess id="Activity_Window" name="執行夜間測試並持續留證">
      <bpmn:incoming>Flow_ModeToWindow</bpmn:incoming>
      <bpmn:outgoing>Flow_WindowToClose</bpmn:outgoing>
      <bpmn:startEvent id="Inner_Start" name="夜間時窗開始">
        <bpmn:outgoing>Flow_StartToRun</bpmn:outgoing>
      </bpmn:startEvent>
      <bpmn:sequenceFlow id="Flow_StartToRun" sourceRef="Inner_Start" targetRef="Inner_Run" />
      <bpmn:serviceTask id="Inner_Run" name="檢查就緒並協調本輪測試">
        <bpmn:incoming>Flow_StartToRun</bpmn:incoming>
        <bpmn:outgoing>Flow_RunToSave</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:sequenceFlow id="Flow_RunToSave" sourceRef="Inner_Run" targetRef="Inner_Save" />
      <bpmn:boundaryEvent id="Inner_Catch" name="執行失敗或中斷" attachedToRef="Inner_Run">
        <bpmn:outgoing>Flow_CatchToError</bpmn:outgoing>
        <bpmn:errorEventDefinition errorRef="Error_NightRunError" />
      </bpmn:boundaryEvent>
      <bpmn:sequenceFlow id="Flow_CatchToError" sourceRef="Inner_Catch" targetRef="Inner_Error" />
      <bpmn:serviceTask id="Inner_Save" name="保存已完成結果與線索">
        <bpmn:incoming>Flow_RunToSave</bpmn:incoming>
        <bpmn:outgoing>Flow_SaveToMergeEnd</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:sequenceFlow id="Flow_SaveToMergeEnd" sourceRef="Inner_Save" targetRef="Gateway_MergeEnd" />
      <bpmn:serviceTask id="Inner_Error" name="保存已取得的中斷線索">
        <bpmn:incoming>Flow_CatchToError</bpmn:incoming>
        <bpmn:outgoing>Flow_ErrorToWait</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:sequenceFlow id="Flow_ErrorToWait" sourceRef="Inner_Error" targetRef="Inner_Wait" />
      <bpmn:serviceTask id="Inner_Wait" name="等待截止；不延長執行">
        <bpmn:incoming>Flow_ErrorToWait</bpmn:incoming>
        <bpmn:outgoing>Flow_WaitToMergeEnd</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:sequenceFlow id="Flow_WaitToMergeEnd" sourceRef="Inner_Wait" targetRef="Gateway_MergeEnd" />
      <bpmn:endEvent id="Inner_End" name="時窗工作結束">
        <bpmn:incoming>Flow_MergeEndToEnd</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:exclusiveGateway id="Gateway_MergeEnd">
        <bpmn:incoming>Flow_SaveToMergeEnd</bpmn:incoming>
        <bpmn:incoming>Flow_WaitToMergeEnd</bpmn:incoming>
        <bpmn:outgoing>Flow_MergeEndToEnd</bpmn:outgoing>
      </bpmn:exclusiveGateway>
      <bpmn:sequenceFlow id="Flow_MergeEndToEnd" sourceRef="Gateway_MergeEnd" targetRef="Inner_End" />
    </bpmn:subProcess>
    <bpmn:sequenceFlow id="Flow_WindowToClose" sourceRef="Activity_Window" targetRef="Activity_Close" />
    <bpmn:boundaryEvent id="Event_Cutoff" name="固定關閉時間已到" attachedToRef="Activity_Window">
      <bpmn:outgoing>Flow_CutoffToForce</bpmn:outgoing>
      <bpmn:timerEventDefinition>
        <bpmn:timeDate xsi:type="bpmn:tFormalExpression">${shutdownDeadline}</bpmn:timeDate>
      </bpmn:timerEventDefinition>
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="Flow_CutoffToForce" sourceRef="Event_Cutoff" targetRef="Activity_Force" />
    <bpmn:serviceTask id="Activity_Close" name="正常完成後自動關閉">
      <bpmn:incoming>Flow_WindowToClose</bpmn:incoming>
      <bpmn:outgoing>Flow_CloseToNight</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_CloseToNight" sourceRef="Activity_Close" targetRef="Event_Night" />
    <bpmn:endEvent id="Event_Night" name="正常結束待早晨啟用">
      <bpmn:incoming>Flow_CloseToNight</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:serviceTask id="Activity_Force" name="到點強制關閉測試環境">
      <bpmn:incoming>Flow_CutoffToForce</bpmn:incoming>
      <bpmn:outgoing>Flow_ForceToForced</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_ForceToForced" sourceRef="Activity_Force" targetRef="Event_Forced" />
    <bpmn:endEvent id="Event_Forced" name="早上啟用後依線索調查">
      <bpmn:incoming>Flow_ForceToForced</bpmn:incoming>
    </bpmn:endEvent>
  </bpmn:process>
  <bpmn:error id="Error_NightRunError" name="NightRunError" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_Collaboration_EnvironmentLifecycle">
    <bpmndi:BPMNPlane id="BPMNPlane_Collaboration_EnvironmentLifecycle" bpmnElement="Collaboration_EnvironmentLifecycle">
      <bpmndi:BPMNShape id="BPMNShape_Participant_Platform" bpmnElement="Participant_Platform" isHorizontal="true">
        <dc:Bounds x="80" y="80" width="1214" height="593" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Lane_Control" bpmnElement="Lane_Control" isHorizontal="true">
        <dc:Bounds x="110" y="80" width="1184" height="280" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Lane_People" bpmnElement="Lane_People" isHorizontal="true">
        <dc:Bounds x="110" y="360" width="1184" height="140" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Lane_Run" bpmnElement="Lane_Run" isHorizontal="true">
        <dc:Bounds x="110" y="500" width="1184" height="173" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Start" bpmnElement="Event_Start">
        <dc:Bounds x="170" y="132" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="151" y="174" width="75" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Start" bpmnElement="Activity_Start">
        <dc:Bounds x="266" y="110" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Gateway_Mode" bpmnElement="Gateway_Mode" isMarkerVisible="true">
        <dc:Bounds x="426" y="125" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="421" y="105" width="61" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Day" bpmnElement="Activity_Day">
        <dc:Bounds x="536" y="390" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Day" bpmnElement="Event_Day">
        <dc:Bounds x="696" y="412" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="673" y="454" width="82" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Window" bpmnElement="Activity_Window">
        <dc:Bounds x="536" y="530" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Cutoff" bpmnElement="Event_Cutoff">
        <dc:Bounds x="543" y="592" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="583" y="612" width="68" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Close" bpmnElement="Activity_Close">
        <dc:Bounds x="1048" y="110" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Night" bpmnElement="Event_Night">
        <dc:Bounds x="1208" y="132" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1189" y="174" width="75" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Activity_Force" bpmnElement="Activity_Force">
        <dc:Bounds x="792" y="250" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Event_Forced" bpmnElement="Event_Forced">
        <dc:Bounds x="952" y="272" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="929" y="314" width="82" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_StartToStart" bpmnElement="Flow_StartToStart">
        <di:waypoint x="206" y="150" />
        <di:waypoint x="266" y="150" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_StartToMode" bpmnElement="Flow_StartToMode">
        <di:waypoint x="366" y="150" />
        <di:waypoint x="426" y="150" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ModeToDay" bpmnElement="Flow_ModeToDay">
        <di:waypoint x="451" y="175" />
        <di:waypoint x="451" y="430" />
        <di:waypoint x="536" y="430" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="459" y="412" width="26" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ModeToWindow" bpmnElement="Flow_ModeToWindow">
        <di:waypoint x="451" y="175" />
        <di:waypoint x="451" y="570" />
        <di:waypoint x="536" y="570" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="459" y="552" width="26" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_DayToDay" bpmnElement="Flow_DayToDay">
        <di:waypoint x="636" y="430" />
        <di:waypoint x="696" y="430" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_WindowToClose" bpmnElement="Flow_WindowToClose">
        <di:waypoint x="636" y="570" />
        <di:waypoint x="1098" y="570" />
        <di:waypoint x="1098" y="190" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CutoffToForce" bpmnElement="Flow_CutoffToForce">
        <di:waypoint x="561" y="628" />
        <di:waypoint x="561" y="643" />
        <di:waypoint x="842" y="643" />
        <di:waypoint x="842" y="330" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CloseToNight" bpmnElement="Flow_CloseToNight">
        <di:waypoint x="1148" y="150" />
        <di:waypoint x="1208" y="150" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ForceToForced" bpmnElement="Flow_ForceToForced">
        <di:waypoint x="892" y="290" />
        <di:waypoint x="952" y="290" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Activity_Window">
    <bpmndi:BPMNPlane id="BPMNPlane_Activity_Window" bpmnElement="Activity_Window">
      <bpmndi:BPMNShape id="BPMNShape_Inner_Start" bpmnElement="Inner_Start">
        <dc:Bounds x="80" y="121" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="71" y="163" width="54" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_Run" bpmnElement="Inner_Run">
        <dc:Bounds x="176" y="99" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_Catch" bpmnElement="Inner_Catch">
        <dc:Bounds x="233" y="161" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="273" y="181" width="61" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_Save" bpmnElement="Inner_Save">
        <dc:Bounds x="336" y="99" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_Error" bpmnElement="Inner_Error">
        <dc:Bounds x="336" y="258" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_Wait" bpmnElement="Inner_Wait">
        <dc:Bounds x="496" y="258" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Inner_End" bpmnElement="Inner_End">
        <dc:Bounds x="766" y="121" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="757" y="163" width="54" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_Gateway_MergeEnd" bpmnElement="Gateway_MergeEnd" isMarkerVisible="true">
        <dc:Bounds x="656" y="114" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_StartToRun" bpmnElement="Flow_StartToRun">
        <di:waypoint x="116" y="139" />
        <di:waypoint x="176" y="139" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_RunToSave" bpmnElement="Flow_RunToSave">
        <di:waypoint x="276" y="139" />
        <di:waypoint x="336" y="139" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_CatchToError" bpmnElement="Flow_CatchToError">
        <di:waypoint x="251" y="197" />
        <di:waypoint x="251" y="298" />
        <di:waypoint x="336" y="298" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_SaveToMergeEnd" bpmnElement="Flow_SaveToMergeEnd">
        <di:waypoint x="436" y="139" />
        <di:waypoint x="656" y="139" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_ErrorToWait" bpmnElement="Flow_ErrorToWait">
        <di:waypoint x="436" y="298" />
        <di:waypoint x="496" y="298" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_WaitToMergeEnd" bpmnElement="Flow_WaitToMergeEnd">
        <di:waypoint x="596" y="298" />
        <di:waypoint x="681" y="298" />
        <di:waypoint x="681" y="164" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_Flow_MergeEndToEnd" bpmnElement="Flow_MergeEndToEnd">
        <di:waypoint x="706" y="139" />
        <di:waypoint x="766" y="139" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
