Commit e9d3feca68664ceac3591568b980f06f3a6effb7
1 parent
064d2ecd
Exists in
AFDemo_Ex4
AFDemo_Ex04
Showing
3 changed files
with
55 additions
and
31 deletions
Show diff stats
AF-Demo/src/af/interfaces/AFState.java
| @@ -4,4 +4,5 @@ public interface AFState { | @@ -4,4 +4,5 @@ public interface AFState { | ||
| 4 | public String IDLE = "IDLE"; | 4 | public String IDLE = "IDLE"; |
| 5 | public String W_E01Res = "W_DBRes"; | 5 | public String W_E01Res = "W_DBRes"; |
| 6 | public String W_ARes = "W_ARes"; | 6 | public String W_ARes = "W_ARes"; |
| 7 | + public String END = "END"; | ||
| 7 | } | 8 | } |
AF-Demo/src/af/state/StateIdle.java
| @@ -4,6 +4,7 @@ import java.util.ArrayList; | @@ -4,6 +4,7 @@ import java.util.ArrayList; | ||
| 4 | 4 | ||
| 5 | import af.instatnce.E01Instance; | 5 | import af.instatnce.E01Instance; |
| 6 | import af.instatnce.EC02Instance; | 6 | import af.instatnce.EC02Instance; |
| 7 | +import af.instatnce.EQXRawInstance; | ||
| 7 | import af.interfaces.AFEvent; | 8 | import af.interfaces.AFEvent; |
| 8 | import af.interfaces.AFState; | 9 | import af.interfaces.AFState; |
| 9 | import af.interfaces.EQXMsg; | 10 | import af.interfaces.EQXMsg; |
| @@ -16,41 +17,56 @@ import ec02.af.utils.AlarmCategory; | @@ -16,41 +17,56 @@ import ec02.af.utils.AlarmCategory; | ||
| 16 | import ec02.af.utils.AlarmSeverity; | 17 | import ec02.af.utils.AlarmSeverity; |
| 17 | import ec02.af.utils.AlarmType; | 18 | import ec02.af.utils.AlarmType; |
| 18 | 19 | ||
| 19 | -public class StateIdle implements IAFState { | 20 | +public class StateIdle implements IAFState { |
| 20 | private String eqxState = null; | 21 | private String eqxState = null; |
| 21 | private EC02Builder ec02Builder = new EC02Builder(); | 22 | private EC02Builder ec02Builder = new EC02Builder(); |
| 22 | private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); | 23 | private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); |
| 23 | - | 24 | + |
| 24 | @Override | 25 | @Override |
| 25 | public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { | 26 | public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { |
| 26 | EC02Instance ec02Ins = (EC02Instance) instance; | 27 | EC02Instance ec02Ins = (EC02Instance) instance; |
| 27 | - | ||
| 28 | - for(EquinoxRawData eqxRawData : eqxRawDataList){ | 28 | + |
| 29 | + for (EquinoxRawData eqxRawData : eqxRawDataList) { | ||
| 29 | this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | 30 | this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); |
| 30 | ec02Ins.getAFInstance().setInvoke(eqxRawData.getInvoke()); | 31 | ec02Ins.getAFInstance().setInvoke(eqxRawData.getInvoke()); |
| 31 | ec02Ins.getAFInstance().setOrig(eqxRawData.getRawDataAttribute(EQXMsg.ORIG)); | 32 | ec02Ins.getAFInstance().setOrig(eqxRawData.getRawDataAttribute(EQXMsg.ORIG)); |
| 33 | + | ||
| 34 | + /* | ||
| 35 | + * if(eqxRawData.getRawEventType().equals(AFEvent. | ||
| 36 | + * Incoming_HTTP_Request)){ E01Instance e01Ins = new E01Instance(); | ||
| 37 | + * ArrayList<String> keys = new ArrayList<String>(); | ||
| 38 | + * keys.add(eqxRawData.getRawDataMessage()); keys.add("def"); | ||
| 39 | + * keys.add("def"); keys.add("def"); keys.add("def"); | ||
| 40 | + * e01Ins.setCmd("search"); e01Ins.setObjType("TESTDATA"); | ||
| 41 | + * e01Ins.setKey(keys); // e01Ins.setId("01"); | ||
| 42 | + * ec02Ins.setE01Ins(e01Ins); this.ec02Builder.getE01Request(); | ||
| 43 | + * String [] parameter = {""}; | ||
| 44 | + * abstractAF.getUtils().writeLog("mylog1", "hello word!!!"); | ||
| 45 | + * abstractAF.getUtils().incrementStats("my_stat"); | ||
| 46 | + * abstractAF.getUtils().incrementStats("raise_by_stat"); | ||
| 47 | + * abstractAF.getUtils().raiseAlarm("my_alarm", parameter, | ||
| 48 | + * AlarmSeverity.WARNING, AlarmCategory.APPLICATION, | ||
| 49 | + * AlarmType.Normal); this.eqxState = AFState.W_E01Res; } | ||
| 50 | + */ | ||
| 51 | + ArrayList<EQXRawInstance> eqxRawList = new ArrayList<EQXRawInstance>(); | ||
| 52 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | ||
| 53 | + eqxRaw.setMessage("B1 Req."); | ||
| 54 | + eqxRaw.setTo(abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-B").get(0)); | ||
| 55 | + eqxRaw.setCtype(EQXMsg.TEXTXML); | ||
| 56 | + eqxRawList.add(eqxRaw); | ||
| 57 | + | ||
| 58 | + EQXRawInstance eqxRaw2 = new EQXRawInstance(); | ||
| 59 | + eqxRaw2.setMessage("B2 Req."); | ||
| 60 | + eqxRaw2.setTo(abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-B").get(0)); | ||
| 61 | + eqxRaw2.setCtype(EQXMsg.TEXTXML); | ||
| 62 | + eqxRawList.add(eqxRaw2); | ||
| 63 | + | ||
| 64 | + ArrayList<EquinoxRawData> rawList = this.ec02Builder.getHTTPRequest(eqxRawList); | ||
| 65 | + for (int i = 0; i < rawList.size(); i++) { | ||
| 66 | + this.eqxRawDataList.add(rawList.get(i)); | ||
| 67 | + } | ||
| 68 | + this.eqxState = AFState.W_ARes; | ||
| 32 | 69 | ||
| 33 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_HTTP_Request)){ | ||
| 34 | - E01Instance e01Ins = new E01Instance(); | ||
| 35 | - ArrayList<String> keys = new ArrayList<String>(); | ||
| 36 | - keys.add(eqxRawData.getRawDataMessage()); | ||
| 37 | - keys.add("def"); | ||
| 38 | - keys.add("def"); | ||
| 39 | - keys.add("def"); | ||
| 40 | - keys.add("def"); | ||
| 41 | - e01Ins.setCmd("search"); | ||
| 42 | - e01Ins.setObjType("TESTDATA"); | ||
| 43 | - e01Ins.setKey(keys); | ||
| 44 | -// e01Ins.setId("01"); | ||
| 45 | - ec02Ins.setE01Ins(e01Ins); | ||
| 46 | - this.ec02Builder.getE01Request(); | ||
| 47 | - String [] parameter = {""}; | ||
| 48 | - abstractAF.getUtils().writeLog("mylog1", "hello word!!!"); | ||
| 49 | - abstractAF.getUtils().incrementStats("my_stat"); | ||
| 50 | - abstractAF.getUtils().incrementStats("raise_by_stat"); | ||
| 51 | - abstractAF.getUtils().raiseAlarm("my_alarm", parameter, AlarmSeverity.WARNING, AlarmCategory.APPLICATION, AlarmType.Normal); | ||
| 52 | - this.eqxState = AFState.W_E01Res; | ||
| 53 | - } | ||
| 54 | } | 70 | } |
| 55 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); | 71 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 56 | return this.eqxState; | 72 | return this.eqxState; |
AF-Demo/src/af/state/StateWaitA.java
| @@ -24,8 +24,9 @@ public class StateWaitA implements IAFState { | @@ -24,8 +24,9 @@ public class StateWaitA implements IAFState { | ||
| 24 | EC02Instance ec02Ins = (EC02Instance)instance; | 24 | EC02Instance ec02Ins = (EC02Instance)instance; |
| 25 | 25 | ||
| 26 | for(EquinoxRawData eqxRawData : eqxRawDataList) { | 26 | for(EquinoxRawData eqxRawData : eqxRawDataList) { |
| 27 | - this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | ||
| 28 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_A_Response)){ | 27 | + this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); |
| 28 | + | ||
| 29 | + /*if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_A_Response)){ | ||
| 29 | StringExtract str = new StringExtract(); | 30 | StringExtract str = new StringExtract(); |
| 30 | HashMap<String, String> map = str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())); | 31 | HashMap<String, String> map = str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())); |
| 31 | String message = map.get("MSG[0].value"); | 32 | String message = map.get("MSG[0].value"); |
| @@ -35,12 +36,18 @@ public class StateWaitA implements IAFState { | @@ -35,12 +36,18 @@ public class StateWaitA implements IAFState { | ||
| 35 | eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | 36 | eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); |
| 36 | eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | 37 | eqxRaw.setCtype(EQXMsg.TEXTPLAIN); |
| 37 | this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); | 38 | this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); |
| 38 | - this.eqxState = AFState.IDLE; | ||
| 39 | - } | 39 | + this.eqxState = AFState.END; |
| 40 | + /*} | ||
| 40 | else { | 41 | else { |
| 41 | 42 | ||
| 42 | - } | ||
| 43 | - } | 43 | + }*/ |
| 44 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | ||
| 45 | + eqxRaw.setMessage("A Res."); | ||
| 46 | + eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | ||
| 47 | + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | ||
| 48 | + this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); | ||
| 49 | + this.eqxState = AFState.END; | ||
| 50 | + | ||
| 44 | } | 51 | } |
| 45 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); | 52 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 46 | return this.eqxState; | 53 | return this.eqxState; |