| | |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using System; |
| | | using System.Linq; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Bro.UI.Device.Winform |
| | |
| | | |
| | | public IDevice Device { get; set; } |
| | | |
| | | public MotionCardOperationConfigBase MotionCardOperationConfig { get; set; } |
| | | public MovingOption MotionCardMovingOption { get; set; } = new MovingOption(); |
| | | |
| | | /// <summary> |
| | | /// 当前板卡实例 |
| | |
| | | InitializeComponent(); |
| | | |
| | | Device = device; |
| | | MotionCardOperationConfig = new MotionCardOperationConfigBase(); |
| | | |
| | | InitialLayout(); |
| | | } |
| | | |
| | | MovingOption movingConfig = null; |
| | | |
| | | #region ILogoutput |
| | | public Action<LogMsg> OnLogMsgOutput { get; set; } |
| | | |
| | | public void LogDisplay(LogMsg msg) |
| | | private void InitialLayout() |
| | | { |
| | | } |
| | | #endregion |
| | | foreach (var axisConfig in MotionCard.IConfig.AxisSettings.FindAll(u => u.IsAxisEnabled)) |
| | | { |
| | | CtrlMotionCardAxisOperation axisOperation = new CtrlMotionCardAxisOperation(Device, axisConfig.AxisIndex, axisConfig.AxisName); |
| | | //axisOperation.Dock = DockStyle.Fill; |
| | | flowLayoutPanel1.Controls.Add(axisOperation); |
| | | |
| | | } |
| | | |
| | | private void RadioButton_CheckedChanged(object sender, EventArgs e) |
| | | { |
| | | //加载对应运动的 movingConfig |
| | | //if (radioP2P.Checked) |
| | | //{ |
| | | // movingConfig = MotionCardOperationConfig.MovingOps.FirstOrDefault(u => u.MoveMode == EnumHelper.MotorMoveMode.Normal); |
| | | //} |
| | | //else if (radioJog.Checked) |
| | | //{ |
| | | // movingConfig = MotionCardOperationConfig.MovingOps.FirstOrDefault(u => u.MoveMode == EnumHelper.MotorMoveMode.Jog); |
| | | //} |
| | | //else if (radioGoHome.Checked) |
| | | //{ |
| | | // movingConfig = MotionCardOperationConfig.MovingOps.FirstOrDefault(u => u.MoveMode == EnumHelper.MotorMoveMode.FindOri); |
| | | //} |
| | | |
| | | propGrid.SelectedObject = movingConfig; |
| | | MotionCardMovingOption.SetAxisSetting(MotionCard.IConfig.AxisSettings); |
| | | propGrid.SelectedObject = MotionCardMovingOption; |
| | | } |
| | | |
| | | private void buttonClearStatus_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | MotionCard.ClearStatus(1, MotionCard.IConfig.AxisSettings.FindAll(u => u.IsAxisEnabled).Count); |
| | | } |
| | | |
| | | private void buttonServoEnable_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | int sts = MotionCard.GetAxisStatus(MotionCardMovingOption.AxisIndex); |
| | | if ((sts & 0x200) == 0)//关闭状态 |
| | | { |
| | | MotionCard.AxisOnAsync(MotionCardMovingOption.AxisIndex); |
| | | buttonServoEnable.Text = "伺服已开启"; |
| | | } |
| | | else |
| | | { |
| | | MotionCard.AxisOffAsync(MotionCardMovingOption.AxisIndex); |
| | | buttonServoEnable.Text = "伺服已关闭"; |
| | | } |
| | | } |
| | | |
| | | private void buttonPositionReset_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | var res = MotionCard.PositionReset(MotionCardMovingOption.AxisIndex, 1); |
| | | } |
| | | |
| | | private void btnStart_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | MotionCard.SingleAxisMoving(MotionCardMovingOption).Start(); |
| | | } |
| | | |
| | | private void buttonSmoothStop_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | MotionCard.MoveStop(MotionCardMovingOption.AxisIndex, 0); |
| | | } |
| | | |
| | | private void buttonEmergencyStop_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | MotionCard.MoveStop(MotionCardMovingOption.AxisIndex, 1); |
| | | } |
| | | |
| | | } |