Example #1
0
        public bool addTriggeringLogic(TRIGGER_INFO info)
        {
            string cmd = "addTriggeringLogic";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));
                sbReq.Append(String.Format("&logic_id={0}&desc={1}&mode={2}", info.id, info.desc, info.mode));
                if (info.capture_point != "")
                    sbReq.Append(String.Format("&capture_point={0}", info.capture_point));
                if (info.logic != "")
                    sbReq.Append(String.Format("&logic={0}", info.logic));

                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)
                {
                    string value = node.InnerXml;
                    if (value.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;
            }
        }
Example #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;
        }
Example #3
0
        public System.Collections.ArrayList listTriggeringLogic()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();

            string cmd = "listTriggeringLogic";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            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/TriggeringLogic/logic");
                if (node != null)
                {
                    while (node != null)
                    {
                        TRIGGER_INFO info = new TRIGGER_INFO();

                        XmlAttributeCollection atts = node.Attributes;
                        info.id = atts.GetNamedItem("logic_id").Value;
                        info.desc = atts.GetNamedItem("desc").Value;
                        info.mode = atts.GetNamedItem("mode").Value;
                        info.capture_point = atts.GetNamedItem("capture_point").Value;
                        info.logic = atts.GetNamedItem("logic").Value;

                        list.Add(info);
                        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;
            }
        }