예제 #1
0
        public bool setOperProfile_TxPowers(OPERATION_PROFILE profile)
        {
            string cmd = "setOperProfile";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            try
            {
                StringBuilder sbReq = new StringBuilder();
                string enable = "false";
                if (profile.profile_enable)
                    enable = "true";
                string antennaPort = "";
                if (profile.ant1_enable)
                    antennaPort += "1";
                if (profile.ant2_enable)
                    antennaPort += "2";
                if (profile.ant3_enable)
                    antennaPort += "3";
                if (profile.ant4_enable)
                    antennaPort += "4";

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));
                sbReq.Append(String.Format("&profile_id={0}&captureMode={1}&duplicateEliminationTime={2}", profile.profile_id, profile.capture_mode, profile.window_time));
                sbReq.Append(String.Format("&modulationProfile={0}&populationEst={1}&sessionNo={2}", profile.modulation_profile, profile.population, profile.session_no));
                sbReq.Append(String.Format("&antennaPort={0}&enable={1}", antennaPort, enable));
                sbReq.Append(String.Format("&triggerMethod={0}", profile.trigger));
                sbReq.Append(String.Format("&transmitPower1={0}&&transmitPower2={1}&transmitPower3={2}&transmitPower4={3}", profile.ant1_power, profile.ant2_power, profile.ant3_power, profile.ant4_power));

                sbReq.Append(String.Format("&antennaPortScheme={0}", profile.antennaPortScheme));
                if (profile.memoryBank.Equals("None") == false)
                {
                    sbReq.Append(String.Format("&tagModel={0}&memoryBank={1}", profile.tagModel, profile.memoryBank));
                }

                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 getOperProfile()
        {
            string cmd = "getOperProfile";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            System.Collections.ArrayList list = new System.Collections.ArrayList();
            string cp1_name = null;
            string cp2_name = null;
            string cp3_name = null;
            string cp4_name = null;

            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/CapturePointList/capturepoint");
                if (node != null)
                {
                    while (node != null)
                    {
                        XmlAttributeCollection atts = node.Attributes;
                        if (atts.GetNamedItem("id").Value.Equals("Antenna1"))
                        {
                            cp1_name = atts.GetNamedItem("name").Value;
                        }
                        else if (atts.GetNamedItem("id").Value.Equals("Antenna2"))
                        {
                            cp2_name = atts.GetNamedItem("name").Value;
                        }
                        else if (atts.GetNamedItem("id").Value.Equals("Antenna3"))
                        {
                            cp3_name = atts.GetNamedItem("name").Value;
                        }
                        else if (atts.GetNamedItem("id").Value.Equals("Antenna4"))
                        {
                            cp4_name = atts.GetNamedItem("name").Value;
                        }
                        node = node.NextSibling;
                    }
                }
                node = doc.SelectSingleNode("CSL/ProfileList/profile");
                if (node != null)
                {
                    while (node != null)
                    {
                        OPERATION_PROFILE op = new OPERATION_PROFILE();
                        op.ant1_enable = false;
                        op.ant2_enable = false;
                        op.ant3_enable = false;
                        op.ant4_enable = false;
                        op.profile_enable = false;

                        XmlAttributeCollection atts = node.Attributes;
                        op.profile_id = atts.GetNamedItem("profile_id").Value;
                        op.capture_mode = atts.GetNamedItem("captureMode").Value;
                        op.modulation_profile = atts.GetNamedItem("modulationProfile").Value;
                        Int32.TryParse(atts.GetNamedItem("populationEst").Value, out op.population);
                        if (atts.GetNamedItem("enable").Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                            op.profile_enable = true;
                        Int32.TryParse(atts.GetNamedItem("sessionNo").Value, out op.session_no);
                        op.transmit_power = atts.GetNamedItem("transmitPower").Value;
                        Int32.TryParse(atts.GetNamedItem("duplicateEliminationTime").Value, out op.window_time);
                        op.ant1_name = cp1_name;
                        op.ant2_name = cp2_name;
                        op.ant3_name = cp3_name;
                        op.ant4_name = cp4_name;
                        string ports = atts.GetNamedItem("antennaPort").Value;
                        if (ports.Contains("1"))
                            op.ant1_enable = true;
                        if (ports.Contains("2"))
                            op.ant2_enable = true;
                        if (ports.Contains("3"))
                            op.ant3_enable = true;
                        if (ports.Contains("4"))
                            op.ant4_enable = true;
                        op.trigger = atts.GetNamedItem("triggerMethod").Value;

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