Commit 05038bc84d5f892c704950c237f5af54d6ffec28
1 parent
65149de7
Exists in
master
and in
1 other branch
Majordome logic implemented
Showing
4 changed files
with
310 additions
and
329 deletions
Show diff stats
.idea/workspace.xml
... | ... | @@ -2,28 +2,10 @@ |
2 | 2 | <project version="4"> |
3 | 3 | <component name="ChangeListManager"> |
4 | 4 | <list default="true" id="a32987d6-1295-46a1-bf9a-f01b2781e22f" name="Default" comment=""> |
5 | - <change type="MOVED" beforePath="$PROJECT_DIR$/src/logger/__init__.py" afterPath="$PROJECT_DIR$/src/utils/__init__.py" /> | |
6 | - <change type="MOVED" beforePath="$PROJECT_DIR$/src/logger/config.py" afterPath="$PROJECT_DIR$/src/utils/config.py" /> | |
7 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/PYROS.iml" afterPath="$PROJECT_DIR$/.idea/PYROS.iml" /> | |
8 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" /> | |
9 | 5 | <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> |
10 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/obsolete/userSimulator/tasks.py" afterPath="$PROJECT_DIR$/obsolete/userSimulator/tasks.py" /> | |
11 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/alert/ALERTsimulator.py" afterPath="$PROJECT_DIR$/simulators/alert/ALERTsimulator.py" /> | |
12 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/config/user/conf1.json" afterPath="$PROJECT_DIR$/simulators/config/user/conf1.json" /> | |
13 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/config/user/conf2.json" afterPath="$PROJECT_DIR$/simulators/config/user/conf2.json" /> | |
14 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/plc/PLCsimulator.py" afterPath="$PROJECT_DIR$/simulators/plc/PLCsimulator.py" /> | |
15 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/scripts/simulator_launch.sh" afterPath="$PROJECT_DIR$/simulators/scripts/simulator_launch.sh" /> | |
16 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/simulators/user/USERsimulator.py" afterPath="$PROJECT_DIR$/simulators/user/USERsimulator.py" /> | |
17 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/alert_manager/tests.py" afterPath="$PROJECT_DIR$/src/alert_manager/tests.py" /> | |
18 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/common/tests.py" afterPath="$PROJECT_DIR$/src/common/tests.py" /> | |
19 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/dashboard/views.py" afterPath="$PROJECT_DIR$/src/dashboard/views.py" /> | |
20 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/devices/Device.py" afterPath="$PROJECT_DIR$/src/devices/Device.py" /> | |
6 | + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/common/models.py" afterPath="$PROJECT_DIR$/src/common/models.py" /> | |
21 | 7 | <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/majordome/tasks.py" afterPath="$PROJECT_DIR$/src/majordome/tasks.py" /> |
22 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/monitoring/tasks.py" afterPath="$PROJECT_DIR$/src/monitoring/tasks.py" /> | |
23 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/routine_manager/RequestSerializer.py" afterPath="$PROJECT_DIR$/src/routine_manager/RequestSerializer.py" /> | |
24 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/routine_manager/views.py" afterPath="$PROJECT_DIR$/src/routine_manager/views.py" /> | |
25 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/scheduler/Scheduler.py" afterPath="$PROJECT_DIR$/src/scheduler/Scheduler.py" /> | |
26 | - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/scheduler/tasks.py" afterPath="$PROJECT_DIR$/src/scheduler/tasks.py" /> | |
8 | + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/utils/JDManipulator.py" afterPath="$PROJECT_DIR$/src/utils/JDManipulator.py" /> | |
27 | 9 | </list> |
28 | 10 | <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> |
29 | 11 | <option name="TRACKING_ENABLED" value="true" /> |
... | ... | @@ -50,60 +32,6 @@ |
50 | 32 | <component name="DjangoConsoleOptions" custom-start-script="import sys; print('Python %s on %s' % (sys.version, sys.platform)) import django; print('Django %s' % django.get_version()) sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) if 'setup' in dir(django): django.setup() import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)"> |
51 | 33 | <option name="myCustomStartScript" value="import sys; print('Python %s on %s' % (sys.version, sys.platform)) import django; print('Django %s' % django.get_version()) sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) if 'setup' in dir(django): django.setup() import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)" /> |
52 | 34 | </component> |
53 | - <component name="DockManager"> | |
54 | - <window id="1"> | |
55 | - <content type="file-editors"> | |
56 | - <state> | |
57 | - <splitter split-orientation="horizontal" split-proportion="0.5"> | |
58 | - <split-first> | |
59 | - <leaf> | |
60 | - <file leaf-file-name="tasks.py" pinned="false" current-in-tab="false"> | |
61 | - <entry file="file://$PROJECT_DIR$/src/monitoring/tasks.py"> | |
62 | - <provider selected="true" editor-type-id="text-editor"> | |
63 | - <state relative-caret-position="-79"> | |
64 | - <caret line="46" column="0" lean-forward="false" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" /> | |
65 | - <folding> | |
66 | - <element signature="e#0#38#0" expanded="true" /> | |
67 | - </folding> | |
68 | - </state> | |
69 | - </provider> | |
70 | - </entry> | |
71 | - </file> | |
72 | - <file leaf-file-name="tasks.py" pinned="false" current-in-tab="true"> | |
73 | - <entry file="file://$PROJECT_DIR$/src/scheduler/tasks.py"> | |
74 | - <provider selected="true" editor-type-id="text-editor"> | |
75 | - <state relative-caret-position="526"> | |
76 | - <caret line="32" column="0" lean-forward="false" selection-start-line="32" selection-start-column="0" selection-end-line="32" selection-end-column="0" /> | |
77 | - <folding> | |
78 | - <element signature="e#0#38#0" expanded="true" /> | |
79 | - </folding> | |
80 | - </state> | |
81 | - </provider> | |
82 | - </entry> | |
83 | - </file> | |
84 | - </leaf> | |
85 | - </split-first> | |
86 | - <split-second> | |
87 | - <leaf> | |
88 | - <file leaf-file-name="Scheduler.py" pinned="false" current-in-tab="true"> | |
89 | - <entry file="file://$PROJECT_DIR$/src/scheduler/Scheduler.py"> | |
90 | - <provider selected="true" editor-type-id="text-editor"> | |
91 | - <state relative-caret-position="396"> | |
92 | - <caret line="689" column="29" lean-forward="false" selection-start-line="689" selection-start-column="29" selection-end-line="689" selection-end-column="29" /> | |
93 | - <folding> | |
94 | - <element signature="e#0#66#0" expanded="true" /> | |
95 | - </folding> | |
96 | - </state> | |
97 | - </provider> | |
98 | - </entry> | |
99 | - </file> | |
100 | - </leaf> | |
101 | - </split-second> | |
102 | - </splitter> | |
103 | - </state> | |
104 | - </content> | |
105 | - </window> | |
106 | - </component> | |
107 | 35 | <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" /> |
108 | 36 | <component name="FavoritesManager"> |
109 | 37 | <favorites_list name="PYROS"> |
... | ... | @@ -548,12 +476,12 @@ |
548 | 476 | </favorites_list> |
549 | 477 | </component> |
550 | 478 | <component name="FileEditorManager"> |
551 | - <leaf> | |
552 | - <file leaf-file-name="tasks.py" pinned="false" current-in-tab="false"> | |
479 | + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> | |
480 | + <file leaf-file-name="tasks.py" pinned="false" current-in-tab="true"> | |
553 | 481 | <entry file="file://$PROJECT_DIR$/src/majordome/tasks.py"> |
554 | 482 | <provider selected="true" editor-type-id="text-editor"> |
555 | - <state relative-caret-position="408"> | |
556 | - <caret line="175" column="1" lean-forward="true" selection-start-line="175" selection-start-column="1" selection-end-line="175" selection-end-column="1" /> | |
483 | + <state relative-caret-position="357"> | |
484 | + <caret line="161" column="18" lean-forward="true" selection-start-line="161" selection-start-column="18" selection-end-line="161" selection-end-column="18" /> | |
557 | 485 | <folding> |
558 | 486 | <element signature="e#0#38#0" expanded="true" /> |
559 | 487 | </folding> |
... | ... | @@ -561,14 +489,22 @@ |
561 | 489 | </provider> |
562 | 490 | </entry> |
563 | 491 | </file> |
564 | - <file leaf-file-name="RequestSerializer.py" pinned="false" current-in-tab="true"> | |
565 | - <entry file="file://$PROJECT_DIR$/src/routine_manager/RequestSerializer.py"> | |
492 | + <file leaf-file-name="tasks.py" pinned="false" current-in-tab="false"> | |
493 | + <entry file="file://$PROJECT_DIR$/src/monitoring/tasks.py"> | |
566 | 494 | <provider selected="true" editor-type-id="text-editor"> |
567 | - <state relative-caret-position="323"> | |
568 | - <caret line="19" column="45" lean-forward="true" selection-start-line="19" selection-start-column="45" selection-end-line="19" selection-end-column="45" /> | |
569 | - <folding> | |
570 | - <element signature="e#0#32#0" expanded="true" /> | |
571 | - </folding> | |
495 | + <state relative-caret-position="441"> | |
496 | + <caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" /> | |
497 | + <folding /> | |
498 | + </state> | |
499 | + </provider> | |
500 | + </entry> | |
501 | + </file> | |
502 | + <file leaf-file-name="models.py" pinned="false" current-in-tab="false"> | |
503 | + <entry file="file://$PROJECT_DIR$/src/common/models.py"> | |
504 | + <provider selected="true" editor-type-id="text-editor"> | |
505 | + <state relative-caret-position="813"> | |
506 | + <caret line="381" column="39" lean-forward="true" selection-start-line="381" selection-start-column="39" selection-end-line="381" selection-end-column="39" /> | |
507 | + <folding /> | |
572 | 508 | </state> |
573 | 509 | </provider> |
574 | 510 | </entry> |
... | ... | @@ -585,9 +521,6 @@ |
585 | 521 | </component> |
586 | 522 | <component name="FindInProjectRecents"> |
587 | 523 | <findStrings> |
588 | - <find>"device": 1</find> | |
589 | - <find>"device": 2</find> | |
590 | - <find>"device": 3</find> | |
591 | 524 | <find>"device": 4</find> |
592 | 525 | <find>"device": 5</find> |
593 | 526 | <find>"device": 6</find> |
... | ... | @@ -615,6 +548,9 @@ |
615 | 548 | <find>majordo</find> |
616 | 549 | <find>majordome.tas</find> |
617 | 550 | <find>save</find> |
551 | + <find>get_ni</find> | |
552 | + <find>environe</find> | |
553 | + <find>Sequence</find> | |
618 | 554 | </findStrings> |
619 | 555 | </component> |
620 | 556 | <component name="Git.Settings"> |
... | ... | @@ -641,7 +577,6 @@ |
641 | 577 | <option value="$PROJECT_DIR$/src/misc/fixtures/tests/alert_mgr_test.json" /> |
642 | 578 | <option value="$PROJECT_DIR$/src/misc/fixtures/tests/common_test.json" /> |
643 | 579 | <option value="$PROJECT_DIR$/src/misc/fixtures/tests/routine_mgr_test.json" /> |
644 | - <option value="$PROJECT_DIR$/src/common/models.py" /> | |
645 | 580 | <option value="$PROJECT_DIR$/src/scheduler/tests.py" /> |
646 | 581 | <option value="$PROJECT_DIR$/src/alert_manager/tasks.py" /> |
647 | 582 | <option value="$PROJECT_DIR$/src/routine_manager/views.py" /> |
... | ... | @@ -661,10 +596,11 @@ |
661 | 596 | <option value="$PROJECT_DIR$/src/monitoring/tasks.py" /> |
662 | 597 | <option value="$PROJECT_DIR$/src/utils/julianDateManipulator.py" /> |
663 | 598 | <option value="$PROJECT_DIR$/src/utils/config.py" /> |
664 | - <option value="$PROJECT_DIR$/src/routine_manager/RequestSerializer.py" /> | |
665 | - <option value="$PROJECT_DIR$/src/utils/JDManipulator.py" /> | |
666 | 599 | <option value="$PROJECT_DIR$/src/scheduler/Scheduler.py" /> |
667 | 600 | <option value="$PROJECT_DIR$/src/scheduler/tasks.py" /> |
601 | + <option value="$PROJECT_DIR$/src/routine_manager/RequestSerializer.py" /> | |
602 | + <option value="$PROJECT_DIR$/src/utils/JDManipulator.py" /> | |
603 | + <option value="$PROJECT_DIR$/src/common/models.py" /> | |
668 | 604 | <option value="$PROJECT_DIR$/src/majordome/tasks.py" /> |
669 | 605 | </list> |
670 | 606 | </option> |
... | ... | @@ -699,7 +635,6 @@ |
699 | 635 | </navigator> |
700 | 636 | <panes> |
701 | 637 | <pane id="Scratches" /> |
702 | - <pane id="Scope" /> | |
703 | 638 | <pane id="ProjectPane"> |
704 | 639 | <subPane> |
705 | 640 | <PATH> |
... | ... | @@ -812,12 +747,49 @@ |
812 | 747 | <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> |
813 | 748 | </PATH_ELEMENT> |
814 | 749 | <PATH_ELEMENT> |
750 | + <option name="myItemId" value="monitoring" /> | |
751 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
752 | + </PATH_ELEMENT> | |
753 | + </PATH> | |
754 | + <PATH> | |
755 | + <PATH_ELEMENT> | |
756 | + <option name="myItemId" value="PYROS" /> | |
757 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | |
758 | + </PATH_ELEMENT> | |
759 | + <PATH_ELEMENT> | |
760 | + <option name="myItemId" value="PYROS" /> | |
761 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
762 | + </PATH_ELEMENT> | |
763 | + <PATH_ELEMENT> | |
764 | + <option name="myItemId" value="src" /> | |
765 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
766 | + </PATH_ELEMENT> | |
767 | + <PATH_ELEMENT> | |
815 | 768 | <option name="myItemId" value="majordome" /> |
816 | 769 | <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> |
817 | 770 | </PATH_ELEMENT> |
818 | 771 | </PATH> |
772 | + <PATH> | |
773 | + <PATH_ELEMENT> | |
774 | + <option name="myItemId" value="PYROS" /> | |
775 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | |
776 | + </PATH_ELEMENT> | |
777 | + <PATH_ELEMENT> | |
778 | + <option name="myItemId" value="PYROS" /> | |
779 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
780 | + </PATH_ELEMENT> | |
781 | + <PATH_ELEMENT> | |
782 | + <option name="myItemId" value="src" /> | |
783 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
784 | + </PATH_ELEMENT> | |
785 | + <PATH_ELEMENT> | |
786 | + <option name="myItemId" value="common" /> | |
787 | + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | |
788 | + </PATH_ELEMENT> | |
789 | + </PATH> | |
819 | 790 | </subPane> |
820 | 791 | </pane> |
792 | + <pane id="Scope" /> | |
821 | 793 | </panes> |
822 | 794 | </component> |
823 | 795 | <component name="PropertiesComponent"> |
... | ... | @@ -1190,7 +1162,6 @@ |
1190 | 1162 | <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> |
1191 | 1163 | <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> |
1192 | 1164 | <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> |
1193 | - <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32925585" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> | |
1194 | 1165 | <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> |
1195 | 1166 | <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> |
1196 | 1167 | <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> |
... | ... | @@ -1202,6 +1173,7 @@ |
1202 | 1173 | <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> |
1203 | 1174 | <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.22731906" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> |
1204 | 1175 | <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> |
1176 | + <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32925585" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> | |
1205 | 1177 | <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> |
1206 | 1178 | <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> |
1207 | 1179 | </layout> |
... | ... | @@ -1268,16 +1240,6 @@ |
1268 | 1240 | </state> |
1269 | 1241 | </provider> |
1270 | 1242 | </entry> |
1271 | - <entry file="file://$PROJECT_DIR$/src/common/models.py"> | |
1272 | - <provider selected="true" editor-type-id="text-editor"> | |
1273 | - <state relative-caret-position="609"> | |
1274 | - <caret line="248" column="28" lean-forward="true" selection-start-line="248" selection-start-column="28" selection-end-line="248" selection-end-column="28" /> | |
1275 | - <folding> | |
1276 | - <element signature="e#470#509#0" expanded="false" /> | |
1277 | - </folding> | |
1278 | - </state> | |
1279 | - </provider> | |
1280 | - </entry> | |
1281 | 1243 | <entry file="file://$PROJECT_DIR$/src/common/tests.py"> |
1282 | 1244 | <provider selected="true" editor-type-id="text-editor"> |
1283 | 1245 | <state relative-caret-position="405"> |
... | ... | @@ -1388,7 +1350,6 @@ |
1388 | 1350 | <provider selected="true" editor-type-id="text-editor"> |
1389 | 1351 | <state relative-caret-position="646"> |
1390 | 1352 | <caret line="38" column="0" lean-forward="true" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> |
1391 | - <folding /> | |
1392 | 1353 | </state> |
1393 | 1354 | </provider> |
1394 | 1355 | </entry> |
... | ... | @@ -1396,7 +1357,6 @@ |
1396 | 1357 | <provider selected="true" editor-type-id="text-editor"> |
1397 | 1358 | <state relative-caret-position="646"> |
1398 | 1359 | <caret line="38" column="0" lean-forward="true" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> |
1399 | - <folding /> | |
1400 | 1360 | </state> |
1401 | 1361 | </provider> |
1402 | 1362 | </entry> |
... | ... | @@ -1404,7 +1364,6 @@ |
1404 | 1364 | <provider selected="true" editor-type-id="text-editor"> |
1405 | 1365 | <state relative-caret-position="577"> |
1406 | 1366 | <caret line="59" column="18" lean-forward="true" selection-start-line="59" selection-start-column="18" selection-end-line="59" selection-end-column="18" /> |
1407 | - <folding /> | |
1408 | 1367 | </state> |
1409 | 1368 | </provider> |
1410 | 1369 | </entry> |
... | ... | @@ -1412,7 +1371,6 @@ |
1412 | 1371 | <provider selected="true" editor-type-id="text-editor"> |
1413 | 1372 | <state relative-caret-position="887"> |
1414 | 1373 | <caret line="64" column="0" lean-forward="true" selection-start-line="64" selection-start-column="0" selection-end-line="64" selection-end-column="0" /> |
1415 | - <folding /> | |
1416 | 1374 | </state> |
1417 | 1375 | </provider> |
1418 | 1376 | </entry> |
... | ... | @@ -1420,9 +1378,6 @@ |
1420 | 1378 | <provider selected="true" editor-type-id="text-editor"> |
1421 | 1379 | <state relative-caret-position="206"> |
1422 | 1380 | <caret line="22" column="0" lean-forward="true" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" /> |
1423 | - <folding> | |
1424 | - <element signature="e#0#19#0" expanded="false" /> | |
1425 | - </folding> | |
1426 | 1381 | </state> |
1427 | 1382 | </provider> |
1428 | 1383 | </entry> |
... | ... | @@ -1430,9 +1385,6 @@ |
1430 | 1385 | <provider selected="true" editor-type-id="text-editor"> |
1431 | 1386 | <state relative-caret-position="631"> |
1432 | 1387 | <caret line="49" column="0" lean-forward="false" selection-start-line="49" selection-start-column="0" selection-end-line="49" selection-end-column="0" /> |
1433 | - <folding> | |
1434 | - <element signature="e#0#13#0" expanded="false" /> | |
1435 | - </folding> | |
1436 | 1388 | </state> |
1437 | 1389 | </provider> |
1438 | 1390 | </entry> |
... | ... | @@ -1440,7 +1392,6 @@ |
1440 | 1392 | <provider selected="true" editor-type-id="text-editor"> |
1441 | 1393 | <state relative-caret-position="646"> |
1442 | 1394 | <caret line="38" column="0" lean-forward="false" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> |
1443 | - <folding /> | |
1444 | 1395 | </state> |
1445 | 1396 | </provider> |
1446 | 1397 | </entry> |
... | ... | @@ -1448,7 +1399,6 @@ |
1448 | 1399 | <provider selected="true" editor-type-id="text-editor"> |
1449 | 1400 | <state relative-caret-position="0"> |
1450 | 1401 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1451 | - <folding /> | |
1452 | 1402 | </state> |
1453 | 1403 | </provider> |
1454 | 1404 | </entry> |
... | ... | @@ -1456,7 +1406,6 @@ |
1456 | 1406 | <provider selected="true" editor-type-id="text-editor"> |
1457 | 1407 | <state relative-caret-position="136"> |
1458 | 1408 | <caret line="38" column="0" lean-forward="false" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> |
1459 | - <folding /> | |
1460 | 1409 | </state> |
1461 | 1410 | </provider> |
1462 | 1411 | </entry> |
... | ... | @@ -1464,9 +1413,6 @@ |
1464 | 1413 | <provider selected="true" editor-type-id="text-editor"> |
1465 | 1414 | <state relative-caret-position="595"> |
1466 | 1415 | <caret line="110" column="0" lean-forward="false" selection-start-line="110" selection-start-column="0" selection-end-line="110" selection-end-column="0" /> |
1467 | - <folding> | |
1468 | - <element signature="e#0#27#0" expanded="false" /> | |
1469 | - </folding> | |
1470 | 1416 | </state> |
1471 | 1417 | </provider> |
1472 | 1418 | </entry> |
... | ... | @@ -1474,9 +1420,6 @@ |
1474 | 1420 | <provider selected="true" editor-type-id="text-editor"> |
1475 | 1421 | <state relative-caret-position="0"> |
1476 | 1422 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1477 | - <folding> | |
1478 | - <element signature="e#0#32#0" expanded="false" /> | |
1479 | - </folding> | |
1480 | 1423 | </state> |
1481 | 1424 | </provider> |
1482 | 1425 | </entry> |
... | ... | @@ -1484,7 +1427,6 @@ |
1484 | 1427 | <provider selected="true" editor-type-id="text-editor"> |
1485 | 1428 | <state relative-caret-position="0"> |
1486 | 1429 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1487 | - <folding /> | |
1488 | 1430 | </state> |
1489 | 1431 | </provider> |
1490 | 1432 | </entry> |
... | ... | @@ -1492,7 +1434,6 @@ |
1492 | 1434 | <provider selected="true" editor-type-id="text-editor"> |
1493 | 1435 | <state relative-caret-position="0"> |
1494 | 1436 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1495 | - <folding /> | |
1496 | 1437 | </state> |
1497 | 1438 | </provider> |
1498 | 1439 | </entry> |
... | ... | @@ -1500,9 +1441,6 @@ |
1500 | 1441 | <provider selected="true" editor-type-id="text-editor"> |
1501 | 1442 | <state relative-caret-position="-35"> |
1502 | 1443 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1503 | - <folding> | |
1504 | - <element signature="e#0#27#0" expanded="false" /> | |
1505 | - </folding> | |
1506 | 1444 | </state> |
1507 | 1445 | </provider> |
1508 | 1446 | </entry> |
... | ... | @@ -1518,7 +1456,6 @@ |
1518 | 1456 | <provider selected="true" editor-type-id="text-editor"> |
1519 | 1457 | <state relative-caret-position="0"> |
1520 | 1458 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1521 | - <folding /> | |
1522 | 1459 | </state> |
1523 | 1460 | </provider> |
1524 | 1461 | </entry> |
... | ... | @@ -1526,9 +1463,6 @@ |
1526 | 1463 | <provider selected="true" editor-type-id="text-editor"> |
1527 | 1464 | <state relative-caret-position="0"> |
1528 | 1465 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1529 | - <folding> | |
1530 | - <element signature="e#0#32#0" expanded="false" /> | |
1531 | - </folding> | |
1532 | 1466 | </state> |
1533 | 1467 | </provider> |
1534 | 1468 | </entry> |
... | ... | @@ -1536,7 +1470,6 @@ |
1536 | 1470 | <provider selected="true" editor-type-id="text-editor"> |
1537 | 1471 | <state relative-caret-position="0"> |
1538 | 1472 | <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
1539 | - <folding /> | |
1540 | 1473 | </state> |
1541 | 1474 | </provider> |
1542 | 1475 | </entry> |
... | ... | @@ -1544,7 +1477,6 @@ |
1544 | 1477 | <provider selected="true" editor-type-id="text-editor"> |
1545 | 1478 | <state relative-caret-position="0"> |
1546 | 1479 | <caret line="0" column="35" lean-forward="true" selection-start-line="0" selection-start-column="35" selection-end-line="0" selection-end-column="35" /> |
1547 | - <folding /> | |
1548 | 1480 | </state> |
1549 | 1481 | </provider> |
1550 | 1482 | </entry> |
... | ... | @@ -1552,7 +1484,6 @@ |
1552 | 1484 | <provider selected="true" editor-type-id="text-editor"> |
1553 | 1485 | <state relative-caret-position="289"> |
1554 | 1486 | <caret line="1476" column="0" lean-forward="false" selection-start-line="1476" selection-start-column="0" selection-end-line="1477" selection-end-column="72" /> |
1555 | - <folding /> | |
1556 | 1487 | </state> |
1557 | 1488 | </provider> |
1558 | 1489 | </entry> |
... | ... | @@ -1560,78 +1491,72 @@ |
1560 | 1491 | <provider selected="true" editor-type-id="text-editor"> |
1561 | 1492 | <state relative-caret-position="153"> |
1562 | 1493 | <caret line="9" column="0" lean-forward="true" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" /> |
1563 | - <folding> | |
1564 | - <element signature="e#0#32#0" expanded="false" /> | |
1565 | - </folding> | |
1566 | 1494 | </state> |
1567 | 1495 | </provider> |
1568 | 1496 | </entry> |
1569 | - <entry file="file://$PROJECT_DIR$/src/utils/JDManipulator.py"> | |
1497 | + <entry file="file://$PROJECT_DIR$/src/routine_manager/RequestSerializer.py"> | |
1570 | 1498 | <provider selected="true" editor-type-id="text-editor"> |
1571 | - <state relative-caret-position="1104"> | |
1572 | - <caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" /> | |
1573 | - <folding> | |
1574 | - <element signature="e#0#15#0" expanded="true" /> | |
1575 | - </folding> | |
1499 | + <state relative-caret-position="323"> | |
1500 | + <caret line="19" column="45" lean-forward="false" selection-start-line="19" selection-start-column="45" selection-end-line="19" selection-end-column="45" /> | |
1576 | 1501 | </state> |
1577 | 1502 | </provider> |
1578 | 1503 | </entry> |
1579 | - <entry file="file://$PROJECT_DIR$/src/monitoring/tasks.py"> | |
1504 | + <entry file="file://$PROJECT_DIR$/src/scheduler/tasks.py"> | |
1580 | 1505 | <provider selected="true" editor-type-id="text-editor"> |
1581 | - <state relative-caret-position="-79"> | |
1582 | - <caret line="46" column="0" lean-forward="false" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" /> | |
1583 | - <folding> | |
1584 | - <element signature="e#0#38#0" expanded="true" /> | |
1585 | - </folding> | |
1506 | + <state relative-caret-position="526"> | |
1507 | + <caret line="32" column="0" lean-forward="false" selection-start-line="32" selection-start-column="0" selection-end-line="32" selection-end-column="0" /> | |
1508 | + </state> | |
1509 | + </provider> | |
1510 | + </entry> | |
1511 | + <entry file="file://$PROJECT_DIR$/src/scheduler/Scheduler.py"> | |
1512 | + <provider selected="true" editor-type-id="text-editor"> | |
1513 | + <state relative-caret-position="396"> | |
1514 | + <caret line="689" column="29" lean-forward="false" selection-start-line="689" selection-start-column="29" selection-end-line="689" selection-end-column="29" /> | |
1586 | 1515 | </state> |
1587 | 1516 | </provider> |
1588 | 1517 | </entry> |
1589 | 1518 | <entry file="file://$PROJECT_DIR$/src/observation_manager/tasks.py"> |
1590 | 1519 | <provider selected="true" editor-type-id="text-editor"> |
1591 | - <state relative-caret-position="2312"> | |
1520 | + <state relative-caret-position="2277"> | |
1592 | 1521 | <caret line="136" column="82" lean-forward="true" selection-start-line="136" selection-start-column="47" selection-end-line="136" selection-end-column="82" /> |
1593 | 1522 | <folding> |
1594 | - <element signature="e#0#38#0" expanded="true" /> | |
1523 | + <element signature="e#0#38#0" expanded="false" /> | |
1595 | 1524 | </folding> |
1596 | 1525 | </state> |
1597 | 1526 | </provider> |
1598 | 1527 | </entry> |
1599 | - <entry file="file://$PROJECT_DIR$/src/scheduler/Scheduler.py"> | |
1528 | + <entry file="file://$PROJECT_DIR$/src/utils/JDManipulator.py"> | |
1600 | 1529 | <provider selected="true" editor-type-id="text-editor"> |
1601 | - <state relative-caret-position="396"> | |
1602 | - <caret line="689" column="29" lean-forward="false" selection-start-line="689" selection-start-column="29" selection-end-line="689" selection-end-column="29" /> | |
1530 | + <state relative-caret-position="170"> | |
1531 | + <caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" /> | |
1603 | 1532 | <folding> |
1604 | - <element signature="e#0#66#0" expanded="true" /> | |
1533 | + <element signature="e#0#15#0" expanded="false" /> | |
1605 | 1534 | </folding> |
1606 | 1535 | </state> |
1607 | 1536 | </provider> |
1608 | 1537 | </entry> |
1609 | - <entry file="file://$PROJECT_DIR$/src/scheduler/tasks.py"> | |
1538 | + <entry file="file://$PROJECT_DIR$/src/common/models.py"> | |
1610 | 1539 | <provider selected="true" editor-type-id="text-editor"> |
1611 | - <state relative-caret-position="526"> | |
1612 | - <caret line="32" column="0" lean-forward="false" selection-start-line="32" selection-start-column="0" selection-end-line="32" selection-end-column="0" /> | |
1613 | - <folding> | |
1614 | - <element signature="e#0#38#0" expanded="true" /> | |
1615 | - </folding> | |
1540 | + <state relative-caret-position="813"> | |
1541 | + <caret line="381" column="39" lean-forward="true" selection-start-line="381" selection-start-column="39" selection-end-line="381" selection-end-column="39" /> | |
1542 | + <folding /> | |
1616 | 1543 | </state> |
1617 | 1544 | </provider> |
1618 | 1545 | </entry> |
1619 | - <entry file="file://$PROJECT_DIR$/src/majordome/tasks.py"> | |
1546 | + <entry file="file://$PROJECT_DIR$/src/monitoring/tasks.py"> | |
1620 | 1547 | <provider selected="true" editor-type-id="text-editor"> |
1621 | - <state relative-caret-position="408"> | |
1622 | - <caret line="175" column="1" lean-forward="true" selection-start-line="175" selection-start-column="1" selection-end-line="175" selection-end-column="1" /> | |
1623 | - <folding> | |
1624 | - <element signature="e#0#38#0" expanded="true" /> | |
1625 | - </folding> | |
1548 | + <state relative-caret-position="441"> | |
1549 | + <caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" /> | |
1550 | + <folding /> | |
1626 | 1551 | </state> |
1627 | 1552 | </provider> |
1628 | 1553 | </entry> |
1629 | - <entry file="file://$PROJECT_DIR$/src/routine_manager/RequestSerializer.py"> | |
1554 | + <entry file="file://$PROJECT_DIR$/src/majordome/tasks.py"> | |
1630 | 1555 | <provider selected="true" editor-type-id="text-editor"> |
1631 | - <state relative-caret-position="323"> | |
1632 | - <caret line="19" column="45" lean-forward="true" selection-start-line="19" selection-start-column="45" selection-end-line="19" selection-end-column="45" /> | |
1556 | + <state relative-caret-position="357"> | |
1557 | + <caret line="161" column="18" lean-forward="true" selection-start-line="161" selection-start-column="18" selection-end-line="161" selection-end-column="18" /> | |
1633 | 1558 | <folding> |
1634 | - <element signature="e#0#32#0" expanded="true" /> | |
1559 | + <element signature="e#0#38#0" expanded="true" /> | |
1635 | 1560 | </folding> |
1636 | 1561 | </state> |
1637 | 1562 | </provider> | ... | ... |
src/common/models.py
... | ... | @@ -375,6 +375,7 @@ class Sequence(models.Model): |
375 | 375 | REJECTED = "RJTD" |
376 | 376 | CANCELLED = "CNCLD" |
377 | 377 | INVALID = "INVL" |
378 | + DEVICE_ERROR = "DVER" | |
378 | 379 | STATUS_CHOICES = ( |
379 | 380 | (INCOMPLETE, "Incomplete"), |
380 | 381 | (COMPLETE, "Complete"), |
... | ... | @@ -387,6 +388,7 @@ class Sequence(models.Model): |
387 | 388 | (REJECTED, "Rejected"), |
388 | 389 | (CANCELLED, "Cancelled"), |
389 | 390 | (INVALID, "Invalid"), |
391 | + (DEVICE_ERROR, "Device error"), | |
390 | 392 | ) |
391 | 393 | |
392 | 394 | request = models.ForeignKey( | ... | ... |
src/majordome/tasks.py
1 | 1 | from __future__ import absolute_import |
2 | - | |
2 | +import scheduler | |
3 | +import scheduler.tasks | |
3 | 4 | from celery.task import Task |
5 | +from celery import app | |
4 | 6 | import observation_manager |
5 | 7 | import observation_manager.tasks |
6 | 8 | from common.models import * |
... | ... | @@ -9,35 +11,27 @@ from devices.CameraVIS import VISCameraController |
9 | 11 | from devices.CameraNIR import NIRCameraController |
10 | 12 | from devices.PLC import PLCController |
11 | 13 | from django.conf import settings |
12 | - | |
13 | 14 | from utils.JDManipulator import * |
14 | 15 | import utils.config as L |
15 | 16 | log = L.setupLogger("MajordomeTaskLogger", "Majordome") |
16 | 17 | |
17 | -from devices import Telescope as Tel | |
18 | - | |
19 | -import time | |
20 | -import datetime | |
21 | -import scheduler | |
22 | -import scheduler.tasks | |
23 | - | |
24 | -from decimal import Decimal | |
25 | - | |
26 | -TIMESTAMP_JD = 2440587.500000 | |
27 | -DAILY_SECOND = 1 / 86400 | |
28 | -MAX_WAIT = 180 | |
29 | - | |
30 | 18 | ''' |
31 | - Task to handle the execution of ONE sequence | |
32 | - It receives the shs' id in parameter. | |
33 | - It prepairs the instruments and cut the sequence in plan. Then the execute_plan tasks are created. | |
19 | + Task to handle the execution of the program | |
34 | 20 | |
35 | - If possible, it advances the sequence start. | |
36 | - If the sequence can't start within MAX_WAIT seconds, it relaunches a scheduling | |
21 | + check the environment status in database (putted ther by the monitoring) | |
22 | + check the devices status (telescope / cameras) | |
23 | + check if the last schedule made has to be planned | |
24 | + launch schedule's sequences | |
37 | 25 | ''' |
38 | 26 | class Majordome(Task): |
39 | 27 | loop_speed = 1 |
40 | 28 | julian_div = 86400 |
29 | + executing_sequence = None | |
30 | + next_sequence = None | |
31 | + status_tel = "" | |
32 | + status_nir = "" | |
33 | + status_vis = "" | |
34 | + majordome_status = "STARTING" | |
41 | 35 | |
42 | 36 | |
43 | 37 | def setContext(self): |
... | ... | @@ -46,11 +40,6 @@ class Majordome(Task): |
46 | 40 | self.nir_camera = NIRCameraController() |
47 | 41 | self.plc = PLCController() |
48 | 42 | return (0) |
49 | - # self.vis_camera.do("COOLER", 1.0, -150.0) | |
50 | - # self.nir_camera.do("COOLER", 1.0, -150.0) | |
51 | - # | |
52 | - # self.tel.do("HOMING") | |
53 | - # self.tel.do("DOORS", True) | |
54 | 43 | |
55 | 44 | ''' |
56 | 45 | Function called by celery task |
... | ... | @@ -64,6 +53,7 @@ class Majordome(Task): |
64 | 53 | self.updateSoftware() |
65 | 54 | self.setTime() |
66 | 55 | self.setContext() |
56 | + self.majordome_status = "EXECUTING" | |
67 | 57 | self.loop() |
68 | 58 | |
69 | 59 | ''' |
... | ... | @@ -106,15 +96,16 @@ class Majordome(Task): |
106 | 96 | self.timer_status = 5 |
107 | 97 | self.timer_plc = 2 |
108 | 98 | self.timer_schedule = 1 |
99 | + self.timer_sequence = 1 | |
109 | 100 | |
110 | 101 | if (self.night_start - 120 > getCurrentTime()): |
111 | 102 | self.timer_night_start = self.night_start - 120 - getCurrentTime() |
112 | 103 | self.timer_night_end = self.night_end - getCurrentTime() |
113 | 104 | |
114 | 105 | self.timers = { |
115 | - "status": self.timer_status, "environement": self.timer_plc, | |
106 | + "status": self.timer_status, "environment": self.timer_plc, | |
116 | 107 | "night_start": self.timer_night_start, "night_end": self.timer_night_end, |
117 | - "schedule": self.timer_schedule | |
108 | + "schedule": self.timer_schedule, "sequence" : self.timer_sequence | |
118 | 109 | } |
119 | 110 | |
120 | 111 | # TODO: utiliser un logiciel by AK pour stocker en local le début et la fin de la nuit (on est peut-être dedans) |
... | ... | @@ -122,184 +113,243 @@ class Majordome(Task): |
122 | 113 | |
123 | 114 | ''' |
124 | 115 | Infinite loop according to the majordome behavior |
116 | + | |
117 | + This function is a little fat (core of pyros) -> we maybe should cut it | |
125 | 118 | ''' |
126 | 119 | def loop(self): |
127 | - while (True): | |
120 | + while (self.majordome_status != "SHUTDOWN"): | |
128 | 121 | minimal_timer = min(self.timers, key=self.timers.get) |
129 | 122 | if (self.timers[minimal_timer] > 0): |
130 | 123 | time.sleep(self.timers[minimal_timer]) |
131 | 124 | self.timers = {key: value - self.timers[minimal_timer] for key, value in self.timers.items()} |
132 | - | |
133 | 125 | for timer_name, timer_value in self.timers.items(): |
134 | 126 | if (timer_value <= 0): |
135 | 127 | if timer_name == "status": |
136 | - status_tel = self.tel.get("STATUS") | |
137 | - status_nir = self.nir_camera.get("STATUS") | |
138 | - status_vis = self.vis_camera.get("STATUS") | |
139 | - self.handleStatus(status_tel, status_nir, status_vis) | |
128 | + self.status_tel = self.tel.get("STATUS") | |
129 | + self.status_nir = self.nir_camera.get("STATUS") | |
130 | + self.status_vis = self.vis_camera.get("STATUS") | |
131 | + self.handleStatus() | |
140 | 132 | self.timers["status"] = self.timer_status |
141 | - elif (timer_name == "environement"): | |
133 | + elif (timer_name == "environment"): | |
142 | 134 | site_status = SiteWatch.objects.latest('updated') |
143 | 135 | weather_status = WeatherWatch.objects.latest('updated') |
144 | 136 | self.handlePLC(site_status, weather_status) |
145 | - self.timers["environement"] = self.timer_plc | |
146 | - elif (timer_name == "night_start"): | |
147 | - scheduler.tasks.scheduling.delay(first_schedule=False, alert=False) | |
148 | - self.timers["night_start"] = getNextNightStart() | |
149 | - elif (timer_name == "night_end"): | |
150 | - observation_manager.tasks.create_calibrations.delay() | |
151 | - self.timers["night_end"] = getNextNightEnd() | |
152 | - elif (timer_name == "schedule"): | |
153 | - self.schedule = Schedule.objects.latest('created') | |
154 | - shs_list = self.schedule.shs.filter(status=Sequence.PENDING) | |
155 | - self.executeSchedule(shs_list) | |
156 | - self.timers["scheduler"] = self.timer_schedule | |
137 | + self.timers["environment"] = self.timer_plc | |
138 | + if (self.isValidStatus(self.status_tel)): | |
139 | + if (timer_name == "night_start"): | |
140 | + scheduler.tasks.scheduling.delay(first_schedule=False, alert=False) | |
141 | + self.timers["night_start"] = getNextNightStart() | |
142 | + elif (timer_name == "night_end"): | |
143 | + observation_manager.tasks.create_calibrations.delay() | |
144 | + self.timers["night_end"] = getNextNightEnd() | |
145 | + elif (timer_name == "schedule"): | |
146 | + self.schedule = Schedule.objects.latest('created') | |
147 | + shs_list = self.schedule.shs.filter(status=Sequence.PENDING).order_by('tsp') | |
148 | + self.executeSchedule(shs_list) | |
149 | + self.timers["scheduler"] = self.timer_schedule | |
150 | + elif (timer_name == "sequence"): | |
151 | + if (self.executing_sequence != None): | |
152 | + self.handleSequence(self.executing_sequence[0], | |
153 | + self.executing_sequence[1], self.executing_sequence[2]) | |
154 | + self.timers["sequence"] = self.timer_sequence | |
155 | + else: | |
156 | + log.info("Timer : " + str(timer_name) + "is not known by the Majordome") | |
157 | + return (1) | |
157 | 158 | else: |
158 | - log.info("Timer " + str(timer_name) + "is not known by the Majordome") | |
159 | - return (1) | |
159 | + self.notifyTelescopeStatus(timer_name) | |
160 | + if (settings.DEBUG): | |
161 | + log.info("Timer : " + str(timer_name) + " executed") | |
162 | + return (0) | |
163 | + | |
164 | + def notifyDeviceStatus(self, device_name, timer_name, status): | |
165 | + Log.objects.create(agent=device_name, create=datetime.datetime.now(), | |
166 | + message="The action : " + str(timer_name) + " has been canceled : Telescope status : " | |
167 | + + status) | |
168 | + # maybe reset some variables and do a scheduling | |
160 | 169 | return (0) |
161 | 170 | |
162 | 171 | ''' |
163 | 172 | Function called when a schedule has to be executed |
164 | 173 | ''' |
165 | 174 | def executeSchedule(self, shs_list): |
175 | + for shs in shs_list: # shs_list is sorted by tsp | |
176 | + with shs.sequence as seq: | |
177 | + if (seq.status == Sequence.OBSERVABLE): | |
178 | + countdown = self.getCountdown(shs) | |
179 | + if countdown <= JulianSeconds(5): | |
180 | + if (self.executing_sequence == None): | |
181 | + self.executeSequence(shs, seq, countdown) | |
182 | + else: | |
183 | + self.setNextSequence(shs, seq, countdown) | |
184 | + return (0) | |
185 | + | |
186 | + ''' | |
187 | + Launch the observation tasks associated to a sequence | |
188 | + ''' | |
189 | + def executeSequence(self, shs, sequence, countdown): | |
190 | + plans_results = [] | |
191 | + | |
192 | + if sequence.albums.filter(detector__name="Cagire").exists(): | |
193 | + if (self.isValidStatus(self.status_nir)): | |
194 | + for plan in sequence.albums.get(detector__name="Cagire").plans.all(): | |
195 | + res = observation_manager.tasks.execute_plan_nir.apply_async((plan.id, countdown)) | |
196 | + TaskId.objects.create(task_id=res.id, task="execute_plan") | |
197 | + plans_results.append(res) | |
198 | + else: | |
199 | + self.notifyDeviceStatus("Cagire", "Sequence execution", self.status_nir) | |
200 | + sequence.status = Sequence.DEVICE_ERROR | |
201 | + sequence.save() | |
202 | + return (1) | |
203 | + if sequence.albums.filter(detector__name="Visible camera").exists(): | |
204 | + if (self.isValidStatus(self.status_vis)): | |
205 | + for plan in sequence.albums.get(detector__name="Visible camera").plans.all(): | |
206 | + res = observation_manager.tasks.execute_plan_vis.apply_async((plan.id, countdown)) | |
207 | + TaskId.objects.create(task_id=res.id, task="execute_plan") | |
208 | + plans_results.append(res) | |
209 | + else: | |
210 | + self.notifyDeviceStatus("Camera visible", "Sequence execution", self.status_vis) | |
211 | + sequence.status = Sequence.DEVICE_ERROR | |
212 | + sequence.save() | |
213 | + return (1) | |
214 | + shs.status = Sequence.EXECUTING | |
215 | + sequence.status = Sequence.EXECUTING | |
216 | + shs.save() | |
217 | + sequence.save() | |
218 | + self.executing_sequence = [shs, sequence, plans_results] | |
219 | + return (0) | |
220 | + | |
221 | + ''' | |
222 | + Set the next sequence | |
223 | + ''' | |
224 | + def setNextSequence(self, shs, sequence, countdown): | |
225 | + self.next_sequence = [shs, sequence, countdown] | |
166 | 226 | return (0) |
167 | -# TaskId.objects.filter(task_id=self.request.id).delete() | |
168 | -# shs = ScheduleHasSequences.objects.get(pk=shs_pk) | |
169 | -# sequence = shs.sequence | |
170 | -# | |
171 | -# if sequence.status != Sequence.OBSERVABLE: | |
172 | -# return | |
173 | -# | |
174 | -# message = 'Start sequence ' + str(sequence.pk) + ' execution' | |
175 | -# Log.objects.create(agent='Majordome', message=message) | |
176 | -# | |
177 | -# print("execute_sequence : ", sequence.pk) | |
178 | -# | |
179 | -# countdown = self.get_countdown(shs, sequence) | |
180 | -# | |
181 | -# if countdown > MAX_WAIT * DAILY_SECOND: | |
182 | -# scheduler.tasks.scheduling.delay(first_schedule=False, alert=False) | |
183 | -# return | |
184 | -# | |
185 | -# tel = Tel.TelescopeController() | |
186 | -# | |
187 | -# tel.set("SPEED", 10.0, 10.0, 10.0) | |
188 | -# tel.set("COORDS", 104.0, 12.0, 88.0) | |
189 | -# tel.set("COORDS_FRAME", "Radec") | |
190 | -# tel.set("TRACKING_SPEED", 0.3, 0.3, 0.3) | |
191 | -# tel.set("ACCEL", 1.0, 1.0, 1.0) | |
192 | -# tel.set("ROTATOR", "Tracking") | |
193 | -# tel.set("FOCUS", 23562.0) | |
194 | -# tel.set("MOVE_MODE", "GotoTrack") | |
195 | -# | |
196 | -# tel.do("START") | |
197 | -# | |
198 | -# countdown = 1 # TODO: à virer, juste pour pouvoir tester | |
199 | -# | |
200 | -# plans_results = [] | |
201 | -# | |
202 | -# if sequence.albums.filter(detector__name="Cagire").exists(): | |
203 | -# for plan in sequence.albums.get(detector__name="Cagire").plans.all(): | |
204 | -# res = observation_manager.tasks.execute_plan_nir.apply_async((plan.id, countdown)) | |
205 | -# TaskId.objects.create(task_id=res.id, task="execute_plan") | |
206 | -# plans_results.append(res) | |
207 | -# | |
208 | -# if sequence.albums.filter(detector__name="Visible camera").exists(): | |
209 | -# for plan in sequence.albums.get(detector__name="Visible camera").plans.all(): | |
210 | -# res = observation_manager.tasks.execute_plan_vis.apply_async((plan.id, countdown)) | |
211 | -# TaskId.objects.create(task_id=res.id, task="execute_plan") | |
212 | -# plans_results.append(res) | |
213 | -# | |
214 | -# shs.status = Sequence.EXECUTING | |
215 | -# sequence.status = Sequence.EXECUTING | |
216 | -# shs.save() | |
217 | -# sequence.save() | |
218 | -# | |
219 | -# for plan_result in plans_results: | |
220 | -# try: | |
221 | -# while plan_result.ready() == False: | |
222 | -# print("not finished") | |
223 | -# time.sleep(1) | |
224 | -# print("result : %s " % (plan_result.status,)) | |
225 | -# except Exception as e: | |
226 | -# print("exception : %s" % (str(e),)) | |
227 | -# shs.status = Sequence.CANCELLED | |
228 | -# shs.save() | |
229 | -# sequence.status = Sequence.CANCELLED | |
230 | -# sequence.save() | |
231 | -# # TODO: rendre le quota à l'utilisateur | |
232 | -# return | |
233 | -# | |
234 | -# shs.status = Sequence.EXECUTED | |
235 | -# sequence.status = Sequence.EXECUTED | |
236 | -# shs.save() | |
237 | -# sequence.save() | |
238 | -# message = 'Finished sequence ' + str(sequence.pk) + ' execution' | |
239 | -# Log.objects.create(agent='Majordome', message=message) | |
240 | 227 | |
228 | + ''' | |
229 | + Switch sequences | |
230 | + ''' | |
231 | + def switchSequence(self): | |
232 | + if (self.next_sequence == None): | |
233 | + self.executing_sequence = None | |
234 | + else: | |
235 | + self.executing_sequence = None | |
236 | + self.executeSequence(self.executing_sequence[0], | |
237 | + self.executing_sequence[1], self.executing_sequence[2]) | |
238 | + self.next_sequence = None | |
239 | + return (0) | |
240 | + | |
241 | + ''' | |
242 | + Check if the current sequence is finished | |
243 | + ''' | |
244 | + def handleSequence(self, shs, sequence, executing_plans): | |
245 | + finished = False | |
246 | + error = False | |
247 | + | |
248 | + for plan in executing_plans: | |
249 | + try: | |
250 | + if plan.ready() == False: | |
251 | + finished = True | |
252 | + except Exception as e: | |
253 | + error = True | |
254 | + shs.status = Sequence.CANCELLED | |
255 | + sequence.status = Sequence.CANCELLED | |
256 | + shs.save() | |
257 | + sequence.save() | |
258 | + for rev in executing_plans: | |
259 | + if (not rev.failed() and rev.ready() != True): | |
260 | + app.control.revoke(rev.id) | |
261 | + self.switchSequence() | |
262 | + return (-1) | |
263 | + if (finished): | |
264 | + sequence.status = Sequence.EXECUTED | |
265 | + shs.status = Sequence.EXECUTED | |
266 | + sequence.save() | |
267 | + shs.save() | |
268 | + message = "Finished sequence " + str(sequence.pk) + " execution" | |
269 | + Log.objects.create(agent="Majordome", message=message) | |
270 | + self.switchSequence() | |
271 | + return (0) | |
241 | 272 | |
242 | 273 | ''' |
243 | 274 | Function called to do an action with the devices status |
244 | 275 | ''' |
245 | - def handleStatus(self, status_tel, status_nir, status_vis): | |
276 | + def handleStatus(self): | |
277 | + telescope = Telescope.objects.first() | |
278 | + camera_nir = Detector.objects.get(name="Cagire") | |
279 | + camera_vis = Detector.objects.get(name="Visible camera") | |
280 | + telescope.status = self.status_tel | |
281 | + camera_nir.status = self.status_nir | |
282 | + camera_vis.status = self.status_vis | |
246 | 283 | return (0) |
247 | 284 | |
248 | 285 | ''' |
286 | + Check if the instrument status is valid | |
287 | + ''' | |
288 | + def isValidStatus(self, status): | |
289 | + if (status == "" or status == "ERROR"): | |
290 | + return (False) | |
291 | + return (True) | |
292 | + | |
293 | + ''' | |
249 | 294 | Function called to do an action with the site status and the wheather status |
250 | 295 | ''' |
251 | 296 | def handlePLC(self, site_status, weather_status): |
252 | 297 | return (0) |
253 | 298 | |
254 | - def get_countdown(self, shs, sequence): | |
255 | - """ | |
256 | - Gets the time before the expected start of the execution. | |
257 | - If it is > 10s, tries to get the sequence ahead according the JD1 | |
258 | - """ | |
259 | - countdown = 0 | |
260 | - | |
261 | - current_time = Decimal(time.time() / 86400 + TIMESTAMP_JD) | |
262 | - time_before_exec = shs.tsp - current_time | |
263 | - | |
264 | - if time_before_exec > 10 * DAILY_SECOND: | |
265 | - time_before_jd1 = sequence.jd1 - current_time | |
266 | - if time_before_jd1 < 0: | |
267 | - pass | |
268 | - elif time_before_jd1 < time_before_exec: | |
269 | - countdown = time_before_jd1 | |
270 | - else: | |
271 | - countdown = time_before_exec | |
299 | + """ | |
300 | + Gets the time before the expected start of the execution. | |
301 | + """ | |
302 | + def getCountdown(self, shs): | |
303 | + # TODO start sequence as soon as possible (a lot of verifications must be done there) | |
304 | + current_time = secondsToJulianDate(getPreciseCurrentTime()); | |
305 | + countdown = shs.tsp - current_time | |
272 | 306 | return countdown |
273 | 307 | |
308 | +''' | |
309 | + Task called by the monitoring in case of problem. | |
310 | + It stops the system and the instruments. | |
311 | +''' | |
274 | 312 | class system_pause(Task): |
275 | - ''' | |
276 | - Task called by the monitoring in case of problem. | |
277 | - It stops the system and the instruments. | |
278 | - ''' | |
279 | - | |
280 | 313 | def run(self): |
281 | 314 | time.sleep(5) |
282 | 315 | print("system_pause") |
283 | 316 | |
284 | 317 | |
318 | +''' | |
319 | + Task called by the monitoring when there is no more problem. | |
320 | + Should just make a scheduling. | |
321 | +''' | |
285 | 322 | class system_restart(Task): |
286 | - ''' | |
287 | - Task called by the monitoring when there is no more problem. | |
288 | - Should just make a scheduling. | |
289 | - ''' | |
290 | 323 | |
291 | 324 | def run(self): |
292 | 325 | time.sleep(5) |
293 | 326 | print("system_restart") |
294 | 327 | |
295 | 328 | |
329 | +''' | |
330 | + Task called by the monitoring when the obs condition have changed. | |
331 | + It reads them in the DB and changes the sequences status in consequence. | |
332 | + If needed, relaunches a scheduling | |
333 | +''' | |
296 | 334 | class change_obs_conditions(Task): |
297 | - ''' | |
298 | - Task called by the monitoring when the obs condition have changed. | |
299 | - It reads them in the DB and changes the sequences status in consequence. | |
300 | - If needed, relaunches a scheduling | |
301 | - ''' | |
302 | 335 | def run(self): |
303 | 336 | # important : penser à rendre les quotas aux users |
304 | 337 | time.sleep(5) |
305 | 338 | print("change_obs_conditions") |
339 | + | |
340 | + | |
341 | +# Previouns code | |
342 | +# -------------------------------------------------- | |
343 | +# tel = Tel.TelescopeController() | |
344 | +# | |
345 | +# tel.set("SPEED", 10.0, 10.0, 10.0) | |
346 | +# tel.set("COORDS", 104.0, 12.0, 88.0) | |
347 | +# tel.set("COORDS_FRAME", "Radec") | |
348 | +# tel.set("TRACKING_SPEED", 0.3, 0.3, 0.3) | |
349 | +# tel.set("ACCEL", 1.0, 1.0, 1.0) | |
350 | +# tel.set("ROTATOR", "Tracking") | |
351 | +# tel.set("FOCUS", 23562.0) | |
352 | +# tel.set("MOVE_MODE", "GotoTrack") | |
353 | +# | |
354 | +# tel.do("START") | |
355 | +# ------------------------------------------------- | ... | ... |
src/utils/JDManipulator.py
... | ... | @@ -4,15 +4,19 @@ from decimal import * |
4 | 4 | |
5 | 5 | JD_VALUE = 86400 |
6 | 6 | TIMESTAMP_JD = 2440587.500000 |
7 | +DAILY_SECOND = 1 / 86400 | |
8 | + | |
9 | +def JulianSeconds(value): | |
10 | + return (Decimal(value * DAILY_SECOND)) | |
7 | 11 | |
8 | 12 | def getPreciseCurrentTime(): |
9 | 13 | return (Decimal(getCurrentTime())) |
10 | 14 | |
11 | -def getPreciseDefaultNightStart(): | |
12 | - return (Decimal(getDefaultNightStart())) | |
15 | +def getPreciseNightStart(): | |
16 | + return (Decimal(getNightStart())) | |
13 | 17 | |
14 | -def getPreciseDefaultNightEnd(): | |
15 | - return (Decimal(getDefaultNightEnd())) | |
18 | +def getPreciseNightEnd(): | |
19 | + return (Decimal(getNightEnd())) | |
16 | 20 | |
17 | 21 | def secondsToJulianDate(time_seconds): |
18 | 22 | return (time_seconds / 86400 + TIMESTAMP_JD) | ... | ... |