|
@@ -2,6 +2,7 @@
|
|
|
using AwInitilizer.Model;
|
|
|
using CsuWebApiLib;
|
|
|
using CsuWebApiLib.Model;
|
|
|
+using FluentFTP;
|
|
|
using InitializerModel;
|
|
|
using Newtonsoft.Json;
|
|
|
using System;
|
|
@@ -14,6 +15,7 @@ using System.Security.AccessControl;
|
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
+using System.Web;
|
|
|
using System.Windows;
|
|
|
|
|
|
namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
@@ -26,6 +28,7 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
FirstButtonCheckFail,
|
|
|
SecondButtonCheckFail,
|
|
|
EmergencyButtonCheckFail,
|
|
|
+ ThirdButtonCheckFail
|
|
|
}
|
|
|
|
|
|
public enum LogEvent
|
|
@@ -50,6 +53,11 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
};
|
|
|
|
|
|
private HintDialog hintDialog = new HintDialog();
|
|
|
+ private bool isBtn1NeedTest = false;
|
|
|
+ private bool isBtn2NeedTest = false;
|
|
|
+ private bool isBtn3NeedTest = false;
|
|
|
+ private bool isEmergencyNeedTest = false;
|
|
|
+
|
|
|
public ButtonStatusCheckPorcedure() : base()
|
|
|
{
|
|
|
Name = "Button Press Test";
|
|
@@ -69,12 +77,7 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //await PressBtnCheck(0);
|
|
|
- //DismisDialog();
|
|
|
- //await PressBtnCheck(1);
|
|
|
- //DismisDialog();
|
|
|
- //await PressBtnCheck(2);
|
|
|
- //DismisDialog();
|
|
|
+ UpdateButtonNeedTestVar();
|
|
|
|
|
|
var response = await GetButtonStatus();
|
|
|
if (response == null)
|
|
@@ -92,36 +95,41 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
//Logger.Print("Button press Status check Start");
|
|
|
//MessageBox.Show("Press Button1,Button2,EmergencyButton in order\neach press continuous 2 secondes\nPress Ok to start", "Starting Button test");
|
|
|
|
|
|
- //Button1,Button2,EmergencyButton in order 0,1,2
|
|
|
- for (int testType = 0; testType < 3; testType++)
|
|
|
+ //Button1,Button2,Button3,EmergencyButton in order 0,1,2,3
|
|
|
+ for (int testType = 0; testType < 4; testType++)
|
|
|
{
|
|
|
- if ((testType == 1 || testType == 0) &&
|
|
|
- UpdateData.ButtonTestMode == ButtonTestModeType.SkipNormalButton)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (testType == 2 &&
|
|
|
- UpdateData.ButtonTestMode == ButtonTestModeType.SkipEmergencyButton)
|
|
|
- {
|
|
|
- continue;
|
|
|
+ if ((!isBtn1NeedTest && testType == 0) ||
|
|
|
+ (!isBtn2NeedTest && testType == 1) ||
|
|
|
+ (!isBtn3NeedTest && testType == 2) ||
|
|
|
+ (!isEmergencyNeedTest && testType == 3))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
var checkResult = await PressBtnCheck(testType);
|
|
|
if (!checkResult)
|
|
|
{
|
|
|
- if (testType == 0)
|
|
|
- Error = ErrorType.FirstButtonCheckFail;
|
|
|
- else if (testType == 1)
|
|
|
- Error = ErrorType.SecondButtonCheckFail;
|
|
|
- else if (testType == 2)
|
|
|
- Error = ErrorType.EmergencyButtonCheckFail;
|
|
|
+ switch (testType)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ Error = ErrorType.FirstButtonCheckFail;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ Error = ErrorType.SecondButtonCheckFail;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ Error = ErrorType.ThirdButtonCheckFail;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ Error = ErrorType.EmergencyButtonCheckFail;
|
|
|
+ break;
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
private async Task<bool> CheckUnpressAllBtn()
|
|
|
{
|
|
|
ShowDialog(
|
|
@@ -139,56 +147,57 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
|
|
|
//LogWriter.Report(LogEvent.UnpressButtonTest, string.Format("{0}{1}{2}", status.Button1, status.Button2, status.EmergencyButton));
|
|
|
|
|
|
- LogWriter.Log(string.Format("Button unpress test result : {0}{1}{2}, Expect:000",
|
|
|
- status.Button1, status.Button2, status.EmergencyButton));
|
|
|
+ LogWriter.Log(string.Format("Button unpress test result : {0}/{1}/{2}/{3}, Expect:0000",
|
|
|
+ status.Button1, status.Button2, status.Button3, status.EmergencyButton));
|
|
|
|
|
|
LogWriter.Log(
|
|
|
- string.Format("Button1:{0},Button2:{1},EmgerncyButton:{2}",
|
|
|
+ string.Format("Button1:{0},Button2:{1},Button3:{2},EmgerncyButton:{3}",
|
|
|
GetBtnStatusString(status.Button1),
|
|
|
GetBtnStatusString(status.Button2),
|
|
|
- GetBtnStatusString(status.EmergencyButton)));
|
|
|
+ GetBtnStatusString(status.Button3),
|
|
|
+ GetBtnStatusString(status.EmergencyButton)
|
|
|
+ ));
|
|
|
|
|
|
bool isAllMatched = true;
|
|
|
if (status != null)
|
|
|
{
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipNormalButton)
|
|
|
+ if (isBtn1NeedTest && status.Button1 != 0)
|
|
|
{
|
|
|
- if (status.Button1 != 0)
|
|
|
- {
|
|
|
- Error = ErrorType.FirstButtonCheckFail;
|
|
|
- LogWriter.Log("Button1 status ERROR, unpress is expected", isError: true);
|
|
|
- //Logger.Print("Button1 status ERROR, unpress is expected", isError: true);
|
|
|
- isAllMatched = false;
|
|
|
- }
|
|
|
- if (status.Button2 != 0)
|
|
|
- {
|
|
|
- Error = ErrorType.SecondButtonCheckFail;
|
|
|
- LogWriter.Log("Button2 status ERROR, unpress is expected", isError: true);
|
|
|
- //Logger.Print("Button2 status ERROR, unpress is expected", isError: true);
|
|
|
- isAllMatched = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipEmergencyButton)
|
|
|
+ Error = ErrorType.FirstButtonCheckFail;
|
|
|
+ LogWriter.Log("Button1 status ERROR, unpress is expected", isError: true);
|
|
|
+ isAllMatched = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBtn2NeedTest && status.Button2 != 0)
|
|
|
{
|
|
|
- if (status.EmergencyButton != 0)
|
|
|
- {
|
|
|
- Error = ErrorType.EmergencyButtonCheckFail;
|
|
|
- LogWriter.Log("EmergencyButton status ERROR, unpress is expected", isError: true);
|
|
|
- //Logger.Print("EmergencyButton status ERROR, unpress is expected", isError: true);
|
|
|
- isAllMatched = false;
|
|
|
- }
|
|
|
+ Error = ErrorType.SecondButtonCheckFail;
|
|
|
+ LogWriter.Log("Button2 status ERROR, unpress is expected", isError: true);
|
|
|
+ isAllMatched = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBtn3NeedTest && status.Button3 != 0)
|
|
|
+ {
|
|
|
+ Error = ErrorType.ThirdButtonCheckFail;
|
|
|
+ LogWriter.Log("Button3 status ERROR, unpress is expected", isError: true);
|
|
|
+ isAllMatched = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isEmergencyNeedTest && status.EmergencyButton != 0)
|
|
|
+ {
|
|
|
+ Error = ErrorType.EmergencyButtonCheckFail;
|
|
|
+ LogWriter.Log("EmergencyButton status ERROR, unpress is expected", isError: true);
|
|
|
+ isAllMatched = false;
|
|
|
}
|
|
|
|
|
|
if (isAllMatched)
|
|
|
{
|
|
|
LogWriter.Log("Unpress Check passed");
|
|
|
- LogWriter.Report(LogEvent.UnpressButtonTest, string.Format("{0}{1}{2}", status.Button1, status.Button2, status.EmergencyButton));
|
|
|
+ LogWriter.Report(LogEvent.UnpressButtonTest, string.Format("{0}{1}{2}{3}", status.Button1, status.Button2, status.Button3, status.EmergencyButton));
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LogWriter.Report(LogEvent.UnpressButtonTest, string.Format("{0}{1}{2}", status.Button1, status.Button2, status.EmergencyButton), isError: true);
|
|
|
+ LogWriter.Report(LogEvent.UnpressButtonTest, string.Format("{0}{1}{2}{3}", status.Button1, status.Button2, status.Button3, status.EmergencyButton), isError: true);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -206,7 +215,7 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
string btn, btnLang, imgUrl;
|
|
|
(btn, btnLang, imgUrl) = GetBtnParam(btnInt);
|
|
|
|
|
|
- if (btnInt == 2)
|
|
|
+ if (btnInt == 3)
|
|
|
{
|
|
|
ShowEmergencyBtnPressRequestDialog(imgUrl);
|
|
|
}
|
|
@@ -224,15 +233,17 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
//LogWriter.Report($"{btn}PressTest", string.Format("{0}{1}{2}", btnStatus.Button1, btnStatus.Button2, btnStatus.EmergencyButton));
|
|
|
LogWriter.Log($"Press check stage {btn} result:");
|
|
|
LogWriter.Log(
|
|
|
- string.Format("Button1:{0},Button2:{1},EmgerncyButton:{2}",
|
|
|
+ string.Format("Button1:{0},Button2:{1},Button3:{2},EmgerncyButton:{3}",
|
|
|
GetBtnStatusString(btnStatus.Button1),
|
|
|
GetBtnStatusString(btnStatus.Button2),
|
|
|
- GetBtnStatusString(btnStatus.EmergencyButton)));
|
|
|
+ GetBtnStatusString(btnStatus.Button3),
|
|
|
+ GetBtnStatusString(btnStatus.EmergencyButton)
|
|
|
+ ));
|
|
|
|
|
|
DismisDialog();
|
|
|
- var btnStatusIsMatchedRequred = CheckBtnStatus(btnInt, btnStatus);
|
|
|
- LogWriter.Report($"{btn}PressTest", string.Format("{0}{1}{2}", btnStatus.Button1, btnStatus.Button2, btnStatus.EmergencyButton), isError: !btnStatusIsMatchedRequred);
|
|
|
- return btnStatusIsMatchedRequred;
|
|
|
+ var btnStatusIsMatchedRequired = CheckOneBtnPressStatus(btnInt, btnStatus);
|
|
|
+ LogWriter.Report($"{btn}PressTest", string.Format("{0}{1}{2}{3}", btnStatus.Button1, btnStatus.Button2, btnStatus.Button3, btnStatus.EmergencyButton), isError: !btnStatusIsMatchedRequired);
|
|
|
+ return btnStatusIsMatchedRequired;
|
|
|
}
|
|
|
|
|
|
private async Task<ButtonStatus> WaitAndtGetPressBtn()
|
|
@@ -249,54 +260,44 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- var isAnyButtonIsPressed = false;
|
|
|
-
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipNormalButton)
|
|
|
+ if (IsAnyButtonPressed(pressStatus))
|
|
|
{
|
|
|
- if (pressStatus.Button1 != 0 || pressStatus.Button2 != 0 )
|
|
|
- {
|
|
|
- isAnyButtonIsPressed = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipEmergencyButton)
|
|
|
- {
|
|
|
- if (pressStatus.EmergencyButton != 0)
|
|
|
- {
|
|
|
- isAnyButtonIsPressed = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //if any button is pressed
|
|
|
- //if (pressStatus.Button1 != 0 ||
|
|
|
- // pressStatus.Button2 != 0 ||
|
|
|
- // pressStatus.EmergencyButton != 0)
|
|
|
- if (isAnyButtonIsPressed)
|
|
|
- {
|
|
|
+
|
|
|
await WaitAllBtnRelease();
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
return pressStatus;
|
|
|
}
|
|
|
|
|
|
- private bool CheckBtnStatus(int btnInt, ButtonStatus buttonStatus)
|
|
|
+ private bool CheckOneBtnPressStatus(int btnInt, ButtonStatus buttonStatus)
|
|
|
{
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipNormalButton)
|
|
|
+ if (isBtn1NeedTest &&
|
|
|
+ (buttonStatus.Button1 is null || buttonStatus.Button1 == (btnInt == 0 ? 0 : 1))
|
|
|
+ )
|
|
|
{
|
|
|
- if (buttonStatus.Button1 == (btnInt == 0 ? 0 : 1) ||
|
|
|
- buttonStatus.Button2 == (btnInt == 1 ? 0 : 1))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipEmergencyButton)
|
|
|
+ if (isBtn2NeedTest &&
|
|
|
+ (buttonStatus.Button2 is null || buttonStatus.Button2 == (btnInt == 1 ? 0 : 1))
|
|
|
+ )
|
|
|
{
|
|
|
- if (buttonStatus.EmergencyButton == (btnInt == 2 ? 0 : 1))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBtn3NeedTest &&
|
|
|
+ (buttonStatus.Button3 is null || buttonStatus.Button3 == (btnInt == 2 ? 0 : 1))
|
|
|
+ )
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isEmergencyNeedTest &&
|
|
|
+ (buttonStatus.EmergencyButton is null || buttonStatus.EmergencyButton == (btnInt == 3 ? 0 : 1))
|
|
|
+ )
|
|
|
+ {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -323,17 +324,22 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
string btn, btnLang, imgUrl;
|
|
|
switch (btnInt)
|
|
|
{
|
|
|
- case 1:
|
|
|
- btn = "Green Button";
|
|
|
- btnLang = Resx.AppResources.BtnPressGreenBtn;
|
|
|
- imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Green.png";
|
|
|
- break;
|
|
|
case 0:
|
|
|
btn = "Blue Button";
|
|
|
btnLang = Resx.AppResources.BtnPressBlueBtn;
|
|
|
imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Blue.png";
|
|
|
break;
|
|
|
+ case 1:
|
|
|
+ btn = "Green Button";
|
|
|
+ btnLang = Resx.AppResources.BtnPressGreenBtn;
|
|
|
+ imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Green.png";
|
|
|
+ break;
|
|
|
case 2:
|
|
|
+ btn = "Third Button";
|
|
|
+ btnLang = Resx.AppResources.BtnPressThirdBtn;
|
|
|
+ imgUrl = "";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
btn = "EmergencyButton";
|
|
|
btnLang = Resx.AppResources.BtnPressEmergencyBtn;
|
|
|
imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Emergency.png";
|
|
@@ -349,41 +355,20 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
|
|
|
private async Task WaitAllBtnRelease()
|
|
|
{
|
|
|
- ButtonStatus status;
|
|
|
+ ButtonStatus pressStatus;
|
|
|
//wait release
|
|
|
for (var releaseCnt = 0; releaseCnt < 20; releaseCnt++)
|
|
|
{
|
|
|
await Task.Delay(500);
|
|
|
- status = await GetButtonStatus();
|
|
|
- if (status == null)
|
|
|
+ pressStatus = await GetButtonStatus();
|
|
|
+ if (pressStatus == null)
|
|
|
{
|
|
|
//InfoLog += "Get Butoon state failed\n";
|
|
|
//Logger.Print("Get Butoon state failed");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- bool isAllBtnReleased = true;
|
|
|
-
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipNormalButton)
|
|
|
- {
|
|
|
- if (status.Button1 != 0 || status.Button2 != 0)
|
|
|
- {
|
|
|
- isAllBtnReleased = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (UpdateData.ButtonTestMode != ButtonTestModeType.SkipEmergencyButton)
|
|
|
- {
|
|
|
- if (status.EmergencyButton != 0)
|
|
|
- {
|
|
|
- isAllBtnReleased = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //if (status.Button1 == 0 &&
|
|
|
- // status.Button2 == 0 &&
|
|
|
- // status.EmergencyButton == 0)
|
|
|
- if (isAllBtnReleased)
|
|
|
+ if (!IsAnyButtonPressed(pressStatus))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
@@ -411,14 +396,19 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private string GetBtnStatusString(int status)
|
|
|
+ private string GetBtnStatusString(int? status)
|
|
|
{
|
|
|
- if (status == 1)
|
|
|
- return "Pressed";
|
|
|
- else if (status == 0)
|
|
|
- return "Unpressed";
|
|
|
- else
|
|
|
- return status.ToString();
|
|
|
+ switch (status)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ return "Pressed";
|
|
|
+ case 0:
|
|
|
+ return "Unpressed";
|
|
|
+ case null:
|
|
|
+ return "Unknown";
|
|
|
+ default:
|
|
|
+ return status.ToString();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void ShowDialog(string msg, string title, string btnText, string imgUrl, bool cancelAble)
|
|
@@ -448,6 +438,47 @@ namespace AwInitilizer.Procedure.ButtonStatusCheck
|
|
|
if (hintDialog == null)
|
|
|
return;
|
|
|
hintDialog.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UpdateButtonNeedTestVar()
|
|
|
+ {
|
|
|
+ isBtn1NeedTest = false;
|
|
|
+ isBtn2NeedTest = false;
|
|
|
+ isBtn3NeedTest = false;
|
|
|
+ isEmergencyNeedTest = false;
|
|
|
+
|
|
|
+ switch (UpdateData.ButtonTestMode)
|
|
|
+ {
|
|
|
+ case ButtonTestModeType.TwoButtonsWithEmergencyButton:
|
|
|
+ isBtn1NeedTest = true;
|
|
|
+ isBtn2NeedTest = true;
|
|
|
+ isEmergencyNeedTest= true;
|
|
|
+ break;
|
|
|
+ case ButtonTestModeType.SkipButtonTest:
|
|
|
+ break;
|
|
|
+ case ButtonTestModeType.EmergencyButtonOnly:
|
|
|
+ isEmergencyNeedTest = true;
|
|
|
+ break;
|
|
|
+ case ButtonTestModeType.TwoButtons:
|
|
|
+ isBtn1NeedTest = true;
|
|
|
+ isBtn2NeedTest = true;
|
|
|
+ break;
|
|
|
+ case ButtonTestModeType.ThreeButtonsWithEmergencyButton:
|
|
|
+ isBtn1NeedTest = true;
|
|
|
+ isBtn2NeedTest = true;
|
|
|
+ isBtn3NeedTest= true;
|
|
|
+ isEmergencyNeedTest = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool IsAnyButtonPressed(ButtonStatus pressStatus)
|
|
|
+ {
|
|
|
+ return
|
|
|
+ (isBtn1NeedTest && pressStatus.Button1 == 1) ||
|
|
|
+ (isBtn2NeedTest && pressStatus.Button2 == 1) ||
|
|
|
+ (isEmergencyNeedTest && pressStatus.EmergencyButton == 1) ||
|
|
|
+ (isBtn3NeedTest && pressStatus.Button3 == 1);
|
|
|
}
|
|
|
}
|
|
|
}
|