In the first two blogs, I have already introduced how to use the dragonbaord 410c to build a smart mirror. The overall design of the system and the database construction plan are analyzed and designed, and the detailed design framework and partial database implementation are given. Code, this section will introduce to you on this basis, how to achieve the function of playing different messages according to different users in the mirror. According to the previous design, we have built the database, and built a pushInfo table in the database to manage the system's messages. The table is designed with the message ID, ownerID and pushID fields. We can easily query the ownerID. The sender of the message, at the same time through the pushID we can query the pusher of the message, so to retrieve the current user's message, we only need to retrieve the user ID in the pushInfo table according to the user ID found by the camera. All the messages of the user are displayed, and two fields of viewWight and isTop are also set in the table to mark the display order of the message. If isTop indicates that the message is to be displayed first, if the user has multiple isTops The message is sorted according to the time, the latest message is displayed at the top, and the message is also displayed according to viewWight. If the field is set to 0, the message has been displayed, no need to display again, according to this rule. , we can design a getTextMessageList in the MagicMirrorDB data management class The (self, userID) function retrieves the message of the specified user, and the results are sorted in the order in which they are displayed. The specific code is as follows: Def getTextMessageList(self,userID): This function will return a list of search results, each message's message ID infoID, pusher ID pushID, message subject: infoContent, message push time: pushTime five content, follow-up we can conveniently display the message according to these five contents And the messages returned here have been sorted according to our rules. In this way, when the message is displayed, we only need to build a MagicMirrorDB class, and then call this method to get the text message of the specified user, and sort it. The specific display can be implemented by the following functions: Def showPushInfo(self,userID): "+msg_info+" Here we use the html support provided by qt, format the obtained message content into the defined message style template, and then call the qt control to display the completion message. Splitter Connectors And Junction Box Connectors Splitter Connectors And Junction Box Connectors,Splitter Three-Way Plug Waterproof Connector,Y-Shaped Three-Way Splitter Waterproof Connector,One Tow Triple Y Waterproof Connector Shenzhen HuaTao Electronic Co., LTD , https://www.htconnector.com
Self.cu.execute("")
Format="select infoID,pushID,infoSubject,infoContent,pushTIme from pushInfo where ownerID==%u and isTop==1 and infoType==0 and viewWeight!=0 order by pushTIme desc"
Values=(userID)
querySQL1=format % values
Self.cu.execute(querySQL1)
Result1=self.cu.fetchone()
Print(querySQL1)
Print(result1)
#print result
Format="select infoID,pushID,infoSubject,infoContent,pushTIme from pushInfo where ownerID=%u and isTop==0 and infoType==0 order by pushTIme desc"
Values=(userID)
querySQL2=format % values
Print(querySQL2)
Self.cu.execute(querySQL2)
Result2=self.cu.fetchone()
Print(result2)
If result1!=None and result2 != None:
#result=result1+result2
Print(result1+result2)
Return result1+result2
Elif result1==None and result2!=None:
#result=result2
Return result2
Elif result1!=None and result2 == None:
#resutl=result1
Return result1
Else:
#result==None
Return None
MMDB=MMDB=MagicMirrorDB("./MagicMirrorDB.db")
#update welcome info by userID
userName=MMDB.getUserName(userID)
Format=" Hello %s Welcome...
"
Values=(userName)
Result=format % values
self.new.helloWelcome.setText(result)
#update pushInfo
#infoID,pushID,infoSubject,infoContent,pushTime
msgList=MMDB.getTextMessageList(userID)
Print("test0")
Print(msgList)
Print("hello")
i=0
pushName=""
Msg_info=""
pushTime=""
msgStr=""
If msgList!=None:
For msg in msgList:
Print(msgList)
If i==1:
Print("test1")
Print(msg)
pushName=MMDB.getUserName(msg)
If i==3:
Msg_info=msg
If i==4:
#pushTime=time.strftime("%Y-%m-%d %H:%M:%S", msg)
msgStr+=(" "+pushName+"to you:"+"
i=i+1
If i==5:
i=0
self.new.webMessageText.setHtml(" ")
self.new.webMemorandum.setHtml(" ")
videoMsgList=MMDB.getUserVideoMessageList(self.current_userID)