Esempio n. 1
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;
        }
Esempio n. 2
0
        public System.Collections.ArrayList listEvent()
        {
            string cmd = "listEvent";
            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/EventList/event");
                if (node != null)
                {
                    while (node != null)
                    {
                        EVENT_INFO info = new EVENT_INFO();
                        info.enable = false;
                        info.log = false;

                        XmlAttributeCollection atts = node.Attributes;
                        info.id = atts.GetNamedItem("event_id").Value;
                        info.desc = atts.GetNamedItem("desc").Value;
                        info.profile = atts.GetNamedItem("operProfile_id").Value;
                        info.enable = (atts.GetNamedItem("enable").Value.Equals("true", StringComparison.OrdinalIgnoreCase)) ? true : false;
                        /*
                        if (atts.GetNamedItem("enable").Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                            info.enable = true;
                        */
                        info.log = (atts.GetNamedItem("event_log").Value.Equals("true", StringComparison.OrdinalIgnoreCase)) ? true : false;
                        /*
                        if (atts.GetNamedItem("event_log").Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                            info.log = true;
                        */
                        info.enabling = atts.GetNamedItem("inventoryEnablingTrigger").Value;
                        info.disabling = atts.GetNamedItem("inventoryDisablingTrigger").Value;
                        //Optional fields
                        XmlNode n = atts.GetNamedItem("triggering_logic");
                        if (n != null) info.trigger = n.Value;
                        n = atts.GetNamedItem("resultant_action");
                        if (n != null) info.action = n.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;
            }
        }
Esempio n. 3
0
        public bool addEvent(EVENT_INFO info)
        {
            string cmd = "addEvent";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            try
            {
                StringBuilder sbReq = new StringBuilder();
                string eventEnable = "false";
                if (info.enable)
                    eventEnable = "true";
                string eventLog = "false";
                if (info.log)
                    eventLog = "true";

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));
                sbReq.Append(String.Format("&event_id={0}&desc={1}&triggering_logic={2}&operProfile_id={3}", info.id, info.desc, info.trigger, info.profile));
                sbReq.Append(String.Format("&resultant_action={0}&event_log={1}&enable={2}", info.action, eventLog, eventEnable));
                sbReq.Append(String.Format("&inventoryEnablingTrigger={0}&inventoryDisablingTrigger={1}", info.enabling, info.disabling));

                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;
            }
        }
Esempio n. 4
0
        public READER_STATUS getReaderStatus()
        {
            string cmd = "getReaderStatus";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            READER_STATUS status = new READER_STATUS();
            int year, month, day, hour, minute, second;

            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command={1}&username={2}&password={3}", httpUri.AbsoluteUri, cmd, LoginName, LoginPassword));

                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/Model");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Model = atts["name"].InnerXml;
                    status.Protocol_Supported = atts["protocol"].InnerXml;
                }
                else
                {
                    parseErrorCode(ref doc);
                    return null;
                }

                node = doc.SelectSingleNode("CSL/Reader");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Description = atts["desc"].InnerXml;
                    status.ID = atts["reader_id"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/ReaderVersion");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.DSP_Version = atts["dsp"].InnerXml;
                    status.EdgeServer_Version = atts["edgeServer"].InnerXml;
                    status.FPGA_Version = atts["fpga"].InnerXml;
                    status.LibMapi_Version = atts["libMapi"].InnerXml;
                    status.Middleware_Version = atts["middleware"].InnerXml;
                    status.ModemController_Version = atts["modemController"].InnerXml;
                    status.Firmware_Version = atts["version"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/Timezone");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.DaylightSaving = atts["daylight_saving"].InnerXml;
                    status.TimeZone = atts["tz"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/Logout");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Session_Timeout = atts["time"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/UserStatus");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Client_IP = atts["client_ip"].InnerXml;
                    status.Host_IP = atts["host_ip"].InnerXml;
                    status.User_Level = atts["level"].InnerXml;
                    status.Login_Status = atts["login_status"].InnerXml;
                    status.Session_Id = atts["session_id"].InnerXml;
                    status.Username = atts["username"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/AccessMode");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Access_Mode = atts["mode"].InnerXml;
                    status.Access_Mode_Description = atts["name"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/OperationProfile");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Antenna_Ports = atts["antennaPort"].InnerXml;
                    status.Capture_Mode = atts["captureMode"].InnerXml;
                    status.Profile_ID = atts["profile_id"].InnerXml;
                    status.Trigger_Methed = atts["triggerMethod"].InnerXml;
                }

                status.Active_Event = new System.Collections.ArrayList();
                node = doc.SelectSingleNode("CSL/ActiveEventList/Event");
                while (node != null)
                {
                    EVENT_INFO eventInfo = new EVENT_INFO();
                    XmlAttributeCollection atts = node.Attributes;
                    eventInfo.id = atts["event_id"].InnerXml;
                    eventInfo.desc = atts["desc"].InnerXml;
                    status.Active_Event.Add(eventInfo);
                    node = node.NextSibling;
                }

                node = doc.SelectSingleNode("CSL/CurrentLocalTime");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    year = int.Parse(atts["year"].InnerXml);
                    month = int.Parse(atts["month"].InnerXml);
                    day = int.Parse(atts["day"].InnerXml);
                    hour = int.Parse(atts["hour"].InnerXml);
                    minute = int.Parse(atts["minute"].InnerXml);
                    second = int.Parse(atts["second"].InnerXml);
                    status.Local_Time = new DateTime(year, month, day, hour, minute, second);
                }

                node = doc.SelectSingleNode("CSL/CurrentUTCTime");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    year = int.Parse(atts["year"].InnerXml);
                    month = int.Parse(atts["month"].InnerXml);
                    day = int.Parse(atts["day"].InnerXml);
                    hour = int.Parse(atts["hour"].InnerXml);
                    minute = int.Parse(atts["minute"].InnerXml);
                    second = int.Parse(atts["second"].InnerXml);
                    status.UTC_Time = new DateTime(year, month, day, hour, minute, second);
                }

                ErrorCode = ERR_CODE_NO_ERROR;
                ErrorMsg = "";
                return status;
            }
            catch
            {
                ErrorCode = ERR_CODE_UNKNOWN_ERROR;
                ErrorMsg = ERR_MSG_UNKNOWN_ERROR;
                return null;
            }
        }