void test_实时互动1() { //接收到一个标签数据 MiddleWareCore.set_mode(MiddleWareMode.实时互动); string cmd1 = "[select,master_node,equip000001,stu000001,01,A]"; MiddleWareCore.Set_new_data(ProtocolHelper.getProtocolHelper(cmd1)); IntelligentEvent evt1 = MiddleWareCore.get_a_event(); if (evt1.epcID == "stu000001" && evt1.localDeviceID == "master_node" && evt1.remoteDeviceID == "equip000001" && evt1.questionID == "01" && evt1.questionValue == "A" && evt1.event_unit_list[0] == IntelligentEventUnit.new_epc) { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } //找到该学生的信息,包括学生姓名、位置、选择 //查找学生信息 Person person = MemoryTable.getPersonByEpc(evt1.epcID); if (person.id_num == "CE4D9397871") { Debug.WriteLine("True"); } else { Debug.WriteLine("False"); } }
public void callback() { int carbinetIndex = Program.frmClassRoom.carbinetIndex; int floorNumber = Program.frmClassRoom.floorNumber; int columnNumber = Program.frmClassRoom.columnNumber; string epc = MemoryTable.getPersonEpcByPosition(carbinetIndex, floorNumber, columnNumber); Person p = MemoryTable.getPersonByEpc(epc); frmShowStudentInfo frm = new frmShowStudentInfo(p.id_num); frm.ShowDialog(); }
private void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { IntelligentEvent IEvent = (IntelligentEvent)evt; string epcID = IEvent.epcID; string remoteDeviceID = IEvent.remoteDeviceID; string check_time = IEvent.time_stamp; string studentName = string.Empty; string question_value = IEvent.questionValue.ToUpper();; //终端发送的答案必须符合要求 A B C 或者 D if (question_value != "A" && question_value != "B" && question_value != "C" && question_value != "D") { return; } //1 更改本地信息 //2 更改饼图 //3 更改座位状态 int totalCount = MemoryTable.studentInfoTable.Rows.Count; Person person = MemoryTable.getPersonByEpc(epcID); equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID); if (ep != null) { if (IEvent.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { ////这里要处理一下同一个学生用不一个设备发送答案的情况 equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID); this.setChairState(ep_old, DocumentFileState.InitialState, ""); MemoryTable.clearEquipmentAndStudentCombining(epcID); } if (person != null) { studentName = person.name; this.setChairState(ep, studentName); MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc); this.setPersonAnswer(person.id_num, question_value); } DocumentFileState dfs = this.getStateByAnswer(question_value); this.setChairState(ep, dfs); this.refreshPie(); } } }
private void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { IntelligentEvent p = (IntelligentEvent)evt; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string studentName = string.Empty; bool bRefresh_ui = false; Person person = MemoryTable.getPersonByEpc(epcID); equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID); if (person != null && ep != null) { if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)//重复考勤 { ////这里要处理一下同一个学生用不一个设备发送答案的情况 equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID); this.setChairState(ep_old, DocumentFileState.InitialState, ""); MemoryTable.clearEquipmentAndStudentCombining(epcID); bRefresh_ui = true; } if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)//第一次考勤 { //更新考勤信息 this.addStudentRecord(person.id_num, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); bRefresh_ui = true; } if (bRefresh_ui == true) { if (person != null) { studentName = person.name; this.setChairState(ep, studentName); MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc); } this.refreshPie(); } } } }
//设置当前题目的答题状态 private void reset_test_status(string question_id) { DataRow[] rows = this.dtQuestion_answer_record.Select(string.Format("question_id = '{0}'", question_id)); int total_student_count = MemoryTable.studentInfoTable.Rows.Count; int iAnswered = rows.Length; int iUnknown = total_student_count - iAnswered; NotifyFormToRefreshPie(this.getValueList(iUnknown, iAnswered), true); MiddleWareCore.set_mode(MiddleWareMode.课堂测验); Program.frmClassRoom.resetClassRoomState(); //设置教室座位 根据问题查找学生ID,然后根据ID查找位置 for (int i = 0; i < rows.Length; i++) { string studentID = (string)rows[i]["student_id"]; equipmentPosition ep = MemoryTable.getEquipmentInfoByEpc(studentID); Person psn = MemoryTable.getPersonByEpc(studentID); Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), DocumentFileState.Green); Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), psn.name); } }
private void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { deleControlInvoke dele = delegate(object o) { IntelligentEvent p = (IntelligentEvent)o; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string question_value = p.questionValue; int totalCount = MemoryTable.studentInfoTable.Rows.Count; Person person = MemoryTable.getPersonByEpc(epcID); equipmentPosition ep = MemoryTable.getEquipmentConfigMapInfoByDeviceID(remoteDeviceID); //如果只是重复发送,不需要做什么 if (p.event_unit_list.IndexOf(IntelligentEventUnit.repeat_epc) >= 0) { //如果重复发送之外,还改变了设备的ID if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { if (person != null && ep != null) { int groupIndex = ep.group; equipmentPosition ep_old = MemoryTable.getEquipmentInfoByEpc(epcID); Program.frmClassRoom.changeChairState(ep_old.group, ep_old.formatedPosition(), DocumentFileState.InitialState); Program.frmClassRoom.changeChairState(ep_old.group, ep_old.formatedPosition(), ""); MemoryTable.clearEquipmentAndStudentCombining(epcID); Program.frmClassRoom.changeChairState(groupIndex, ep.formatedPosition(), person.name); MemoryTable.setEquipmentInfoCombineStudentID(ep, person.epc); Program.frmClassRoom.changeChairState(groupIndex, ep.formatedPosition(), DocumentFileState.Green); } } //如果重复发送之外,还改变了问题的答案,按照设计,这里不需要更改饼图 if (p.event_unit_list.IndexOf(IntelligentEventUnit.change_answer) >= 0) { this.refreshAnswerRecord(person, question_value); } } else if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0) { //处理该事件需要更新数据和显示页面 if (person != null && ep != null) { MemoryTable.setEquipmentInfoCombineStudentID(ep, epcID); Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), DocumentFileState.Green); Program.frmClassRoom.changeChairState(ep.group, ep.formatedPosition(), person.name); } this.refreshAnswerRecord(person, question_value); this.refreshPie(); } }; this.Invoke(dele, evt); } }
static void OnReceiveRFID(IAsyncResult ar) { try { IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0); EndPoint epSender = (EndPoint)ipeSender; RFID_ServerSocket.EndReceiveFrom(ar, ref epSender); string strReceived = Encoding.UTF8.GetString(byteData); Array.Clear(byteData, 0, byteData.Length); Debug.WriteLine("OnReceiveRFID => " + strReceived); //先假设接收到的都是卡号 //查找学生信息里面有没有该卡号,如果有的话,广播卡号和学号,可以附带未使用的设备号 //格式为 [epc,id,equipmentID] string epc = strReceived.Substring(0, strReceived.IndexOf("\0")); epcList.Add(epc); string strToBroadcast = string.Empty; Person person = MemoryTable.getPersonByEpc(epc); if (person != null) { string equipmentID = string.Empty; equipmentPosition ep = MemoryTable.getEquipmentInfoByEpc(epc); if (ep == null) { ep = MemoryTable.getEquipmentInfoNotUsed(); } if (ep != null) { equipmentID = ep.equipmentID; } strToBroadcast = string.Format("[id,{0},epc,{1},equipmentID,{2}]", person.id_num, epc, equipmentID); //strToBroadcast = string.Format("[id,{0},epc,{1}]", person.id_num, epc); Broadcast(strToBroadcast); //Regex regex = new Regex(@"\[(?<epc>\w+),(?<id>\w+)\]"); //MatchCollection matches = regex.Matches(strToBroadcast); //foreach (Match mc in matches) //{ // string epc_match = mc.Groups["epc"].Value; // string id_match = mc.Groups["id"].Value; // Debug.WriteLine(string.Format("Match => epc = {0} student ID = {1}", epc_match, id_match)); //} //equipmentPosition ep = MemoryTable.getEquipmentInfoByEpc(epc); //if (ep == null)//学生尚未绑定座位位置,为其选择一个空的位置 //{ //} //else //{ // strToBroadcast = string.Format("[{0},{1}]", epc, person.id_num); //} } //Start listening to the message send by the user RFID_ServerSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnReceiveRFID), epSender); } catch (Exception ex) { Debug.WriteLine("OnReceiveRFID => " + ex.Message); } }