330 lines
18 KiB
C#
330 lines
18 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using SmartX;
|
|
using ITC81DB_0H.Forms;
|
|
using ITC81DB_2H.Datastore;
|
|
|
|
namespace ITC81DB_0H.Controls
|
|
{
|
|
public partial class ControlBottomSystem : UserControl
|
|
{
|
|
#region Field
|
|
private FormMenu m_ParentForm;
|
|
|
|
private Define.E_MenuBottomSystem CurrentMenu;
|
|
private Collection<SmartButton> CollectionButtonMenu;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public ControlBottomSystem(FormMenu parent)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.ParentForm = parent;
|
|
|
|
this.InitializeDesign();
|
|
this.DefaultSetting();
|
|
}
|
|
#endregion
|
|
|
|
#region Property
|
|
public FormMenu ParentForm
|
|
{
|
|
get { return this.m_ParentForm; }
|
|
private set { this.m_ParentForm = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Method
|
|
public void InitializeDesign()
|
|
{
|
|
}
|
|
private void DefaultSetting()
|
|
{
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.Help;
|
|
|
|
this.CollectionButtonMenu = new Collection<SmartButton>();
|
|
this.CollectionButtonMenu.Clear();
|
|
this.CollectionButtonMenu.Add(this.buttonHelp);
|
|
this.CollectionButtonMenu.Add(this.buttonCalibration);
|
|
this.CollectionButtonMenu.Add(this.buttonJudgmentSetting);
|
|
this.CollectionButtonMenu.Add(this.buttonSorter);
|
|
this.CollectionButtonMenu.Add(this.buttonAutoZero);
|
|
this.CollectionButtonMenu.Add(this.buttonIOTest);
|
|
this.CollectionButtonMenu.Add(this.buttonExternalOutput);
|
|
this.CollectionButtonMenu.Add(this.buttonBLDCMotorSetting);
|
|
}
|
|
|
|
public void CurrentControlEnable(bool enable)
|
|
{
|
|
foreach (SmartButton button in this.CollectionButtonMenu)
|
|
button.Enabled = enable;
|
|
}
|
|
|
|
public void UpdateMenuDisplay(SystemStatus status)
|
|
{
|
|
switch (status.CurrentUser.Group)
|
|
{
|
|
case Define.E_UserGroup.Level1:
|
|
this.buttonCalibration.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemCalibration;
|
|
this.buttonJudgmentSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemJudgmentSetting;
|
|
this.buttonSorter.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemSorterSetting;
|
|
this.buttonAutoZero.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemAutoZero;
|
|
this.buttonIOTest.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemIOTest;
|
|
this.buttonExternalOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemExternalOutput;
|
|
break;
|
|
case Define.E_UserGroup.Level2:
|
|
this.buttonCalibration.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemCalibration;
|
|
this.buttonJudgmentSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemJudgmentSetting;
|
|
this.buttonSorter.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemSorterSetting;
|
|
this.buttonAutoZero.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemAutoZero;
|
|
this.buttonIOTest.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemIOTest;
|
|
this.buttonExternalOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemExternalOutput;
|
|
break;
|
|
case Define.E_UserGroup.Level3:
|
|
this.buttonCalibration.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemCalibration;
|
|
this.buttonJudgmentSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemJudgmentSetting;
|
|
this.buttonSorter.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemSorterSetting;
|
|
this.buttonAutoZero.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemAutoZero;
|
|
this.buttonIOTest.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemIOTest;
|
|
this.buttonExternalOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemExternalOutput;
|
|
break;
|
|
case Define.E_UserGroup.Admin:
|
|
case Define.E_UserGroup.Developer:
|
|
this.buttonCalibration.Enabled = true;
|
|
this.buttonJudgmentSetting.Enabled = true;
|
|
this.buttonSorter.Enabled = true;
|
|
this.buttonAutoZero.Enabled = true;
|
|
this.buttonIOTest.Enabled = true;
|
|
this.buttonExternalOutput.Enabled = true;
|
|
break;
|
|
case Define.E_UserGroup.NotLogin:
|
|
this.buttonCalibration.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemCalibration;
|
|
this.buttonJudgmentSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemJudgmentSetting;
|
|
this.buttonSorter.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemSorterSetting;
|
|
this.buttonAutoZero.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemAutoZero;
|
|
this.buttonIOTest.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemIOTest;
|
|
this.buttonExternalOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemExternalOutput;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void UpdateDisplayMenuButton(Define.E_MenuBottomSystem menu)
|
|
{
|
|
switch (menu)
|
|
{
|
|
case Define.E_MenuBottomSystem.Calibration:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonCalibration.ButtonDown();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.ExternalOutput:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonExternalOutput.ButtonDown();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.Help:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonHelp.ButtonDown();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.IOTest:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonIOTest.ButtonDown();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.JudgmentSetting:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonJudgmentSetting.ButtonDown();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.SorterSetting:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonSorter.ButtonDown();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.AutoZero:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonAutoZero.ButtonDown();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomSystem.BLDCMotorSetting:
|
|
if (this.buttonAutoZero.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonAutoZero.ButtonUp();
|
|
if (this.buttonCalibration.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonCalibration.ButtonUp();
|
|
if (this.buttonExternalOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonExternalOutput.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonIOTest.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonIOTest.ButtonUp();
|
|
if (this.buttonJudgmentSetting.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
if (this.buttonSorter.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSorter.ButtonUp();
|
|
if (this.buttonBLDCMotorSetting.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonBLDCMotorSetting.ButtonDown();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void DisplayRefresh(SystemStatus status)
|
|
{
|
|
bool value;
|
|
|
|
value = this.ParentForm.ParentForm.SystemConfig1.IsBLDCON;
|
|
if (value == false)
|
|
this.buttonBLDCMotorSetting.Visible = false;
|
|
else
|
|
this.buttonBLDCMotorSetting.Visible = true;
|
|
|
|
this.buttonHelp.ButtonDown();
|
|
this.buttonCalibration.ButtonUp();
|
|
this.buttonJudgmentSetting.ButtonUp();
|
|
this.buttonAutoZero.ButtonUp();
|
|
this.buttonIOTest.ButtonUp();
|
|
this.buttonExternalOutput.ButtonUp();
|
|
this.buttonBLDCMotorSetting.ButtonUp();
|
|
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.Help;
|
|
this.ParentForm.DisplayBottomSystem(this.CurrentMenu);
|
|
}
|
|
#endregion
|
|
|
|
#region Event Handler
|
|
private void buttonMenu_Click(object sender, EventArgs e)
|
|
{
|
|
SmartButton button = sender as SmartButton;
|
|
|
|
if (button == null)
|
|
return;
|
|
|
|
if (button == this.buttonHelp)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.Help;
|
|
else if (button == this.buttonCalibration)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.Calibration;
|
|
else if (button == this.buttonJudgmentSetting)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.JudgmentSetting;
|
|
else if (button == this.buttonSorter)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.SorterSetting;
|
|
else if (button == this.buttonAutoZero)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.AutoZero;
|
|
else if (button == this.buttonExternalOutput)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.ExternalOutput;
|
|
else if (button == this.buttonIOTest)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.IOTest;
|
|
else if (button == this.buttonBLDCMotorSetting)
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.BLDCMotorSetting;
|
|
else
|
|
this.CurrentMenu = Define.E_MenuBottomSystem.Help;
|
|
|
|
this.ParentForm.DisplayBottomSystem(this.CurrentMenu);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|