Commit 9a689719 authored by Boteju W.J.M.'s avatar Boteju W.J.M.

09/07

parent ff41cba2
Pipeline #1287 canceled with stages
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N812" />
<option value="N806" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
......@@ -44,6 +44,8 @@
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Research\DogBehaviouralSystem\DogBehaviouralSystem\Django\WalkingPatternRecognition\WalkingPatternRecognition" />
<recent name="C:\Research\DogBehaviouralSystem\DogBehaviouralSystem\Django\WalkingPatternRecognition\mobileapp" />
<recent name="C:\Users\ASUS\Desktop\DogBehaviouralSystem\Django\WalkingPatternRecognition\WalkingPatternRecognition" />
</key>
</component>
......@@ -141,16 +143,19 @@
<screen x="1920" y="0" width="1920" height="1040" />
</state>
<state x="2612" y="324" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1593071203993" />
<state x="2610" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1593580754525">
<state x="2610" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1599456440610">
<screen x="1920" y="0" width="1920" height="1040" />
</state>
<state x="2610" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1593580754525" />
<state x="2606" y="216" key="FileChooserDialogImpl" timestamp="1597319516255">
<state x="2610" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1599456440610" />
<state x="2606" y="216" key="FileChooserDialogImpl" timestamp="1599212559698">
<screen x="1920" y="0" width="1920" height="1040" />
</state>
<state x="549" y="171" key="FileChooserDialogImpl/0.0.1536.824/1920.0.1920.1040@0.0.1536.824" timestamp="1597313444704" />
<state x="2606" y="216" key="FileChooserDialogImpl/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1597319516255" />
<state x="549" y="171" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1590316992326" />
<state x="2606" y="216" key="FileChooserDialogImpl/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1599212559698" />
<state x="2000" y="0" key="FileDocumentManager.FileCacheConflict" timestamp="1599458251559">
<screen x="1920" y="0" width="1920" height="1040" />
</state>
<state x="2000" y="0" key="FileDocumentManager.FileCacheConflict/0.0.1536.824/1920.0.1920.1040@1920.0.1920.1040" timestamp="1599458251559" />
<state width="1877" height="347" key="GridCell.Tab.0.bottom" timestamp="1595420765831">
<screen x="1920" y="0" width="1920" height="1040" />
</state>
......@@ -215,6 +220,11 @@
<line>2</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/WalkingPatternRecognition/urls.py</url>
<line>15</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
......
timestamp,Ax,Ay,Az,Gx,Gy,Gz
2020-09-07 15:43:52.514517,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:43:54.514112,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:43:56.516865,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:43:58.543214,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:44:00.502703,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:44:02.510448,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-07 15:44:04.507576,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
......@@ -29,7 +29,7 @@ SECRET_KEY = '^^46u_fc$#)x5ji*s#l3p6igr9*6fwknxevip$ozw8#-m=*#f0'
DEBUG = True
ALLOWED_HOSTS = ['192.168.1.25', 'localhost', '127.0.0.1']
ALLOWED_HOSTS = ['192.168.1.19', 'localhost', '127.0.0.1']
CORS_ORIGIN_ALLOW_ALL = False
......@@ -152,7 +152,8 @@ USE_I18N = True
USE_L10N = True
USE_TZ = True
# USE_TZ = True
USE_TZ = False
# Static files (CSS, JavaScript, Images)
......@@ -167,7 +168,6 @@ STATICFILES_DIRS = [
]
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
......
# Generated by Django 3.0.6 on 2020-05-09 17:22
# Generated by Django 3.0.5 on 2020-09-04 05:42
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
......@@ -8,14 +11,41 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='user',
name='Activity',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_id', models.IntegerField()),
('name', models.CharField(max_length=10)),
('activity_id', models.IntegerField()),
],
),
migrations.CreateModel(
name='Dog',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('birthday', models.DateField()),
('breed', models.CharField(max_length=10)),
('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('U', 'Unknown')], max_length=1)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='MotionActivityPerDay',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField(default=django.utils.timezone.now)),
('activity', models.IntegerField()),
('timePeriod', models.IntegerField()),
('week', models.IntegerField(null=True)),
('month', models.IntegerField(null=True)),
('year', models.IntegerField(null=True)),
('dog', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mobileapp.Dog')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
import django
from django.db import models
# from django.db import models
from djongo import models
from django.utils import timezone
from django.contrib.auth.models import User
......@@ -44,5 +45,3 @@ class MotionActivityPerDay(models.Model):
......@@ -44,6 +44,5 @@ urlpatterns = [
path('highlightsPerYear', views.highlightsPerYear),
# getting the readings
path('getReadings', views.getReadings)
path('readings', views.readings),
]
......@@ -18,17 +18,69 @@ from .serializers import UserSerializer
from datetime import datetime
import calendar
import requests
from django.http import HttpResponse
from django.http import HttpResponse, response, request
from apscheduler.schedulers.background import BackgroundScheduler
import csv
from csv import writer
import pandas as pd
def readings(request):
sched = BackgroundScheduler()
# seconds can be replaced with minutes, hours, or days
sched.add_job(getReadings, 'interval', seconds=2)
sched.start()
return JsonResponse({'data': "Data obtained"}, safe=False, status=status.HTTP_201_CREATED)
@csrf_exempt
def getReadings(request):
response = requests.get('http://192.168.1.42/getReadings')
result = response.text
print(result)
def getReadings():
ReadingsArray = []
responseObtained = requests.get('http://192.168.1.22/getReadings')
result = responseObtained.text
Array = result.split(",")
length = len(Array)
i = 0
while i < length:
reading = Array[i]
ReadingsArray.append(reading.split(":"))
i = i + 1
finalArray = obtainReadings(ReadingsArray)
print(finalArray)
file = open("Readings.csv")
numline = len(file.readlines())
if numline <= 31:
append_list_as_row('Readings.csv', finalArray)
else:
print("time to clear")
with open("Readings.csv", 'r') as f:
with open("Readings.csv", 'w') as f1:
next(f, None)
for line in f:
f1.close()
append_list_as_row('Readings.csv', ['timestamp', 'Ax', 'Ay', 'Az', 'Gx', 'Gy', 'Gz'])
return HttpResponse(response)
def obtainReadings(array):
newReadingArray = [datetime.now()]
length = len(array)
i = 0
while i < length:
newReadingArray.append(array[i][1])
i = i+1
return newReadingArray
def append_list_as_row(file_name, list_of_elem):
with open(file_name, 'a+', newline='') as write_obj:
# Create a writer object from csv module
csv_writer = writer(write_obj)
csv_writer.writerow(list_of_elem)
def index(request):
return render(request, 'user_example/index.html')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment