Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/observatory/observatorydomemodel.cpp
- This file was added.
1 | /* Ekos Observatory Module | ||||
---|---|---|---|---|---|
2 | Copyright (C) Wolfgang Reissenberger <sterne-jaeger@t-online.de> | ||||
3 | | ||||
4 | This application is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | */ | ||||
9 | | ||||
10 | #include "observatorydomemodel.h" | ||||
11 | | ||||
12 | namespace Ekos | ||||
13 | { | ||||
14 | | ||||
15 | void ObservatoryDomeModel::initModel(Dome *dome) | ||||
16 | { | ||||
17 | mDome = dome; | ||||
18 | | ||||
19 | connect(mDome, &Dome::ready, this, &ObservatoryDomeModel::ready); | ||||
20 | connect(mDome, &Dome::disconnected, this, &ObservatoryDomeModel::disconnected); | ||||
21 | connect(mDome, &Dome::newStatus, this, &ObservatoryDomeModel::newStatus); | ||||
22 | connect(mDome, &Dome::newShutterStatus, this, &ObservatoryDomeModel::newShutterStatus); | ||||
23 | | ||||
24 | } | ||||
25 | | ||||
26 | | ||||
27 | ISD::Dome::Status ObservatoryDomeModel::status() | ||||
28 | { | ||||
29 | if (mDome == nullptr) | ||||
30 | return ISD::Dome::DOME_IDLE; | ||||
31 | | ||||
32 | return mDome->status(); | ||||
33 | } | ||||
34 | | ||||
35 | ISD::Dome::ShutterStatus ObservatoryDomeModel::shutterStatus() | ||||
36 | { | ||||
37 | if (mDome == nullptr) | ||||
38 | return ISD::Dome::SHUTTER_UNKNOWN; | ||||
39 | | ||||
40 | return mDome->shutterStatus(); | ||||
41 | } | ||||
42 | | ||||
43 | void ObservatoryDomeModel::park() | ||||
44 | { | ||||
45 | if (mDome == nullptr) | ||||
46 | return; | ||||
47 | | ||||
48 | emit newLog("Parking dome..."); | ||||
49 | mDome->park(); | ||||
50 | } | ||||
51 | | ||||
52 | | ||||
53 | void ObservatoryDomeModel::unpark() | ||||
54 | { | ||||
55 | if (mDome == nullptr) | ||||
56 | return; | ||||
57 | | ||||
58 | emit newLog("Unparking dome..."); | ||||
59 | mDome->unpark(); | ||||
60 | } | ||||
61 | | ||||
62 | void ObservatoryDomeModel::openShutter() | ||||
63 | { | ||||
64 | if (mDome == nullptr) | ||||
65 | return; | ||||
66 | | ||||
67 | emit newLog("Opening shutter..."); | ||||
68 | mDome->controlShutter(true); | ||||
69 | } | ||||
70 | | ||||
71 | void ObservatoryDomeModel::closeShutter() | ||||
72 | { | ||||
73 | if (mDome == nullptr) | ||||
74 | return; | ||||
75 | | ||||
76 | emit newLog("Closing shutter..."); | ||||
77 | mDome->controlShutter(false); | ||||
78 | } | ||||
79 | | ||||
80 | void ObservatoryDomeModel::execute(WeatherActions actions) | ||||
81 | { | ||||
82 | if (hasShutter() && actions.closeShutter) | ||||
83 | closeShutter(); | ||||
84 | if (actions.parkDome) | ||||
85 | park(); | ||||
86 | } | ||||
87 | | ||||
88 | } |