From 5724f7218591f876e5d163b288be548e28cc769d Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 20 May 2024 14:21:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=B0=83=E6=95=B4=E6=9A=82?= =?UTF-8?q?=E6=8F=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trainingCloseDoorFault.gd | 156 ++++++++++++++---- .../trainingCloseDoorFault.tscn | 6 +- 2 files changed, 132 insertions(+), 30 deletions(-) diff --git a/trainings/trainingCloseDoorFault/trainingCloseDoorFault.gd b/trainings/trainingCloseDoorFault/trainingCloseDoorFault.gd index 962a837..f20e2f9 100644 --- a/trainings/trainingCloseDoorFault/trainingCloseDoorFault.gd +++ b/trainings/trainingCloseDoorFault/trainingCloseDoorFault.gd @@ -5,24 +5,101 @@ extends Node ## 场景描述 @export var trainingDesc: String = "列车关门作业,突发单个站台门未正常关闭。" -var currentStep = [] +var stepOperation = [] -var handleStep = [{"stepName": "步骤一:站务员用对讲机汇报值班员:值班员,上行2号门关门故障,使用LCB关闭站台门。", "stepOperation": [],}, - {"stepName": "步骤二:值班员回复:收到。", "stepOperation": []}, - {"stepName": "步骤三:站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“关门”位置。", "stepOperation": ["LCB2","LCB_Key1","confirmUseKey","LCB2RightRotate"]}, - {"stepName": "步骤四:站务员确认故障门关闭。站务员手指:上行2号门门头灯和上行2号站台门。", "stepOperation": []}, - {"stepName": "步骤五:站务员口呼:门头灯熄灭,关门成功。", "stepOperation": ["LCB3LeftRotate"]}, - {"stepName": "步骤六:站务员口呼:故障门处置完毕。", "stepOperation": []}, - {"stepName": "步骤七:列车出清站台后,站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“自动”位置,取出钥匙。", "stepOperation": ["LCB2LeftRotate","removeKeyOfWindowLCB2"]}, - {"stepName": "步骤八:站务员用对讲机汇报值班员:值班员,上行2号门故障已处理完毕。", "stepOperation": []}, - {"stepName": "步骤九:值班员回复:收到。", "stepOperation": []}, +var handleStep = [ + { + "stepName": "步骤一:站务员手指:上行2号门门头灯", + "stepOperation": [], + "next": true, + "waitTime": 3, + "play": false, + "notip": false, + "checkVoice": "" + }, + { + "stepName": "步骤二:站务员口呼:上行2号门门头灯亮,关门故障。", + "stepOperation": [], + "next": false, + "checkVoice": "上行2号门门头灯亮,关门故障。", + "play": false, + "notip": false, + }, + { + "stepName": "步骤三:站务员用对讲机汇报值班员:值班员,上行2号门关门故障,使用LCB关闭站台门。", "stepOperation": [], + "next": false, + "checkVoice": "值班员,上行2号门关门故障,使用LCB关闭站台门。", + "play": false, + "notip": false, + }, + { + "stepName": "值班员回复:收到。", + "stepOperation": [], + "play": true, + "notip": true, + "next": false, + }, + { + "stepName": "步骤四:站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“关门”位置。", + "stepOperation": ["LCB2","LCB_Key1","confirmUseKey","LCB2RightRotate"], + "play": false, + "notip": false, + "next": false, + }, + { + "stepName": "步骤五:站务员确认故障门关闭。站务员手指:上行2号门门头灯和上行2号站台门。", "stepOperation": [], + "next": true, + "waitTime": 3, + "play": false, + "notip": false, + }, + { + "stepName": "步骤六:站务员口呼:门头灯熄灭,关门成功。", + "stepOperation": [], + "checkVoice": "门头灯熄灭,关门成功。", + "next": false, + "play": false, + "notip": false, + }, + { + "stepName": "步骤七:站务员口呼:故障门处置完毕。", + "stepOperation": [], + "checkVoice":"故障门处置完毕", + "next": false, + "play": false, + "notip": false, + }, + { + "stepName": "步骤八:列车出清站台后,站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“自动”位置,取出钥匙。", + "stepOperation": ["LCB2LeftRotate","removeKeyOfWindowLCB2"], + "next": false, + "play": false, + "notip": false, + }, + { + "stepName": "步骤九:站务员用对讲机汇报值班员:值班员,上行2号门故障已处理完毕。", + "stepOperation": [], + "checkVoice":"值班员,上行2号门故障已处理完毕。", + "next": false, + "play": false, + "notip": false, + }, + { + "stepName": "值班员回复:收到。", + "stepOperation": [], + "play": true, + "notip": false, + "next": false, + }, ] +var stepOperationIndex = 0 var stepIndex = 0 func _ready(): $TrainingDescDialog.title = trainingName $TrainingDescDialog.updateSceneDesc(trainingDesc) + stepOperationIndex = 0 stepIndex = 0 @@ -45,38 +122,54 @@ func load_mp3(path): sound.data = file.get_buffer(file.get_length()) return sound +func nextStep(): + if stepIndex < handleStep.size(): + var step = handleStep[stepIndex] + stepIndex = stepIndex + 1 + print(step,'2') + $StepTip.updateOperationTip(step.stepName) + if step.stepOperation.size() > 0: + initStepOperation() + if step.next == true: + $StepTimer.wait_time = 2 + $StepTimer.one_shot = true + $StepTimer.connect("timeout", nextStep) + $StepTimer.start() + if step.checkVoice: + print('speech_record_check') + $VoiceCommunication.speech_record_check(step.checkVoice) + if step.play: + var sound = load_mp3("res://Assets/training_speech/sd.mp3") + await $VoiceCommunication.play_reply(sound) + nextStep() + +func setOperationNodeAndTip(): + $total.currenNeedClickNode = stepOperation[stepOperationIndex] + if $total.trainingMode == TotalScene.Training_Mode.Teach: + $TrainTip.setTrainingTip($total.allClickEquipmentInfo[stepOperation[stepOperationIndex]]) + +func initStepOperation(): + stepOperation = handleStep[stepIndex].stepOperation + stepOperationIndex = 0 func _on_total_screen_door_close_confirm_signal(screenDoor): if screenDoor.name == "screenDoor1": - $StepTip.updateOperationTip(handleStep[0].stepName) - #var sound = load_mp3("res://Assets/training_speech/gmgz/2hmgmgz.mp3") - #await $VoiceCommunication.play_reply(sound) - #$total.currenNeedClickNode = currentStep[stepIndex] - #if $total.trainingMode == TotalScene.Training_Mode.Teach: - #$TrainTip.setTrainingTip($total.allClickEquipmentInfo[currentStep[stepIndex]]) + nextStep() + print('screenDoor') if screenDoor.name == "screenDoor2": var sound3 = load_mp3("res://Assets/training_speech/gmgz/mtdxm.mp3") await $VoiceCommunication.play_reply(sound3) $total.trainLeave() - -func _input(event): - if event is InputEventKey: - if event.pressed: - if event.keycode == KEY_SPACE: # 检查是否按下了空格键 - $VoiceCommunication.speech_record_check(event.keycode) - - func _on_total_current_click_check_signal(isCorrect): if isCorrect: - stepIndex = stepIndex + 1 + stepOperationIndex = stepOperationIndex + 1 $StepJudgment.hideError() - if stepIndex < currentStep.size(): - $total.currenNeedClickNode = currentStep[stepIndex] - if $total.trainingMode == TotalScene.Training_Mode.Teach: - $TrainTip.setTrainingTip($total.allClickEquipmentInfo[currentStep[stepIndex]]) + if stepOperationIndex < stepOperation.size(): + setOperationNodeAndTip() else: $TrainTip.setTrainingTip('') + nextStep() else: if $total.trainingMode != TotalScene.Training_Mode.Exam: $StepJudgment.showError() @@ -93,3 +186,8 @@ func _on_confirm_dialog_two_cancel(): func _on_confirm_dialog_two_confirm(): get_tree().paused = false get_tree().reload_current_scene() + + +func _on_voice_communication_speech_recognition_successed() -> void: + print('111111111111') + nextStep() diff --git a/trainings/trainingCloseDoorFault/trainingCloseDoorFault.tscn b/trainings/trainingCloseDoorFault/trainingCloseDoorFault.tscn index 903a67a..d8745bf 100644 --- a/trainings/trainingCloseDoorFault/trainingCloseDoorFault.tscn +++ b/trainings/trainingCloseDoorFault/trainingCloseDoorFault.tscn @@ -12,7 +12,7 @@ [node name="TrainingCloseDoorFault" type="Node"] script = ExtResource("1_iggb0") -trainingName = "上行头等亮,关门故障" +trainingName = "站台单档滑动门关门故障处置" [node name="TrainingDescDialog" parent="." instance=ExtResource("1_efkp6")] sceneDesc = "上行门头灯亮关门故障" @@ -34,8 +34,12 @@ visible = false [node name="StepTip" parent="." instance=ExtResource("9_3cm1b")] +[node name="StepTimer" type="Timer" parent="."] +one_shot = true + [connection signal="StartTraining" from="TrainingDescDialog" to="." method="_on_training_desc_dialog_start_training"] [connection signal="currentClickCheckSignal" from="total" to="." method="_on_total_current_click_check_signal"] [connection signal="screenDoorCloseConfirmSignal" from="total" to="." method="_on_total_screen_door_close_confirm_signal"] +[connection signal="speech_recognition_successed" from="VoiceCommunication" to="." method="_on_voice_communication_speech_recognition_successed"] [connection signal="two_cancel" from="ConfirmDialog" to="." method="_on_confirm_dialog_two_cancel"] [connection signal="two_confirm" from="ConfirmDialog" to="." method="_on_confirm_dialog_two_confirm"]