U
    fd                     @   s   d dl mZ d dlmZ d dl mZ d dlZd dlmZ d dlZd dl	Z	d dlmZ d dl
Z
d dlmZ d dlmZ d dlmZ d	d
 Zdd Zdd ZdS )    )render)messages)redirectN)HttpResponse)JsonResponse)Serial)	get_skillc                 C   s8   t d}| }|d }|dkr&g }t| dd|idS )Nz7https://thingsaccess.com/rfid/index.php/Api/getOperatorresponse   zoperators/operator.htmldata_operator)context)requestsgetjsonr   )requestr	   	data_sendr    r   //var/www/html/myproject/core/operators/views.pyoperator_page   s    
r   c                  C   s   d } t jddddt jd}zzl|  }|rt| z8| }|dd }t	||d  } td|  W qW q t
k
r   Y qX qW n tk
r   Y nX W 5 |  X | S )	NZCOM5i        )portZbaudrateZbytesizetimeoutZstopbitsO   zNumber:)serialr   ZSTOPBITS_ONEclosereadlinestripprintdecodeindexint
ValueErrorKeyboardInterrupt)numberZserdataZdecoded_dataZnumber_start_indexr   r   r   get_operator_tag_id   s$    


r'   c                 C   s,   | j dkr(t }d|i}t| t|S d S )NGETr%   )methodr'   r   r   )r   r%   r	   r   r   r   tag_id_operator   s
    
r*   )django.shortcutsr   django.contribr   r   r   django.httpr   r   timer   r   r   articles.viewsr   r   r'   r*   r   r   r   r   <module>   s   o