123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package kr.co.icontrols.wallpadmain.imap;
- import android.content.Context;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
- import com.artncore.wallpadimap.RetProci;
- import com.artncore.wallpadimap.WallPadiMAPClient;
- public class iMAPSmartLightEvent extends WallPadiMAPClient
- {
- private static final String TAG = "iMAPSmartLightEvent";
- String myIP = "NONE";
- String myDong = "NONE";
- String myHo = "NONE";
- Context ctx;
- RetProci Proc;
- String XMLHeader;
- WallpadStatusData DBMGR;
- String ServerIP = "10.0.1.1";
- int SvrPort = 10000;
- public iMAPSmartLightEvent(Context ctx)
- {
- super.setContext(ctx);
- DBMGR = new WallpadStatusData(ctx);
- AddressSet addc = DBMGR.getAddressMGR(); // DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- // 동, 호, ip 정보 저장
- myIP = addc.IPAddress;
- myDong = addc.Dong;
- myHo = addc.Ho;
- // 타임아웃 설정
- SetSocketWaitCount(2000);
- // XML Header 생성
- XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + "<imap ver = \"1.0\" address = \"" + myIP + "\" sender = \"" + myDong + "동 " + myHo
- + "호" + "\">\r\n";
- this.ctx = ctx;
- }
- private String GetXMLSmartLightEvent(String Type, String Device, String DeviceIndex, String CauseType, String CauseDetail)
- {
- String retXML = "";
- retXML = XMLHeader
- + " <service type = \"request\" name= \"smart_light_event\">\r\n"
- + " <request_info name = \"homedev\" id_high=\"" + myDong + "\" id_low=\"" + myHo + "\" type=\"" + "main" + "\" />\r\n"
- + " <event "
- + "type=\"" + Type + "\" "
- + "device=\"" + Device + "\" "
- + "device_index=\"" + DeviceIndex + "\" "
- + "cause_type=\"" + CauseType + "\" "
- + "cause_detail=\"" + CauseDetail + "\" "
- + " />\r\n"
- + " </service>\r\n</imap>";
- return retXML;
- }
- public void SetServerIPcfg(String IPa, int port)
- {
- ServerIP = IPa;
- SvrPort = port;
- }
- public void SetRetCtr(RetProci retProci)
- {
- Proc = retProci;
- }
- @Override
- protected void ProcComplite()
- {
- if (Proc != null)
- {
- SetItem("service");
- String result = GetAttributeVal(0, "result");
- if (result != null)
- {
- if ((result.equalsIgnoreCase("ok")) || (result.equalsIgnoreCase("none")))
- {
- String name = GetAttributeVal(0, "name");
- String type = GetAttributeVal(0, "type");
- if ((name!=null && name.equalsIgnoreCase("smart_light_event")) && (type!=null && type.equalsIgnoreCase("reply")))
- {
- Proc.ProcSuccess();
- return;
- }
- }
- }
- }
- if(Proc!=null) Proc.ProcError();
- }
- @Override
- protected void ProcError()
- {
- Proc.ProcError();
- }
- /**
- * 스마트분전반 이상상태 알림 수행
- * **/
- public void DoWork(String Type, String Device, String DeviceIndex, String CauseType, String CauseDetail)
- {
- SetServerIPConfig(ServerIP, SvrPort);
- String XmlData = GetXMLSmartLightEvent(Type, Device, DeviceIndex, CauseType, CauseDetail);
- if(XmlData != null)
- {
- SendXMLDoc(XmlData, true);
- }
- }
- }
|