Commit c612d553a9d87b85934e0d2c3afe27068409b44a
1 parent
064d2ecd
Exists in
AFDemo_Ex8
AFDemo_Ex08
Showing
6 changed files
with
106 additions
and
24 deletions
Show diff stats
AF-Demo/src/af/control/StateManager.java
| @@ -4,6 +4,7 @@ import af.interfaces.AFState; | @@ -4,6 +4,7 @@ import af.interfaces.AFState; | ||
| 4 | import af.state.StateIdle; | 4 | import af.state.StateIdle; |
| 5 | import af.state.StateWaitE01; | 5 | import af.state.StateWaitE01; |
| 6 | import af.state.StateWaitA; | 6 | import af.state.StateWaitA; |
| 7 | +import af.state.StateWaitC; | ||
| 7 | import ec02.af.abstracts.AbstractAFStateManager; | 8 | import ec02.af.abstracts.AbstractAFStateManager; |
| 8 | 9 | ||
| 9 | public class StateManager extends AbstractAFStateManager { | 10 | public class StateManager extends AbstractAFStateManager { |
| @@ -18,5 +19,8 @@ public class StateManager extends AbstractAFStateManager { | @@ -18,5 +19,8 @@ public class StateManager extends AbstractAFStateManager { | ||
| 18 | else if (state.equals(AFState.W_ARes)) { | 19 | else if (state.equals(AFState.W_ARes)) { |
| 19 | this.afState = new StateWaitA(); | 20 | this.afState = new StateWaitA(); |
| 20 | } | 21 | } |
| 22 | + else if (state.equals(AFState.W_CRes)) { | ||
| 23 | + this.afState = new StateWaitC(); | ||
| 24 | + } | ||
| 21 | } | 25 | } |
| 22 | } | 26 | } |
AF-Demo/src/af/interfaces/AFState.java
| @@ -2,6 +2,8 @@ package af.interfaces; | @@ -2,6 +2,8 @@ package af.interfaces; | ||
| 2 | 2 | ||
| 3 | public interface AFState { | 3 | public interface AFState { |
| 4 | public String IDLE = "IDLE"; | 4 | public String IDLE = "IDLE"; |
| 5 | + public String END = "END"; | ||
| 5 | public String W_E01Res = "W_DBRes"; | 6 | public String W_E01Res = "W_DBRes"; |
| 6 | public String W_ARes = "W_ARes"; | 7 | public String W_ARes = "W_ARes"; |
| 8 | + public String W_CRes = "W_CRes"; | ||
| 7 | } | 9 | } |
AF-Demo/src/af/message/EC02Builder.java
| @@ -39,10 +39,10 @@ public class EC02Builder { | @@ -39,10 +39,10 @@ public class EC02Builder { | ||
| 39 | return eqxRawDataList; | 39 | return eqxRawDataList; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - public EquinoxRawData getHTTPResponse(EQXRawInstance eqxRaw){ | 42 | + public EquinoxRawData getHTTPResponse(EQXRawInstance eqxRaw,String Invoke){ |
| 43 | eqxRaw.setType(EQXMsg.RESPONSE); | 43 | eqxRaw.setType(EQXMsg.RESPONSE); |
| 44 | this.msgBuilder = new EC02MSGBuilder(eqxRaw); | 44 | this.msgBuilder = new EC02MSGBuilder(eqxRaw); |
| 45 | - this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); | 45 | + this.msgBuilder.setInvoke(Invoke); |
| 46 | return this.msgBuilder.getHttpMessage(); | 46 | return this.msgBuilder.getHttpMessage(); |
| 47 | } | 47 | } |
| 48 | 48 |
AF-Demo/src/af/state/StateIdle.java
| @@ -30,7 +30,7 @@ public class StateIdle implements IAFState { | @@ -30,7 +30,7 @@ public class StateIdle implements IAFState { | ||
| 30 | ec02Ins.getAFInstance().setInvoke(eqxRawData.getInvoke()); | 30 | ec02Ins.getAFInstance().setInvoke(eqxRawData.getInvoke()); |
| 31 | ec02Ins.getAFInstance().setOrig(eqxRawData.getRawDataAttribute(EQXMsg.ORIG)); | 31 | ec02Ins.getAFInstance().setOrig(eqxRawData.getRawDataAttribute(EQXMsg.ORIG)); |
| 32 | 32 | ||
| 33 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_HTTP_Request)){ | 33 | + /*if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_HTTP_Request)){ |
| 34 | E01Instance e01Ins = new E01Instance(); | 34 | E01Instance e01Ins = new E01Instance(); |
| 35 | ArrayList<String> keys = new ArrayList<String>(); | 35 | ArrayList<String> keys = new ArrayList<String>(); |
| 36 | keys.add(eqxRawData.getRawDataMessage()); | 36 | keys.add(eqxRawData.getRawDataMessage()); |
| @@ -50,7 +50,10 @@ public class StateIdle implements IAFState { | @@ -50,7 +50,10 @@ public class StateIdle implements IAFState { | ||
| 50 | abstractAF.getUtils().incrementStats("raise_by_stat"); | 50 | abstractAF.getUtils().incrementStats("raise_by_stat"); |
| 51 | abstractAF.getUtils().raiseAlarm("my_alarm", parameter, AlarmSeverity.WARNING, AlarmCategory.APPLICATION, AlarmType.Normal); | 51 | abstractAF.getUtils().raiseAlarm("my_alarm", parameter, AlarmSeverity.WARNING, AlarmCategory.APPLICATION, AlarmType.Normal); |
| 52 | this.eqxState = AFState.W_E01Res; | 52 | this.eqxState = AFState.W_E01Res; |
| 53 | - } | 53 | + }*/ |
| 54 | + | ||
| 55 | + this.eqxState = AFState.W_ARes; | ||
| 56 | + | ||
| 54 | } | 57 | } |
| 55 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); | 58 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 56 | return this.eqxState; | 59 | return this.eqxState; |
AF-Demo/src/af/state/StateWaitA.java
| @@ -18,29 +18,47 @@ public class StateWaitA implements IAFState { | @@ -18,29 +18,47 @@ public class StateWaitA implements IAFState { | ||
| 18 | private String eqxState = null; | 18 | private String eqxState = null; |
| 19 | private EC02Builder ec02Builder = new EC02Builder(); | 19 | private EC02Builder ec02Builder = new EC02Builder(); |
| 20 | private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); | 20 | private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); |
| 21 | - | 21 | + |
| 22 | @Override | 22 | @Override |
| 23 | public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { | 23 | public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { |
| 24 | - EC02Instance ec02Ins = (EC02Instance)instance; | ||
| 25 | - | ||
| 26 | - for(EquinoxRawData eqxRawData : eqxRawDataList) { | ||
| 27 | - this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | ||
| 28 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_A_Response)){ | ||
| 29 | - StringExtract str = new StringExtract(); | ||
| 30 | - HashMap<String, String> map = str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())); | ||
| 31 | - String message = map.get("MSG[0].value"); | ||
| 32 | - if (message.trim().equals("SUCCESS")) { | ||
| 33 | - EQXRawInstance eqxRaw = new EQXRawInstance(); | ||
| 34 | - eqxRaw.setMessage(message.trim()); | ||
| 35 | - eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | ||
| 36 | - eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 37 | - this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); | ||
| 38 | - this.eqxState = AFState.IDLE; | ||
| 39 | - } | ||
| 40 | - else { | ||
| 41 | - | ||
| 42 | - } | 24 | + EC02Instance ec02Ins = (EC02Instance) instance; |
| 25 | + | ||
| 26 | + for (EquinoxRawData eqxRawData : eqxRawDataList) { | ||
| 27 | + this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | ||
| 28 | + /* | ||
| 29 | + * if(eqxRawData.getRawEventType().equals(AFEvent. | ||
| 30 | + * Incoming_A_Response)){ StringExtract str = new StringExtract(); | ||
| 31 | + * HashMap<String, String> map = | ||
| 32 | + * str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())) | ||
| 33 | + * ; String message = map.get("MSG[0].value"); if | ||
| 34 | + * (message.trim().equals("SUCCESS")) { EQXRawInstance eqxRaw = new | ||
| 35 | + * EQXRawInstance(); eqxRaw.setMessage(message.trim()); | ||
| 36 | + * eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | ||
| 37 | + * eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 38 | + * this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)) | ||
| 39 | + * ; this.eqxState = AFState.IDLE; } else { | ||
| 40 | + * | ||
| 41 | + * } } | ||
| 42 | + */ | ||
| 43 | + | ||
| 44 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | ||
| 45 | + eqxRaw.setMessage("B Res."); | ||
| 46 | + eqxRaw.setTo(eqxRawData.getOrig()); | ||
| 47 | + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 48 | + this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw, eqxRawData.getInvoke())); | ||
| 49 | + | ||
| 50 | + ArrayList<EQXRawInstance> eqxRawList = new ArrayList<EQXRawInstance>(); | ||
| 51 | + EQXRawInstance eqxRawC = new EQXRawInstance(); | ||
| 52 | + eqxRawC.setMessage("C Req."); | ||
| 53 | + eqxRawC.setTo(abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-C").get(0)); | ||
| 54 | + eqxRawC.setCtype(EQXMsg.TEXTXML); | ||
| 55 | + eqxRawList.add(eqxRaw); | ||
| 56 | + ArrayList<EquinoxRawData> rawList = this.ec02Builder.getHTTPRequest(eqxRawList); | ||
| 57 | + for (int i = 0; i < rawList.size(); i++) { | ||
| 58 | + this.eqxRawDataList.add(rawList.get(i)); | ||
| 43 | } | 59 | } |
| 60 | + this.eqxState = AFState.W_CRes; | ||
| 61 | + | ||
| 44 | } | 62 | } |
| 45 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); | 63 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 46 | return this.eqxState; | 64 | return this.eqxState; |
| @@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
| 1 | +package af.state; | ||
| 2 | + | ||
| 3 | +import java.util.ArrayList; | ||
| 4 | +import java.util.HashMap; | ||
| 5 | + | ||
| 6 | +import th.co.ais.equinox.utils.StringExtract; | ||
| 7 | +import af.instatnce.EC02Instance; | ||
| 8 | +import af.instatnce.EQXRawInstance; | ||
| 9 | +import af.interfaces.AFEvent; | ||
| 10 | +import af.interfaces.AFState; | ||
| 11 | +import af.interfaces.EQXMsg; | ||
| 12 | +import af.message.EC02Builder; | ||
| 13 | +import ec02.af.abstracts.AbstractAF; | ||
| 14 | +import ec02.af.data.EquinoxRawData; | ||
| 15 | +import ec02.af.interfaces.IAFState; | ||
| 16 | + | ||
| 17 | +public class StateWaitC implements IAFState { | ||
| 18 | + private String eqxState = null; | ||
| 19 | + private EC02Builder ec02Builder = new EC02Builder(); | ||
| 20 | + private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { | ||
| 24 | + EC02Instance ec02Ins = (EC02Instance) instance; | ||
| 25 | + | ||
| 26 | + for (EquinoxRawData eqxRawData : eqxRawDataList) { | ||
| 27 | + this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | ||
| 28 | + /* | ||
| 29 | + * if(eqxRawData.getRawEventType().equals(AFEvent. | ||
| 30 | + * Incoming_A_Response)){ StringExtract str = new StringExtract(); | ||
| 31 | + * HashMap<String, String> map = | ||
| 32 | + * str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())) | ||
| 33 | + * ; String message = map.get("MSG[0].value"); if | ||
| 34 | + * (message.trim().equals("SUCCESS")) { EQXRawInstance eqxRaw = new | ||
| 35 | + * EQXRawInstance(); eqxRaw.setMessage(message.trim()); | ||
| 36 | + * eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | ||
| 37 | + * eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 38 | + * this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)) | ||
| 39 | + * ; this.eqxState = AFState.IDLE; } else { | ||
| 40 | + * | ||
| 41 | + * } } | ||
| 42 | + */ | ||
| 43 | + | ||
| 44 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | ||
| 45 | + eqxRaw.setMessage("A Res."); | ||
| 46 | + eqxRaw.setTo(eqxRawData.getOrig()); | ||
| 47 | + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 48 | + this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw, ec02Ins.getAFInstance().getInvoke())); | ||
| 49 | + this.eqxState = AFState.END; | ||
| 50 | + | ||
| 51 | + } | ||
| 52 | + ec02Ins.setEqxRawDataList(this.eqxRawDataList); | ||
| 53 | + return this.eqxState; | ||
| 54 | + } | ||
| 55 | +} |