示例#1
0
        public bool setServerID(SERVER_INFO svr)
        {
            string cmd = "setServerID";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            try
            {
                StringBuilder sbReq = new StringBuilder();

                string enable = "false";
                if (svr.enable)
                    enable = "true";

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));
                sbReq.Append(String.Format("&server_id={0}&desc={1}", svr.id, svr.desc));
                sbReq.Append(String.Format("&server_ip={0}&server_port={1}&enable={2}", svr.ip, svr.server_port, enable));
                sbReq.Append(String.Format("&reader_ip={0}&mode={1}", svr.reader_port, svr.mode));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null) return false;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resp);
                if (isCSLResponse(ref doc, cmd) == false) return false;

                XmlNode node = doc.SelectSingleNode("CSL/Ack");
                if (node != null)
                {
                    if (node.InnerXml.StartsWith("OK", StringComparison.OrdinalIgnoreCase))
                    {
                        ErrorCode = ERR_CODE_NO_ERROR;
                        ErrorMsg = "";
                        return true;
                    }
                }
                parseErrorCode(ref doc);
                return false;
            }
            catch
            {
                ErrorCode = ERR_CODE_UNKNOWN_ERROR;
                ErrorMsg = ERR_MSG_UNKNOWN_ERROR;
                return false;
            }
        }
示例#2
0
        private bool setupReader()
        {
            if (reader.connect() == false)
            {
                tsslStatus.Text = "Cannot connect to reader";
                return false;
            }

            //Disable all events
            System.Collections.ArrayList eventList;
            eventList = reader.listEvent();
            if (eventList != null)
            {
                foreach (EVENT_INFO e in eventList)
                {
                    reader.enableEvent(e.id, false);
                }
            }

            //Setup Operation Profile
            OPERATION_PROFILE profile = new OPERATION_PROFILE();

            profile.profile_id = "Default Profile";
            profile.profile_enable = true;
            profile.modulation_profile = settings.Text("CS461/Reader/ModulationProfile", "Profile0");
            profile.population = settings.Int16("CS461/Reader/PopulationEstimation", 10);
            profile.session_no = settings.Int16("CS461/Reader/Session", 1);
            profile.ant1_power = settings.Text("CS461/Reader/Antennas/Ant1/Power", "30.00");
            profile.ant2_power = settings.Text("CS461/Reader/Antennas/Ant2/Power", "30.00");
            profile.ant3_power = settings.Text("CS461/Reader/Antennas/Ant3/Power", "30.00");
            profile.ant4_power = settings.Text("CS461/Reader/Antennas/Ant4/Power", "30.00");
            profile.ant1_enable = settings.Boolean("CS461/Reader/Antennas/Ant1/Enabled", false);
            profile.ant2_enable = settings.Boolean("CS461/Reader/Antennas/Ant2/Enabled", false);
            profile.ant3_enable = settings.Boolean("CS461/Reader/Antennas/Ant3/Enabled", false);
            profile.ant4_enable = settings.Boolean("CS461/Reader/Antennas/Ant4/Enabled", false);
            profile.window_time = settings.Int16("CS461/Reader/DuplicationElimination/Time", 1000);
            profile.trigger = settings.Text("CS461/Reader/DuplicationElimination/Method", "Autonomous Time Trigger");
            profile.capture_mode = "Time Window";
            profile.tagModel = settings.Text("CS461/Reader/TagIC", "GenericTID32");
            profile.memoryBank = settings.Text("CS461/Reader/AdditionalMemoryBank", "None");
            profile.antennaPortScheme = settings.Text("CS461/Reader/DuplicationElimination/AntennaPortScheme", "true");

            if (reader.setOperProfile_TxPowers(profile) == false)
            {
                tsslStatus.Text = "Fail to set operation profile";
                return false;
            }

            //Setup Trusted Server
            SERVER_INFO svr = new SERVER_INFO();
            svr.id = "AccessControlDemoServer";
            svr.desc = "Access Control Demo Server";
            svr.ip = settings.Text("CS461/Application/LocalIP", "0.0.0.0");
            svr.server_port = settings.Text("CS461/Application/ServerPort", "9090");
            svr.mode = "Listening Port on Server Side";
            svr.enable = true;

            if (reader.setServerID(svr) == false)
            {
                if (reader.modServerID(svr) == false)
                {
                    tsslStatus.Text = "Fail to set trusted server";
                    return false;
                }
            }

            //Setup Triggering Logic
            reader.delTriggeringLogic("AccessControlDemoLogic");

            TRIGGER_INFO trigger = new TRIGGER_INFO();
            trigger.id = "AccessControlDemoLogic";
            trigger.desc = "Access Control Demo";
            trigger.mode = "Read Any Tags (any ID, 1 trigger per tag)"; //For firmware 2.1.0 or later
            trigger.capture_point = "";
            trigger.capture_point += settings.Boolean("CS461/Reader/Antennas/Ant1/Enabled", false) ? "1" : "";
            trigger.capture_point += settings.Boolean("CS461/Reader/Antennas/Ant2/Enabled", false) ? "2" : "";
            trigger.capture_point += settings.Boolean("CS461/Reader/Antennas/Ant3/Enabled", false) ? "3" : "";
            trigger.capture_point += settings.Boolean("CS461/Reader/Antennas/Ant4/Enabled", false) ? "4" : "";

            if (reader.addTriggeringLogic(trigger) == false)
            {
                trigger.mode = "Read Any Tags";     //For firmware 2.0.9, 2.0.10
                if (reader.addTriggeringLogic(trigger) == false)
                {
                    tsslStatus.Text = "Fail to set triggering logic";
                    return false;
                }
            }

            //Setup Resultant Action
            reader.delResultantAction("AccessControlDemoAction");

            RESULTANT_ACTION_INFO action1 = new RESULTANT_ACTION_INFO();
            action1.id = "AccessControlDemoAction";
            action1.desc = "Access Control Demo";
            if (profile.trigger.Equals("Autonomous Time Trigger") == true)
            {
                action1.mode = "Instant Alert to Server";
            }
            else
            {
                action1.mode = "Batch Alert to Server";
            }
            action1.server_id = svr.id;
            action1.report_id = "Default Report";

            if (reader.addResultantAction(action1) == false)
            {
                tsslStatus.Text = "Fail to set resultant action";
                return false;
            }

            //Setup Event
            reader.delEvent("AccessControlDemoEvent");

            EVENT_INFO eventInfo = new EVENT_INFO();
            eventInfo.id = "AccessControlDemoEvent";
            eventInfo.desc = "Access Control Demo";
            eventInfo.profile = profile.profile_id;
            eventInfo.trigger = trigger.id;
            eventInfo.action = action1.id;
            eventInfo.log = false;
            eventInfo.enable = true;
            eventInfo.enabling = "Always On";
            eventInfo.disabling = "Never Stop";

            if (reader.addEvent(eventInfo) == false)
            {
                tsslStatus.Text = "Fail to set event";
                return false;
            }

            return true;
        }
示例#3
0
        public System.Collections.ArrayList listServer()
        {
            string cmd = "listServer";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            System.Collections.ArrayList list = new System.Collections.ArrayList();

            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null) return null;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resp);
                if (isCSLResponse(ref doc, cmd) == false) return null;

                XmlNode node = doc.SelectSingleNode("CSL/ServerList/Server");
                if (node != null)
                {
                    while (node != null)
                    {
                        SERVER_INFO si = new SERVER_INFO();
                        si.enable = false;

                        XmlAttributeCollection atts = node.Attributes;
                        si.id = atts.GetNamedItem("server_id").Value;
                        si.desc = atts.GetNamedItem("desc").Value;
                        si.ip = atts.GetNamedItem("server_ip").Value;
                        si.server_port = atts.GetNamedItem("server_port").Value;
                        si.reader_port = atts.GetNamedItem("reader_port").Value;
                        si.mode = atts.GetNamedItem("mode").Value;
                        if (atts.GetNamedItem("enable").Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                            si.enable = true;

                        list.Add(si);
                        node = node.NextSibling;
                    }
                    ErrorCode = ERR_CODE_NO_ERROR;
                    ErrorMsg = "";

                    return list;
                }

                parseErrorCode(ref doc);
                return null;
            }
            catch
            {
                ErrorCode = ERR_CODE_UNKNOWN_ERROR;
                ErrorMsg = ERR_MSG_UNKNOWN_ERROR;
                return null;
            }
        }