You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
6.7 KiB
C#

11 months ago
using Rs.Camera;
using Rs.Controls;
using Rs.Framework;
using Rs.Motion;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Flow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Rs.MotionPlat.SysConfig
{
public partial class CommonConfig : BaseForm
{
IniHelper ini = new IniHelper(Path.Combine(GlobalVar.CurRecipe, "default.ini"));
public CommonConfig()
{
InitializeComponent();
}
private void CommonConfig_Load(object sender, EventArgs e)
{
List<string> cameras = HikCamera.Instance.GetCameras();
foreach (string cam in cameras)
{
cboxUpCameraName.Items.Add(cam);
cboxDownLocationCameraName.Items.Add(cam);
}
foreach (var con in groupBox1.Controls)
{
if (con is TextBox)
{
TextBox txt = (TextBox)con;
txt.Text = SysConfigParam.GetValue<string>(txt.Name.Replace("txt", ""));
}
else if (con is TrackBar)
{
TrackBar tb = (TrackBar)con;
tb.Value = SysConfigParam.GetValue<int>(tb.Name.Replace("tbar", ""));
}
else if (con is CheckBox)
{
CheckBox cbox = (CheckBox)con;
cbox.Checked = SysConfigParam.GetValue<bool>(cbox.Name.Replace("cbox", ""));
}
else if (con is ComboBox)
{
ComboBox cbox = (ComboBox)con;
cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
}
}
foreach (var con in groupBox3.Controls)
{
if (con is ComboBox)
{
ComboBox cbox = (ComboBox)con;
cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
}
}
foreach (var con in groupBox2.Controls)
{
if (con is TextBox)
{
TextBox txt = (TextBox)con;
txt.Text = SysConfigParam.GetValue<string>(txt.Name.Replace("txt", ""));
}
else if (con is CheckBox)
{
CheckBox cbox = (CheckBox)con;
cbox.Checked = SysConfigParam.GetValue<bool>(cbox.Name.Replace("cbox", ""));
}
}
foreach (var con in groupBox3.Controls)
{
if (con is ComboBox)
{
ComboBox cbox = (ComboBox)con;
cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
}
}
PositionHelper.BindPosition(groupBox9, "int");
PositionHelper.BindPosition(groupBox10, "int");
PositionHelper.BindPosition(groupBox8, "int");
txtQifuValue.Text = SysConfigParam.GetValue<string>(txtQifuValue.Name.Replace("txt", ""));
}
private void btnSaveSpeedParam_Click(object sender, EventArgs e)
{
QifuManager.Instance.Write(float.Parse(txtQifuValue.Text));
SysConfigParam.Update(txtQifuValue.Name.Replace("txt", ""), txtQifuValue.Text);
foreach (var con in groupBox1.Controls)
{
if(con is TextBox)
{
TextBox txt=(TextBox)con;
SysConfigParam.Update(txt.Name.Replace("txt",""), txt.Text);
}
else if(con is TrackBar)
{
TrackBar tb= (TrackBar)con;
SysConfigParam.Update(tb.Name.Replace("tbar",""), tb.Value.ToString());
}
else if(con is CheckBox)
{
CheckBox cbox= (CheckBox)con;
SysConfigParam.Update(cbox.Name.Replace("cbox",""), cbox.Checked.ToString());
}
else if(con is ComboBox)
{
ComboBox cbox= (ComboBox)con;
if(cbox.SelectedItem!=null)
{
SysConfigParam.Update(cbox.Name.Replace("cbox", ""), cbox.SelectedItem.ToString());
}
}
}
foreach (var con in groupBox2.Controls)
{
if (con is TextBox)
{
TextBox txt = (TextBox)con;
SysConfigParam.Update(txt.Name.Replace("txt", ""), txt.Text);
}
else if (con is CheckBox)
{
CheckBox cbox = (CheckBox)con;
SysConfigParam.Update(cbox.Name.Replace("cbox", ""), cbox.Checked.ToString());
}
}
Msg.ShowInfo("Save success!");
}
private void tbarWholeSpeed_ValueChanged(object sender, EventArgs e)
{
lblWholeSpeed.Text = $"{tbarWholeSpeed.Value}%";
}
private void tbarFlyCameraSpeed_ValueChanged(object sender, EventArgs e)
{
lblFlyCameraSpeed.Text = $"{tbarFlyCameraSpeed.Value}%";
}
private void tbarTakeTraySpeed_ValueChanged(object sender, EventArgs e)
{
lblTakeTraySpeed.Text = $"{tbarTakeTraySpeed.Value}%";
}
private void tbarPressLowSpeed_ValueChanged(object sender, EventArgs e)
{
lblPressLowSpeed.Text = $"{tbarPressLowSpeed.Value}%";
}
public void txtSysParam_KeyUp(object sender, KeyEventArgs e)
{
UpdateSysParam((TextBox)sender);
}
private void txtQifuValue_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TextBox txt = (TextBox)sender;
string value = txt.Text;
QifuManager.Instance.Write(float.Parse(value));
SysConfigParam.Update(txt.Name.Replace("txt", ""), value);
}
}
private void tbarStockBeltSpeed_ValueChanged(object sender, EventArgs e)
{
lblStockBeltSpeed.Text = $"{tbarStockBeltSpeed.Value}%";
}
private void tbarTakeTrayFromNg2InputSpeed_ValueChanged(object sender, EventArgs e)
{
lblTakeTrayFromNg2InputSpeed.Text = $"{tbarTakeTrayFromNg2InputSpeed.Value}%";
}
}
}