@@ -0,0 +1,30 | |||||
|
1 | {% extends 'base.html' %} | |||
|
2 | ||||
|
3 | {% block content-title %}{{title}}{% endblock %} | |||
|
4 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
5 | ||||
|
6 | {% block content %} | |||
|
7 | ||||
|
8 | <form action="" method="post" class="form">{% csrf_token %} | |||
|
9 | {% if next %} | |||
|
10 | <input name="next" type="hidden" value="{{ next }}" /> | |||
|
11 | {% endif %} | |||
|
12 | {% if delete_view %} | |||
|
13 | {% if object_name %} | |||
|
14 | <h3>Are you sure you wish to delete {{ object_name }}: {{ object }}?</h3> | |||
|
15 | {% else %} | |||
|
16 | <h3>Are you sure you wish to delete: {{ object }}?</h3> | |||
|
17 | {% endif %} | |||
|
18 | {% else %} | |||
|
19 | <h4>Are you sure you wish to proceed?</h4> | |||
|
20 | {% endif %} | |||
|
21 | {% if message %}<h4>{{ message }}</h4>{% endif %} | |||
|
22 | <br> | |||
|
23 | <button class="btn btn-primary" type="submit"> | |||
|
24 | <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Yes | |||
|
25 | </button> | |||
|
26 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}"> | |||
|
27 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> No | |||
|
28 | </button> | |||
|
29 | </form> | |||
|
30 | {% endblock %} |
@@ -0,0 +1,1 | |||||
|
1 | {% extends "dev_conf_edit.html" %} No newline at end of file |
@@ -0,0 +1,82 | |||||
|
1 | {% extends "dev_conf.html" %} | |||
|
2 | {% load static %} | |||
|
3 | {% load bootstrap3 %} | |||
|
4 | {% block extra-head %} | |||
|
5 | <style type="text/css"> | |||
|
6 | /* show the move cursor as the user moves the mouse over the panel header.*/ | |||
|
7 | .panel-default { cursor: move; } | |||
|
8 | </style> | |||
|
9 | {% endblock %} | |||
|
10 | {% block content %} | |||
|
11 | <table class="table table-bordered"> | |||
|
12 | {% for key in dev_conf_keys %} | |||
|
13 | <tr><th>{{key|title}}</th><td>{{dev_conf|attr:key}}</td></tr> | |||
|
14 | {% endfor %} | |||
|
15 | </table> | |||
|
16 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_send">Send</button> | |||
|
17 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_export">Export</button> | |||
|
18 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_edit">Edit</button> | |||
|
19 | <br> | |||
|
20 | <h2>RC Lines</h2><hr> | |||
|
21 | ||||
|
22 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |||
|
23 | {% for line in rc_lines %} | |||
|
24 | <div class="panel panel-default" > | |||
|
25 | <div class="panel-heading" role="tab" id="headingOne"> | |||
|
26 | <h4 class="panel-title"> | |||
|
27 | <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{line.id}}" aria-expanded="true" aria-controls="collapseOne"> | |||
|
28 | CH{{line.channel}} - {{line.get_name}} | |||
|
29 | </a> | |||
|
30 | <button class="btn-xs btn-danger pull-right" name="bt_remove_line" value="{{line.pk}}"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button> | |||
|
31 | <button class="btn-xs btn-info pull-right" name="bt_line_down" value="{{line.pk}}"><span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span></button> | |||
|
32 | <button class="btn-xs btn-info pull-right" name="bt_line_up" value="{{line.pk}}"><span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span></button> | |||
|
33 | </h4> | |||
|
34 | </div> | |||
|
35 | <div id="collapse{{line.id}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> | |||
|
36 | <div class="panel-body"> | |||
|
37 | {% bootstrap_form line.form layout='horizontal' size='small' %} | |||
|
38 | </div> | |||
|
39 | </div> | |||
|
40 | </div> | |||
|
41 | {% endfor%} | |||
|
42 | </div> | |||
|
43 | <br> | |||
|
44 | <div class="pull-right"> | |||
|
45 | <button class="btn btn-primary" id="bt_add_line">Add Line</button> | |||
|
46 | <button class="btn btn-primary" id="bt_add_line"> Edit </button> | |||
|
47 | <button class="btn btn-primary" id="bt_pulses">Pulses</button> | |||
|
48 | </div> | |||
|
49 | {% endblock %} | |||
|
50 | ||||
|
51 | ||||
|
52 | {% block extra-js%} | |||
|
53 | ||||
|
54 | <script type="text/javascript"> | |||
|
55 | $(document).ready(function() { | |||
|
56 | $("#bt_edit").click(function() { | |||
|
57 | document.location = "{% url 'url_edit_rc_conf' dev_conf.id%}"; | |||
|
58 | }); | |||
|
59 | ||||
|
60 | $("#bt_add_line").click(function() { | |||
|
61 | document.location = "{% url 'url_add_rc_line' dev_conf.id%}"; | |||
|
62 | }); | |||
|
63 | ||||
|
64 | $("button[name=bt_remove_line]").click(function(){ | |||
|
65 | document.location = "line/"+$(this).val()+"/delete/"; | |||
|
66 | }); | |||
|
67 | ||||
|
68 | $("button[name=bt_line_up]").click(function(){ | |||
|
69 | document.location = "line/"+$(this).val()+"/up/"; | |||
|
70 | }); | |||
|
71 | ||||
|
72 | $("button[name=bt_line_down]").click(function(){ | |||
|
73 | document.location = "line/"+$(this).val()+"/down/"; | |||
|
74 | }); | |||
|
75 | ||||
|
76 | ||||
|
77 | ||||
|
78 | $(".panel-group").sortable(); | |||
|
79 | ||||
|
80 | }); | |||
|
81 | </script> | |||
|
82 | {% endblock %} No newline at end of file |
@@ -0,0 +1,1 | |||||
|
1 | {% extends "dev_conf_edit.html" %} No newline at end of file |
@@ -1,109 +1,112 | |||||
1 | from itertools import chain |
|
1 | from itertools import chain | |
2 | from django.db import models |
|
2 | from django.db import models | |
3 | from polymorphic import PolymorphicModel |
|
3 | from polymorphic import PolymorphicModel | |
4 |
|
4 | |||
5 | CONF_TYPES = ( |
|
5 | CONF_TYPES = ( | |
6 | (0, 'Active'), |
|
6 | (0, 'Active'), | |
7 | (1, 'Historical'), |
|
7 | (1, 'Historical'), | |
8 | ) |
|
8 | ) | |
9 |
|
9 | |||
10 | DEV_STATES = ( |
|
10 | DEV_STATES = ( | |
11 | (0, 'No connected'), |
|
11 | (0, 'No connected'), | |
12 | (1, 'Connected'), |
|
12 | (1, 'Connected'), | |
13 | (2, 'Configured'), |
|
13 | (2, 'Configured'), | |
14 | (3, 'Running'), |
|
14 | (3, 'Running'), | |
15 | ) |
|
15 | ) | |
16 |
|
16 | |||
17 | DEV_TYPES = ( |
|
17 | DEV_TYPES = ( | |
18 | ('', 'Select a device type'), |
|
18 | ('', 'Select a device type'), | |
19 | ('rc', 'Radar Controller'), |
|
19 | ('rc', 'Radar Controller'), | |
20 | ('dds', 'Direct Digital Synthesizer'), |
|
20 | ('dds', 'Direct Digital Synthesizer'), | |
21 | ('jars', 'Jicamarca Radar Acquisition System'), |
|
21 | ('jars', 'Jicamarca Radar Acquisition System'), | |
22 | ('usrp', 'Universal Software Radio Peripheral'), |
|
22 | ('usrp', 'Universal Software Radio Peripheral'), | |
23 | ('cgs', 'Clock Generator System'), |
|
23 | ('cgs', 'Clock Generator System'), | |
24 | ('abs', 'Automatic Beam Switching'), |
|
24 | ('abs', 'Automatic Beam Switching'), | |
25 | ) |
|
25 | ) | |
26 |
|
26 | |||
27 | # Create your models here. |
|
27 | # Create your models here. | |
28 |
|
28 | |||
29 | class DeviceType(models.Model): |
|
29 | class DeviceType(models.Model): | |
30 |
|
30 | |||
31 | name = models.CharField(max_length = 10, choices = DEV_TYPES, default = 'rc') |
|
31 | name = models.CharField(max_length = 10, choices = DEV_TYPES, default = 'rc') | |
32 |
|
32 | |||
33 | description = models.TextField(blank=True, null=True) |
|
33 | description = models.TextField(blank=True, null=True) | |
34 |
|
34 | |||
35 | # info = models.TextField(blank=True, null=True) |
|
35 | # info = models.TextField(blank=True, null=True) | |
36 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) |
|
36 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
37 |
|
37 | |||
38 | class Meta: |
|
38 | class Meta: | |
39 | db_table = 'db_device_types' |
|
39 | db_table = 'db_device_types' | |
40 |
|
40 | |||
41 | def __unicode__(self): |
|
41 | def __unicode__(self): | |
42 | return u'%s' % self.get_name_display() |
|
42 | return u'%s' % self.get_name_display() | |
43 |
|
43 | |||
44 | class Device(models.Model): |
|
44 | class Device(models.Model): | |
45 |
|
45 | |||
46 | device_type = models.ForeignKey(DeviceType) |
|
46 | device_type = models.ForeignKey(DeviceType) | |
47 | name = models.CharField(max_length=40, default='') |
|
47 | name = models.CharField(max_length=40, default='') | |
48 | ip_address = models.GenericIPAddressField(protocol='IPv4', default='0.0.0.0') |
|
48 | ip_address = models.GenericIPAddressField(protocol='IPv4', default='0.0.0.0') | |
49 | port_address = models.PositiveSmallIntegerField(default=2000) |
|
49 | port_address = models.PositiveSmallIntegerField(default=2000) | |
50 | description = models.TextField(blank=True, null=True) |
|
50 | description = models.TextField(blank=True, null=True) | |
51 | status = models.PositiveSmallIntegerField(default=0, choices=DEV_STATES) |
|
51 | status = models.PositiveSmallIntegerField(default=0, choices=DEV_STATES) | |
52 |
|
52 | |||
53 | # serial_number = models.CharField(max_length=40, default='') |
|
53 | # serial_number = models.CharField(max_length=40, default='') | |
54 | # mac_address = models.CharField(max_length = 20, null=True, blank=True) |
|
54 | # mac_address = models.CharField(max_length = 20, null=True, blank=True) | |
55 |
|
55 | |||
56 |
|
56 | |||
57 | class Meta: |
|
57 | class Meta: | |
58 | db_table = 'db_devices' |
|
58 | db_table = 'db_devices' | |
59 |
|
59 | |||
60 | def __unicode__(self): |
|
60 | def __unicode__(self): | |
61 | return u'%s | %s' % (self.name, self.ip_address) |
|
61 | return u'%s | %s' % (self.name, self.ip_address) | |
62 |
|
62 | |||
63 | class Campaign(models.Model): |
|
63 | class Campaign(models.Model): | |
64 |
|
64 | |||
65 | name = models.CharField(max_length=40, unique=True) |
|
65 | name = models.CharField(max_length=40, unique=True) | |
66 | start_date = models.DateTimeField(blank=True, null=True) |
|
66 | start_date = models.DateTimeField(blank=True, null=True) | |
67 | end_date = models.DateTimeField(blank=True, null=True) |
|
67 | end_date = models.DateTimeField(blank=True, null=True) | |
68 | tags = models.CharField(max_length=40) |
|
68 | tags = models.CharField(max_length=40) | |
69 | description = models.TextField(blank=True, null=True) |
|
69 | description = models.TextField(blank=True, null=True) | |
70 | template = models.BooleanField(default=False) |
|
70 | template = models.BooleanField(default=False) | |
71 |
|
71 | |||
72 | class Meta: |
|
72 | class Meta: | |
73 | db_table = 'db_campaigns' |
|
73 | db_table = 'db_campaigns' | |
74 |
|
74 | |||
75 | def __unicode__(self): |
|
75 | def __unicode__(self): | |
76 | return u'%s' % (self.name) |
|
76 | return u'%s' % (self.name) | |
77 |
|
77 | |||
78 | class Experiment(models.Model): |
|
78 | class Experiment(models.Model): | |
79 |
|
79 | |||
80 | campaign = models.ForeignKey(Campaign) |
|
80 | campaign = models.ForeignKey(Campaign) | |
81 | name = models.CharField(max_length=40, default='') |
|
81 | name = models.CharField(max_length=40, default='') | |
82 | start_time = models.TimeField(default='00:00:00') |
|
82 | start_time = models.TimeField(default='00:00:00') | |
83 | end_time = models.TimeField(default='23:59:59') |
|
83 | end_time = models.TimeField(default='23:59:59') | |
84 |
|
84 | |||
85 | class Meta: |
|
85 | class Meta: | |
86 | db_table = 'db_experiments' |
|
86 | db_table = 'db_experiments' | |
87 |
|
87 | |||
88 | def __unicode__(self): |
|
88 | def __unicode__(self): | |
89 | return u'[%s]: %s' % (self.campaign.name, self.name) |
|
89 | return u'[%s]: %s' % (self.campaign.name, self.name) | |
90 |
|
90 | |||
91 | class Configuration(PolymorphicModel): |
|
91 | class Configuration(PolymorphicModel): | |
92 |
|
92 | |||
93 | experiment = models.ForeignKey(Experiment) |
|
93 | experiment = models.ForeignKey(Experiment) | |
94 | device = models.ForeignKey(Device) |
|
94 | device = models.ForeignKey(Device) | |
95 | type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES) |
|
95 | type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES) | |
96 |
|
96 | |||
97 | created_date = models.DateTimeField(auto_now_add=True) |
|
97 | created_date = models.DateTimeField(auto_now_add=True) | |
98 | programmed_date = models.DateTimeField(auto_now=True) |
|
98 | programmed_date = models.DateTimeField(auto_now=True) | |
99 |
|
99 | |||
100 | parameters = models.TextField(default='{}') |
|
100 | parameters = models.TextField(default='{}') | |
101 |
|
101 | |||
102 | class Meta: |
|
102 | class Meta: | |
103 | db_table = 'db_configurations' |
|
103 | db_table = 'db_configurations' | |
104 |
|
104 | |||
105 | def __unicode__(self): |
|
105 | def __unicode__(self): | |
106 | return u'[%s - %s]: %s' % (self.experiment.campaign.name, |
|
106 | return u'[%s - %s]: %s' % (self.experiment.campaign.name, | |
107 | self.experiment.name, |
|
107 | self.experiment.name, | |
108 | self.device.name) |
|
108 | self.device.name) | |
|
109 | def get_absolute_url(self): | |||
|
110 | from django.core.urlresolvers import reverse | |||
|
111 | return reverse('url_%s_conf' % self.device.device_type.name, args=[str(self.id)]) | |||
109 | No newline at end of file |
|
112 |
@@ -1,117 +1,126 | |||||
1 | <!DOCTYPE html> |
|
1 | <!DOCTYPE html> | |
2 | {% load static %} |
|
2 | {% load static %} | |
3 | <html lang="en"> |
|
3 | <html lang="en"> | |
4 | <head> |
|
4 | <head> | |
5 | <meta charset="utf-8"> |
|
5 | <meta charset="utf-8"> | |
6 | <title>{% block title %}Jicamarca Integrated Radar System:::::{% endblock %}</title> |
|
6 | <title>{% block title %}Jicamarca Integrated Radar System:::::{% endblock %}</title> | |
7 | <meta name="description" content=""> |
|
7 | <meta name="description" content=""> | |
8 | <meta name="author" content=""> |
|
8 | <meta name="author" content=""> | |
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> | |
10 | {# bootstrap_css #} |
|
10 | {# bootstrap_css #} | |
11 |
<link href="{% static 'css/bootstrap-flatly.min.css' %}" media=" |
|
11 | <link href="{% static 'css/bootstrap-flatly.min.css' %}" media="all" rel="stylesheet"> | |
12 | <style type="text/css"> |
|
12 | <style type="text/css"> | |
13 | body {padding-top: 60px} |
|
13 | body {padding-top: 60px} | |
14 | .logo {padding-top: 5px; height: 50px} |
|
14 | .logo {padding-top: 5px; height: 50px} | |
15 |
.clickable-row {cursor: pointer;} |
|
15 | .clickable-row {cursor: pointer;} | |
16 | </style> |
|
16 | </style> | |
17 | <!--[if lt IE 9]> |
|
17 | <!--[if lt IE 9]> | |
18 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> |
|
18 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
19 | <![endif]--> |
|
19 | <![endif]--> | |
20 | {% block extra-head %} |
|
20 | {% block extra-head %} | |
21 | {% endblock %} |
|
21 | {% endblock %} | |
22 | </head> |
|
22 | </head> | |
23 |
|
23 | |||
24 | <body> |
|
24 | <body> | |
25 |
|
25 | |||
26 | {% block main_menu %} |
|
26 | {% block main_menu %} | |
27 | <nav class="navbar navbar-default navbar-fixed-top" role="banner"> |
|
27 | <nav class="navbar navbar-default navbar-fixed-top" role="banner"> | |
28 | <div class="container-fluid"> |
|
28 | <div class="container-fluid"> | |
29 | <div class="navbar-header"> |
|
29 | <div class="navbar-header"> | |
30 | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar"> |
|
30 | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar"> | |
31 | <span class="sr-only">Toggle navigation</span> |
|
31 | <span class="sr-only">Toggle navigation</span> | |
32 | <span class="icon-bar"></span> |
|
32 | <span class="icon-bar"></span> | |
33 | <span class="icon-bar"></span> |
|
33 | <span class="icon-bar"></span> | |
34 | <span class="icon-bar"></span> |
|
34 | <span class="icon-bar"></span> | |
35 | </button> |
|
35 | </button> | |
36 | <a class="navbar-brand" href="{% url 'index' %}" style="padding-top:1px"><img class="logo" alt="JRO" src="{% static "images/logo-jro-white-trans.png" %}"></a> |
|
36 | <a class="navbar-brand" href="{% url 'index' %}" style="padding-top:1px"><img class="logo" alt="JRO" src="{% static "images/logo-jro-white-trans.png" %}"></a> | |
37 | </div> |
|
37 | </div> | |
38 | <div class="collapse navbar-collapse" id="navigationbar"> |
|
38 | <div class="collapse navbar-collapse" id="navigationbar"> | |
39 | <ul class="nav navbar-nav"> |
|
39 | <ul class="nav navbar-nav"> | |
40 | <li class=" dropdown {% block dev-active %}{% endblock %}"><a href="{% url 'url_devices'%}">Devices</a> |
|
40 | <li class=" dropdown {% block dev-active %}{% endblock %}"><a href="{% url 'url_devices'%}">Devices</a> | |
41 | </li> |
|
41 | </li> | |
42 | <li class=" dropdown {% block camp-active %}{% endblock %}"><a href="{% url 'url_campaigns'%}">Campaigns</a> |
|
42 | <li class=" dropdown {% block camp-active %}{% endblock %}"><a href="{% url 'url_campaigns'%}">Campaigns</a> | |
43 | </li> |
|
43 | </li> | |
44 | <li class=" dropdown {% block exp-active %}{% endblock %}"><a href="{% url 'url_experiments'%}">Experiments</a> |
|
44 | <li class=" dropdown {% block exp-active %}{% endblock %}"><a href="{% url 'url_experiments'%}">Experiments</a> | |
45 | </li> |
|
45 | </li> | |
46 | <li class=" dropdown {% block conf-active %}{% endblock %}"><a href="{% url 'url_dev_confs'%}">Device Configurations</a> |
|
46 | <li class=" dropdown {% block conf-active %}{% endblock %}"><a href="{% url 'url_dev_confs'%}">Device Configurations</a> | |
47 | </li> |
|
47 | </li> | |
48 | </ul> |
|
48 | </ul> | |
49 | <ul class="nav navbar-nav navbar-right"> |
|
49 | <ul class="nav navbar-nav navbar-right"> | |
50 | <li class="nav-divider"></li> |
|
50 | <li class="nav-divider"></li> | |
51 | {% if user.is_authenticated %} |
|
51 | {% if user.is_authenticated %} | |
52 | <li class="dropdown"> |
|
52 | <li class="dropdown"> | |
53 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hi {{ user.username }}<span class="caret"></span></a> |
|
53 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hi {{ user.username }}<span class="caret"></span></a> | |
54 | <ul class="dropdown-menu" role="menu"> |
|
54 | <ul class="dropdown-menu" role="menu"> | |
55 | <li><a href="#">Control Panel</a></li> |
|
55 | <li><a href="#">Control Panel</a></li> | |
56 | <li><a href="{% url 'django.contrib.auth.views.logout' %}">Logout</a></li> |
|
56 | <li><a href="{% url 'django.contrib.auth.views.logout' %}">Logout</a></li> | |
57 | </ul> |
|
57 | </ul> | |
58 | </li> |
|
58 | </li> | |
59 | {% else %} |
|
59 | {% else %} | |
60 | <li><a href="{% url 'django.contrib.auth.views.login' %}?next={{request.get_full_path}}">Login</a></li> |
|
60 | <li><a href="{% url 'django.contrib.auth.views.login' %}?next={{request.get_full_path}}">Login</a></li> | |
61 | {% endif %} |
|
61 | {% endif %} | |
62 | </ul> |
|
62 | </ul> | |
63 | </div> |
|
63 | </div> | |
64 | </div> |
|
64 | </div> | |
65 | </nav> |
|
65 | </nav> | |
66 | <div style="clear: both;"></div> |
|
66 | <div style="clear: both;"></div> | |
67 | {% endblock %} |
|
67 | {% endblock %} | |
68 |
|
68 | |||
69 | <div class="container"> |
|
69 | <div class="container"> | |
70 | <div id="page" class="row" style="min-height:600px"> |
|
70 | <div id="page" class="row" style="min-height:600px"> | |
71 |
|
71 | |||
72 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> |
|
72 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> | |
73 | <br><br> |
|
73 | <br><br> | |
74 | <div id="sidebar"> |
|
74 | <div id="sidebar"> | |
75 | {% block sidebar%} |
|
75 | {% block sidebar%} | |
76 | {% endblock %} |
|
76 | {% endblock %} | |
77 | </div> |
|
77 | </div> | |
78 | </div> |
|
78 | </div> | |
79 |
|
79 | |||
80 | <div class="col-md-9 col-xs-12" role="main"> |
|
80 | <div class="col-md-9 col-xs-12" role="main"> | |
81 | <div class="page-header"> |
|
81 | <div class="page-header"> | |
82 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> |
|
82 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> | |
83 | <hr> |
|
83 | <hr> | |
84 |
</div> |
|
84 | </div> | |
85 |
|
|
85 | {% block messages %} | |
86 | {% endblock %} |
|
86 | {% if messages %} | |
|
87 | {% for message in messages %} | |||
|
88 | <div class="alert alert-{% if message.tags %}{% if 'error' in message.tags %}danger{% else %}{{ message.tags }}{% endif %}{% else %}info{% endif %} alert-dismissible" role="alert"> | |||
|
89 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |||
|
90 | <strong>{{message.tags|title}}!</strong> {{ message }} | |||
|
91 | </div> | |||
|
92 | {% endfor %} | |||
|
93 | {% endif %} | |||
|
94 | {% endblock %} | |||
87 | <br> |
|
95 | <br> | |
88 |
{% block |
|
96 | {% block content %} | |
89 | {% endblock %} |
|
97 | {% endblock %} | |
|
98 | <br> | |||
90 | </div> |
|
99 | </div> | |
91 |
|
100 | |||
92 |
|
101 | |||
93 | </div><!--/row--> |
|
102 | </div><!--/row--> | |
94 | </div> <!-- container --> |
|
103 | </div> <!-- container --> | |
95 |
|
104 | |||
96 | <div id="debug">{{debug}}</div> |
|
105 | <div id="debug">{{debug}}</div> | |
97 |
|
106 | |||
98 | {% block footer %} |
|
107 | {% block footer %} | |
99 | <footer class="footer"> |
|
108 | <footer class="footer"> | |
100 | <div class="container"> |
|
109 | <div class="container"> | |
101 | <p><hr></p> |
|
110 | <p><hr></p> | |
102 | <p> |
|
111 | <p> | |
103 | © <a href="http://jro.igp.gob.pe">Jicamarca Radio Observatory</a> - {% now "Y" %} |
|
112 | © <a href="http://jro.igp.gob.pe">Jicamarca Radio Observatory</a> - {% now "Y" %} | |
104 | </p> |
|
113 | </p> | |
105 | </div> |
|
114 | </div> | |
106 | </footer> |
|
115 | </footer> | |
107 | {% endblock %} |
|
116 | {% endblock %} | |
108 |
|
117 | |||
109 | {# bootstrap_javascript jquery=True #} |
|
118 | {# bootstrap_javascript jquery=True #} | |
110 | <script src="{% static 'js/jquery.min.js' %}"></script> |
|
119 | <script src="{% static 'js/jquery.min.js' %}"></script> | |
111 | <script src="{% static 'js/bootstrap.min.js' %}"></script> |
|
120 | <script src="{% static 'js/bootstrap.min.js' %}"></script> | |
112 |
|
121 | <script src="{% static 'js/jquery-ui.min.js' %}"></script> | ||
113 | {% block extra-js %} |
|
122 | {% block extra-js %} | |
114 | {% endblock%} |
|
123 | {% endblock%} | |
115 | </body> |
|
124 | </body> | |
116 | </html> |
|
125 | </html> | |
117 |
|
126 |
@@ -1,26 +1,29 | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 | {% load bootstrap3 %} |
|
2 | {% load bootstrap3 %} | |
3 | {% load static %} |
|
3 | {% load static %} | |
4 | {% load main_tags %} |
|
4 | {% load main_tags %} | |
5 |
|
5 | |||
6 | {% block conf-active %}active{% endblock %} |
|
6 | {% block conf-active %}active{% endblock %} | |
7 |
|
7 | |||
8 | {% block content-title %}{{title}}{% endblock %} |
|
8 | {% block content-title %}{{title}}{% endblock %} | |
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
10 |
|
10 | |||
11 | {% block content %} |
|
11 | {% block content %} | |
12 | <form class="form" method="post" action=""> |
|
12 | <form class="form" method="post" action=""> | |
13 | {% csrf_token %} |
|
13 | {% csrf_token %} | |
14 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
14 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
15 | <div style="clear: both;"></div> |
|
15 | <div style="clear: both;"></div> | |
16 | <br> |
|
16 | <br> | |
17 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> |
|
17 | <div class="pull-right"> | |
|
18 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> | |||
|
19 | <button type="submit" class="btn btn-primary">{{button}}</button> | |||
|
20 | </div> | |||
18 | </form> |
|
21 | </form> | |
19 | {% endblock %} |
|
22 | {% endblock %} | |
20 |
|
23 | |||
21 | {% block sidebar%} |
|
24 | {% block sidebar%} | |
22 | {% include "sidebar_devices.html" %} |
|
25 | {% include "sidebar_devices.html" %} | |
23 | {% endblock %} |
|
26 | {% endblock %} | |
24 |
|
27 | |||
25 | {% block extra-js%} |
|
28 | {% block extra-js%} | |
26 | {% endblock %} No newline at end of file |
|
29 | {% endblock %} |
@@ -1,6 +1,8 | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from .models import RCConfiguration |
|
2 | from .models import RCConfiguration, RCLine, RCLineType | |
3 |
|
3 | |||
4 | # Register your models here. |
|
4 | # Register your models here. | |
5 |
|
5 | |||
6 | admin.site.register(RCConfiguration) |
|
6 | admin.site.register(RCConfiguration) | |
|
7 | admin.site.register(RCLine) | |||
|
8 | admin.site.register(RCLineType) |
@@ -1,8 +1,43 | |||||
|
1 | import json | |||
|
2 | ||||
1 | from django import forms |
|
3 | from django import forms | |
2 | from .models import RCConfiguration |
|
4 | from .models import RCConfiguration, RCLine, RCLineType | |
3 |
|
5 | |||
4 | class RCConfigurationForm(forms.ModelForm): |
|
6 | class RCConfigurationForm(forms.ModelForm): | |
5 |
|
7 | |||
6 | class Meta: |
|
8 | class Meta: | |
7 | model = RCConfiguration |
|
9 | model = RCConfiguration | |
8 | fields = ('experiment',) |
|
10 | exclude = ('clock', 'ipp', 'ntx', 'clock_divider') | |
|
11 | ||||
|
12 | ||||
|
13 | class RCLineForm(forms.ModelForm): | |||
|
14 | ||||
|
15 | class Meta: | |||
|
16 | model = RCLine | |||
|
17 | fields = ('rc_configuration', 'line_type', 'channel') | |||
|
18 | widgets = { | |||
|
19 | 'channel': forms.HiddenInput(), | |||
|
20 | } | |||
|
21 | ||||
|
22 | def save(self): | |||
|
23 | line = super(RCLineForm, self).save() | |||
|
24 | #auto add channel | |||
|
25 | line.channel = RCLine.objects.filter(rc_configuration=line.rc_configuration).count()-1 | |||
|
26 | #auto add position for TX, TR & CODE | |||
|
27 | if line.line_type.name in ('tx', 'tr', 'code'): | |||
|
28 | line.position = RCLine.objects.filter(rc_configuration=line.rc_configuration, line_type=line.line_type).count()-1 | |||
|
29 | #add default params | |||
|
30 | params = {} | |||
|
31 | for field in json.loads(line.line_type.params): | |||
|
32 | params[field['name']] = field['value'] | |||
|
33 | line.params = json.dumps(params) | |||
|
34 | line.save() | |||
|
35 | return | |||
|
36 | ||||
|
37 | class RCLineViewForm(forms.Form): | |||
|
38 | ||||
|
39 | def __init__(self, *args, **kwargs): | |||
|
40 | extra_fields = kwargs.pop('extra_fields') | |||
|
41 | super(RCLineViewForm, self).__init__(*args, **kwargs) | |||
|
42 | for label, value in extra_fields.items(): | |||
|
43 | self.fields[label] = forms.CharField(initial=value) No newline at end of file |
@@ -1,10 +1,95 | |||||
|
1 | ||||
|
2 | from polymorphic import PolymorphicModel | |||
|
3 | ||||
1 | from django.db import models |
|
4 | from django.db import models | |
|
5 | from django.core.validators import MinValueValidator, MaxValueValidator | |||
|
6 | ||||
2 | from apps.main.models import Configuration |
|
7 | from apps.main.models import Configuration | |
3 | # Create your models here. |
|
8 | # Create your models here. | |
4 |
|
9 | |||
|
10 | LINE_TYPES = ( | |||
|
11 | ('tr', 'Transmission/reception selector signal'), | |||
|
12 | ('tx', 'A modulating signal (Transmission pulse)'), | |||
|
13 | ('codes', 'BPSK modulating signal'), | |||
|
14 | ('windows', 'Sample window signal'), | |||
|
15 | ('sync', 'Synchronizing signal'), | |||
|
16 | ('flip', 'IPP related periodic signal'), | |||
|
17 | ('prog_pulses', 'Programmable pulse'), | |||
|
18 | ) | |||
|
19 | ||||
|
20 | LINE_PARAMS = { | |||
|
21 | "tr": [{"name":"time_after", "value": 0}], | |||
|
22 | "tx": [{"name": "pulse_width", "value": 0},{"name":"delays", "value":""}], | |||
|
23 | "codes": [{"name":"tx_ref", "value": ""},{"name":"code", "value": "", "choices":"RCLineCode"}], | |||
|
24 | "windows": [{"name":"tx_ref","value":""}, {"name":"first_height", "value":0}, {"name":"number_of_samples","value":0}, {"name":"resolution","value":0}, {"name":"last_height","value":0}], | |||
|
25 | "sync": [{"name": "delay", "value": 0}], | |||
|
26 | "flip": [{"name":"number_of_flips", "value": 0}], | |||
|
27 | "prog_pulses": [{"name": "begin", "value": 0}, {"name": "end","value": 0}], | |||
|
28 | } | |||
|
29 | ||||
|
30 | ||||
5 | class RCConfiguration(Configuration): |
|
31 | class RCConfiguration(Configuration): | |
6 |
|
32 | |||
|
33 | clock = models.FloatField(verbose_name='Clock Master (MHz)', validators=[MinValueValidator(0), MaxValueValidator(80)], blank=True, null=True) | |||
|
34 | clock_divider = models.PositiveIntegerField(verbose_name='Clock divider', validators=[MinValueValidator(0), MaxValueValidator(256)], blank=True, null=True) | |||
|
35 | ipp = models.PositiveIntegerField(verbose_name='Inter pulse period (Km)', default=10) | |||
|
36 | ntx = models.PositiveIntegerField(verbose_name='Number of pulse of transmit', default=1) | |||
|
37 | time_before = models.PositiveIntegerField(verbose_name='Number of pulse of transmit', default=0) | |||
7 |
|
38 | |||
8 | class Meta: |
|
39 | class Meta: | |
9 | db_table = 'rc_configurations' |
|
40 | db_table = 'rc_configurations' | |
10 | No newline at end of file |
|
41 | ||
|
42 | def get_number_position(self): | |||
|
43 | ||||
|
44 | lines = RCLine.objects.filter(rc_configuration=self.rc_configuration) | |||
|
45 | if lines: | |||
|
46 | return max([line.position for line in lines]) | |||
|
47 | ||||
|
48 | class RCLineCode(models.Model): | |||
|
49 | ||||
|
50 | name = models.CharField(choices=LINE_TYPES, max_length=40) | |||
|
51 | bits_per_code = models.PositiveIntegerField(default=0) | |||
|
52 | number_of_codes = models.PositiveIntegerField(default=0) | |||
|
53 | codes = models.TextField(blank=True, null=True) | |||
|
54 | ||||
|
55 | class Meta: | |||
|
56 | db_table = 'rc_line_codes' | |||
|
57 | ||||
|
58 | ||||
|
59 | class RCLineType(models.Model): | |||
|
60 | ||||
|
61 | name = models.CharField(choices=LINE_TYPES, max_length=40) | |||
|
62 | description = models.TextField(blank=True, null=True) | |||
|
63 | params = models.TextField(default='[]') | |||
|
64 | ||||
|
65 | class Meta: | |||
|
66 | db_table = 'rc_line_types' | |||
|
67 | ||||
|
68 | def __unicode__(self): | |||
|
69 | return u'%s - %s' % (self.name.upper(), self.get_name_display()) | |||
|
70 | ||||
|
71 | ||||
|
72 | class RCLine(models.Model): | |||
|
73 | ||||
|
74 | rc_configuration = models.ForeignKey(RCConfiguration) | |||
|
75 | line_type = models.ForeignKey(RCLineType) | |||
|
76 | channel = models.PositiveIntegerField(default=0) | |||
|
77 | position = models.PositiveIntegerField(default=0) | |||
|
78 | params = models.TextField(default='{}') | |||
|
79 | ||||
|
80 | class Meta: | |||
|
81 | db_table = 'rc_lines' | |||
|
82 | ||||
|
83 | def __unicode__(self): | |||
|
84 | return u'%s - %s' % (self.rc_configuration, self.get_name()) | |||
|
85 | ||||
|
86 | def get_name(self): | |||
|
87 | ||||
|
88 | chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |||
|
89 | ||||
|
90 | if self.line_type.name in ('tx', 'code', 'tr'): | |||
|
91 | return '%s%s' % (self.line_type.name.upper(), chars[self.position]) | |||
|
92 | ||||
|
93 | return self.line_type.name.upper() | |||
|
94 | ||||
|
95 |
@@ -1,6 +1,10 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 |
url(r'^(?P<id |
|
4 | url(r'^(?P<id>-?\d+)/$', 'apps.rc.views.conf', name='url_rc_conf'), | |
5 |
url(r'^(?P<id |
|
5 | url(r'^(?P<id>-?\d+)/edit/$', 'apps.rc.views.conf_edit', name='url_edit_rc_conf'), | |
|
6 | url(r'^(?P<id>-?\d+)/add_line/$', 'apps.rc.views.add_line', name='url_add_rc_line'), | |||
|
7 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/delete/$', 'apps.rc.views.remove_line', name='url_remove_rc_line'), | |||
|
8 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/up/$', 'apps.rc.views.line_up', name='url_rc_line_up'), | |||
|
9 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/down/$', 'apps.rc.views.line_down', name='url_rc_line_down'), | |||
6 | ) |
|
10 | ) |
@@ -1,3 +1,154 | |||||
1 | from django.shortcuts import render |
|
1 | import json | |
|
2 | ||||
|
3 | from django.contrib import messages | |||
|
4 | from django.shortcuts import render, redirect, get_object_or_404 | |||
|
5 | ||||
|
6 | from apps.main.models import Configuration, Experiment | |||
|
7 | ||||
|
8 | from .models import RCConfiguration, RCLine | |||
|
9 | from .forms import RCConfigurationForm, RCLineForm, RCLineViewForm | |||
|
10 | ||||
|
11 | ||||
|
12 | def conf(request, id): | |||
|
13 | ||||
|
14 | conf = get_object_or_404(RCConfiguration, pk=id) | |||
|
15 | ||||
|
16 | lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel') | |||
|
17 | ||||
|
18 | for line in lines: | |||
|
19 | line.form = RCLineViewForm(extra_fields=json.loads(line.params)) | |||
|
20 | ||||
|
21 | kwargs = {} | |||
|
22 | kwargs['dev_conf'] = conf | |||
|
23 | kwargs['rc_lines'] = lines | |||
|
24 | kwargs['dev_conf_keys'] = ['clock', 'ipp', 'ntx','clock_divider'] | |||
|
25 | ||||
|
26 | kwargs['title'] = 'RC Configuration' | |||
|
27 | kwargs['suptitle'] = 'Details' | |||
|
28 | ||||
|
29 | kwargs['button'] = 'Edit Configuration' | |||
|
30 | ||||
|
31 | ###### SIDEBAR ###### | |||
|
32 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) | |||
|
33 | configurations = Configuration.objects.filter(experiment=conf.experiment) | |||
|
34 | ||||
|
35 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |||
|
36 | conf_keys = ['id', 'device__name', 'device__device_type__name', 'device__ip_address'] | |||
|
37 | ||||
|
38 | kwargs['experiment_keys'] = exp_keys[1:] | |||
|
39 | kwargs['experiments'] = experiments.values(*exp_keys) | |||
|
40 | ||||
|
41 | kwargs['configuration_keys'] = conf_keys[1:] | |||
|
42 | kwargs['configurations'] = configurations.values(*conf_keys) | |||
|
43 | ||||
|
44 | return render(request, 'rc_conf.html', kwargs) | |||
|
45 | ||||
|
46 | ||||
|
47 | def conf_edit(request, id): | |||
|
48 | ||||
|
49 | conf = get_object_or_404(RCConfiguration, pk=id) | |||
|
50 | ||||
|
51 | if request.method=='GET': | |||
|
52 | form = RCConfigurationForm(instance=conf) | |||
|
53 | ||||
|
54 | if request.method=='POST': | |||
|
55 | form = RCConfigurationForm(request.POST, instance=conf) | |||
|
56 | ||||
|
57 | if form.is_valid(): | |||
|
58 | form.save() | |||
|
59 | return redirect('url_rc_conf', id=id) | |||
|
60 | ||||
|
61 | kwargs = {} | |||
|
62 | kwargs['form'] = form | |||
|
63 | kwargs['title'] = 'Device Configuration' | |||
|
64 | kwargs['suptitle'] = 'Edit' | |||
|
65 | kwargs['button'] = 'Update' | |||
|
66 | kwargs['previous'] = conf.get_absolute_url() | |||
|
67 | return render(request, 'rc_conf_edit.html', kwargs) | |||
|
68 | ||||
|
69 | ||||
|
70 | def add_line(request, id): | |||
|
71 | ||||
|
72 | conf = get_object_or_404(RCConfiguration, pk=id) | |||
|
73 | ||||
|
74 | if request.method=='GET': | |||
|
75 | form = RCLineForm(initial={'rc_configuration':conf.id}) | |||
|
76 | ||||
|
77 | if request.method=='POST': | |||
|
78 | form = RCLineForm(request.POST) | |||
|
79 | ||||
|
80 | if form.is_valid(): | |||
|
81 | form.save() | |||
|
82 | return redirect('url_rc_conf', id=id) | |||
|
83 | ||||
|
84 | kwargs = {} | |||
|
85 | kwargs['form'] = form | |||
|
86 | kwargs['title'] = 'RC Configuration' | |||
|
87 | kwargs['suptitle'] = 'Add Line' | |||
|
88 | kwargs['button'] = 'Add' | |||
|
89 | kwargs['previous'] = conf.get_absolute_url() | |||
|
90 | return render(request, 'rc_add_line.html', kwargs) | |||
|
91 | ||||
|
92 | ||||
|
93 | def remove_line(request, conf_id, line_id): | |||
|
94 | ||||
|
95 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |||
|
96 | line = get_object_or_404(RCLine, pk=line_id) | |||
|
97 | ||||
|
98 | if request.method == 'POST': | |||
|
99 | if line: | |||
|
100 | try: | |||
|
101 | channel = line.channel | |||
|
102 | line.delete() | |||
|
103 | for ch in range(channel+1, RCLine.objects.filter(rc_configuration=conf).count()+1): | |||
|
104 | l = RCLine.objects.get(rc_configuration=conf, channel=ch) | |||
|
105 | l.channel = l.channel-1 | |||
|
106 | l.save() | |||
|
107 | messages.success(request, 'Line: "%s" has been deleted.' % line) | |||
|
108 | except: | |||
|
109 | messages.error(request, 'Unable to delete line: "%s".' % line) | |||
|
110 | ||||
|
111 | return redirect(conf.get_absolute_url()) | |||
|
112 | ||||
|
113 | kwargs = {} | |||
|
114 | ||||
|
115 | kwargs['object'] = line | |||
|
116 | kwargs['delete_view'] = True | |||
|
117 | kwargs['title'] = 'Confirm delete' | |||
|
118 | kwargs['previous'] = conf.get_absolute_url() | |||
|
119 | return render(request, 'confirm.html', kwargs) | |||
|
120 | ||||
|
121 | ||||
|
122 | def line_up(request, conf_id, line_id): | |||
|
123 | ||||
|
124 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |||
|
125 | line = get_object_or_404(RCLine, pk=line_id) | |||
|
126 | ||||
|
127 | if line: | |||
|
128 | ch = line.channel | |||
|
129 | if ch-1>=0: | |||
|
130 | line0 = RCLine.objects.get(rc_configuration=conf, channel=ch-1) | |||
|
131 | line0.channel = ch | |||
|
132 | line0.save() | |||
|
133 | line.channel = ch-1 | |||
|
134 | line.save() | |||
|
135 | ||||
|
136 | return redirect(conf.get_absolute_url()) | |||
|
137 | ||||
|
138 | ||||
|
139 | def line_down(request, conf_id, line_id): | |||
|
140 | ||||
|
141 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |||
|
142 | line = get_object_or_404(RCLine, pk=line_id) | |||
|
143 | ||||
|
144 | if line: | |||
|
145 | ch = line.channel | |||
|
146 | if ch+1<RCLine.objects.filter(rc_configuration=conf).count(): | |||
|
147 | line1 = RCLine.objects.get(rc_configuration=conf, channel=ch+1) | |||
|
148 | line1.channel = ch | |||
|
149 | line1.save() | |||
|
150 | line.channel = ch+1 | |||
|
151 | line.save() | |||
|
152 | ||||
|
153 | return redirect(conf.get_absolute_url()) | |||
2 |
|
154 | |||
3 | # Create your views here. |
|
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now