Skip to content

Commit eccfc9c

Browse files
committed
upload by mushding
1 parent 7664d46 commit eccfc9c

13 files changed

+118
-32
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.DS_STORE
22
node_modules
3-
pythonHTTP
3+
*.avi
44
scripts/flow/*/.flowconfig
55
*~
66
*.pyc

app.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,29 @@ def checkPower():
321321
@app.route('/getOnlyLight/<int:index>', methods=['GET'])
322322
def getOnlyLight(index):
323323
requests.get('http://192.168.50.49/set_lock?params=' + str(index))
324+
db.firstRoomPower.find_one_and_update({
325+
"isOpen": {"$exists": True}},
326+
{"$set": {"isOpen": index},
327+
})
324328
return "ok"
325329

326330
# Get Electric Power (49) for progress
327331
@app.route('/getPower/<int:index>', methods=['GET'])
328332
def getPower(index):
333+
power = requests.get('http://192.168.50.49')
334+
329335
if index == 1:
330336
meg_state = " 打開了!"
331337
if index == 0:
332338
meg_state = " 關起來了!"
333339

334340
# sound effect
335-
if index == 1:
341+
if index == 1 and power.json()['variables']['lock'] == 0:
336342
requests.get('http://192.168.50.210:5000/playFirstRoomPowerOn')
337343
time.sleep(1.1)
338344

339345
# Open Camera
340-
if index == 1:
346+
if index == 1 and power.json()['variables']['lock'] == 0:
341347
requests.get('http://192.168.50.225:8888/setFirstRoomCamera/1')
342348
requests.get('http://192.168.50.225:8888/setFirstRoomCamera/2')
343349
elif index == 0:
@@ -1266,19 +1272,35 @@ def checkStoreVideo(name, pid):
12661272
if name == "frame_person_A.avi":
12671273
os.system('kill -9 ' + str(pid))
12681274
db.videoState.update({"name": "videoState"}, {"$set": {"A_done": True}}, True)
1275+
db.notifications.insert({
1276+
'_id': nextNotifications("productid"),
1277+
'avatarIcon': "DialpadIcon",
1278+
'message': "A is done",})
12691279
m=os.system("./videoB.sh &")
12701280
if name == "frame_person_B.avi":
12711281
os.system('kill -9 ' + str(pid))
12721282
db.videoState.update({"name": "videoState"}, {"$set": {"B_done": True}}, True)
1283+
db.notifications.insert({
1284+
'_id': nextNotifications("productid"),
1285+
'avatarIcon': "DialpadIcon",
1286+
'message': "B is done",})
12731287
m=os.system("./videoC.sh &")
12741288
if name == "frame_person_C.avi":
12751289
os.system('kill -9 ' + str(pid))
12761290
db.videoState.update({"name": "videoState"}, {"$set": {"C_done": True}}, True)
1291+
db.notifications.insert({
1292+
'_id': nextNotifications("productid"),
1293+
'avatarIcon': "DialpadIcon",
1294+
'message': "C is done",})
12771295
m=os.system("./videoD.sh &")
12781296
if name == "frame_person_D.avi":
12791297
os.system('kill -9 ' + str(pid))
12801298
# start merge video
12811299
os.system('python3 ./merge_video.py &')
1300+
db.notifications.insert({
1301+
'_id': nextNotifications("productid"),
1302+
'avatarIcon': "DialpadIcon",
1303+
'message': "D is done",})
12821304
db.videoState.update({"name": "videoState"}, {"$set": {"D_done": True}}, True)
12831305
if m==0:
12841306
return "開始儲存"
15.2 MB
Binary file not shown.
6.56 MB
Binary file not shown.
-1.27 MB
Binary file not shown.
1.02 MB
Binary file not shown.

pythonHTTP/storevideo/merge.avi

9.44 MB
Binary file not shown.

pythonHTTP/storevideo/outputA.avi

-1.11 MB
Binary file not shown.

pythonHTTP/storevideo/outputB.avi

-1.9 MB
Binary file not shown.

pythonHTTP/storevideo/outputC.avi

-1.69 MB
Binary file not shown.

pythonHTTP/storevideo/outputD.avi

-4.48 MB
Binary file not shown.

src/SaveVideo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class SaveVideo extends React.Component {
165165
.get('http://192.168.50.225:8888/checkVideo')
166166
.then(data => {
167167
data=data["data"];
168-
console.log("end:"+this.state.end+",start:"+this.state.start);
168+
// console.log("end:"+this.state.end+",start:"+this.state.start);
169169
const newCompleted = this.state.completed;
170170
newCompleted[0] = data["state"]["A_done"];
171171
newCompleted[1] = data["state"]["B_done"];

src/Stepper/Room1.js

+92-28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import StepLabel from '@material-ui/core/StepLabel';
88
import clsx from 'clsx';
99
import PropTypes from 'prop-types';
1010

11+
import Dialog from '@material-ui/core/Dialog';
12+
import DialogActions from '@material-ui/core/DialogActions';
13+
import DialogTitle from '@material-ui/core/DialogTitle';
14+
import Button from '@material-ui/core/Button'
15+
1116
import PhonelinkLockIcon from '@material-ui/icons/PhonelinkLock';
1217
import EmojiObjectsRoundedIcon from '@material-ui/icons/EmojiObjectsRounded';
1318
import CreditCardRoundedIcon from '@material-ui/icons/CreditCardRounded';
@@ -100,24 +105,30 @@ function getSteps() {
100105
return (['燈', 'RFID','手機解鎖']);
101106
}
102107

103-
function getStepContent(step) {
104-
switch (step) {
105-
case 0:
106-
console.log('Step 1') ;
107-
break;
108-
case 1:
109-
console.log('Step 2') ;
110-
break;
111-
case 2:
112-
console.log('Step 3') ;
113-
break;
114-
case 3:
115-
console.log('Step 4') ;
116-
break;
117-
default:
118-
console.log('unknow');
119-
}
120-
}
108+
// function getStepContent(step) {
109+
// switch (step) {
110+
// case 0:
111+
// console.log('control Light') ;
112+
// setOpen(true);
113+
// break;
114+
// case 1:
115+
// console.log('close RFID') ;
116+
// axios
117+
// .get('http://192.168.50.225:8888/resetRFID/0')
118+
// .then(res => {
119+
// // console.log(res)
120+
// })
121+
// break;
122+
// case 2:
123+
// console.log('Step 3') ;
124+
// break;
125+
// case 3:
126+
// console.log('Step 4') ;
127+
// break;
128+
// default:
129+
// console.log('unknow');
130+
// }
131+
// }
121132

122133
function useInterval(callback, delay) {
123134
const savedCallback = useRef();
@@ -144,6 +155,8 @@ export default function HorizontalNonLinearStepper() {
144155
const [activeStep, setActiveStep] = React.useState(0);
145156
const [completed, setCompleted] = React.useState({});
146157
const [count, setCount] = useState(0);
158+
const [open, setOpen] = useState(false);
159+
const [isOpen, setIsOpen] = useState(false);
147160
const steps = getSteps();
148161

149162
useInterval(() => {
@@ -178,18 +191,69 @@ export default function HorizontalNonLinearStepper() {
178191
getStepContent(step);
179192
};
180193

194+
const openLight = () =>{
195+
axios
196+
.get('http://192.168.50.225:8888/getOnlyLight/1')
197+
}
198+
199+
const closeLight = () =>{
200+
axios
201+
.get('http://192.168.50.225:8888/getOnlyLight/0')
202+
}
203+
204+
const getStepContent = step => {
205+
switch (step) {
206+
case 0:
207+
console.log('control Light') ;
208+
setOpen(true);
209+
break;
210+
case 1:
211+
console.log('close RFID') ;
212+
axios
213+
.get('http://192.168.50.225:8888/resetRFID/0')
214+
.then(res => {
215+
// console.log(res)
216+
})
217+
break;
218+
case 2:
219+
console.log('Step 3') ;
220+
break;
221+
case 3:
222+
console.log('Step 4') ;
223+
break;
224+
default:
225+
console.log('unknow');
226+
}
227+
}
228+
181229
return (
182-
<div className={classes.root}>
230+
<div className={classes.root}>
183231
{/* <h1>{count}</h1> */}
184232
<Stepper nonLinear activeStep={null} alternativeLabel connector={<ColorlibConnector />}>
185-
{steps.map((label, index) => (
186-
<Step key={label}>
187-
<StepButton onClick={handleStep(index)} completed={completed[index]}>
188-
<StepLabel StepIconComponent={ColorlibStepIcon}>{label}</StepLabel>
189-
</StepButton>
190-
</Step>
191-
))}
192-
</Stepper>
193-
</div>
233+
{steps.map((label, index) => (
234+
<Step key={label}>
235+
<StepButton onClick={handleStep(index)} completed={completed[index]}>
236+
<StepLabel StepIconComponent={ColorlibStepIcon}>{label}</StepLabel>
237+
</StepButton>
238+
</Step>
239+
))}
240+
</Stepper>
241+
<Dialog
242+
open={open}
243+
onClose={()=>{setOpen(false)}}
244+
aria-labelledby="alert-dialog-title"
245+
aria-describedby="alert-dialog-description"
246+
>
247+
<DialogTitle id="alert-dialog-title">{"Control Light"}</DialogTitle>
248+
<DialogActions>
249+
<Button onClick={()=>{openLight()}} color="primary">
250+
Open
251+
</Button>
252+
<Button onClick={()=>{closeLight()}} color="primary" autoFocus>
253+
Close
254+
</Button>
255+
</DialogActions>
256+
</Dialog>
257+
</div>
194258
);
195259
}

0 commit comments

Comments
 (0)