master
杨威 1 month ago
parent 3ebe322e4d
commit eae3da9152

@ -29,27 +29,30 @@
private void InitializeComponent()
{
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.RfidNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Green = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Yellow = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Red = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSave = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.SetServerIPButton = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.ServerPortTextbox = new System.Windows.Forms.TextBox();
this.ServerIPTextbox = new System.Windows.Forms.TextBox();
this.RfidNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Green = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Yellow = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Red = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label3 = new System.Windows.Forms.Label();
this.Groupbox3 = new System.Windows.Forms.GroupBox();
this.AlarmTimeValueTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.SetAlarmTimeValueButton = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.AlarmTimeValueTextBox = new System.Windows.Forms.TextBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.txtCom = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.Groupbox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// dataGridView1
@ -61,33 +64,73 @@
this.Yellow,
this.Red});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 20);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView1.Location = new System.Drawing.Point(2, 16);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 62;
this.dataGridView1.RowTemplate.Height = 30;
this.dataGridView1.Size = new System.Drawing.Size(615, 657);
this.dataGridView1.Size = new System.Drawing.Size(462, 525);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// RfidNo
//
this.RfidNo.DataPropertyName = "RfidNo";
this.RfidNo.HeaderText = "Rfid";
this.RfidNo.MaxInputLength = 20;
this.RfidNo.MinimumWidth = 20;
this.RfidNo.Name = "RfidNo";
this.RfidNo.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.RfidNo.Width = 150;
//
// Green
//
this.Green.DataPropertyName = "Green";
this.Green.HeaderText = "绿灯";
this.Green.MaxInputLength = 2;
this.Green.MinimumWidth = 8;
this.Green.Name = "Green";
this.Green.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Green.Width = 80;
//
// Yellow
//
this.Yellow.DataPropertyName = "Yellow";
this.Yellow.HeaderText = "黄灯";
this.Yellow.MaxInputLength = 2;
this.Yellow.MinimumWidth = 8;
this.Yellow.Name = "Yellow";
this.Yellow.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Yellow.Width = 80;
//
// Red
//
this.Red.DataPropertyName = "Red";
this.Red.HeaderText = "红灯";
this.Red.MaxInputLength = 5;
this.Red.MinimumWidth = 8;
this.Red.Name = "Red";
this.Red.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Red.Width = 80;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dataGridView1);
this.groupBox1.Location = new System.Drawing.Point(24, 27);
this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBox1.Location = new System.Drawing.Point(18, 22);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBox1.Size = new System.Drawing.Size(621, 679);
this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Size = new System.Drawing.Size(466, 543);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "报警灯设置";
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(27, 723);
this.btnSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnSave.Location = new System.Drawing.Point(20, 578);
this.btnSave.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(163, 75);
this.btnSave.Size = new System.Drawing.Size(122, 60);
this.btnSave.TabIndex = 2;
this.btnSave.Text = "保存报警灯";
this.btnSave.UseVisualStyleBackColor = true;
@ -95,161 +138,155 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.SetServerIPButton);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.ServerPortTextbox);
this.groupBox2.Controls.Add(this.ServerIPTextbox);
this.groupBox2.Location = new System.Drawing.Point(651, 27);
this.groupBox2.Location = new System.Drawing.Point(488, 22);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(487, 65);
this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox2.Size = new System.Drawing.Size(365, 52);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "服务端IP设置";
//
// SetServerIPButton
//
this.SetServerIPButton.Location = new System.Drawing.Point(394, 24);
this.SetServerIPButton.Name = "SetServerIPButton";
this.SetServerIPButton.Size = new System.Drawing.Size(75, 25);
this.SetServerIPButton.TabIndex = 4;
this.SetServerIPButton.Text = "设置";
this.SetServerIPButton.UseVisualStyleBackColor = true;
this.SetServerIPButton.Click += new System.EventHandler(this.SetServerIPButton_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(223, 29);
this.label2.Location = new System.Drawing.Point(167, 23);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(87, 15);
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 3;
this.label2.Text = "ServerPort";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 29);
this.label1.Location = new System.Drawing.Point(4, 23);
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 15);
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 2;
this.label1.Text = "ServerIP";
//
// ServerPortTextbox
//
this.ServerPortTextbox.Location = new System.Drawing.Point(316, 24);
this.ServerPortTextbox.Location = new System.Drawing.Point(237, 19);
this.ServerPortTextbox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerPortTextbox.Name = "ServerPortTextbox";
this.ServerPortTextbox.Size = new System.Drawing.Size(63, 25);
this.ServerPortTextbox.Size = new System.Drawing.Size(48, 21);
this.ServerPortTextbox.TabIndex = 1;
this.ServerPortTextbox.Text = "6001";
//
// ServerIPTextbox
//
this.ServerIPTextbox.Location = new System.Drawing.Point(83, 24);
this.ServerIPTextbox.Location = new System.Drawing.Point(62, 19);
this.ServerIPTextbox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerIPTextbox.Name = "ServerIPTextbox";
this.ServerIPTextbox.Size = new System.Drawing.Size(134, 25);
this.ServerIPTextbox.Size = new System.Drawing.Size(102, 21);
this.ServerIPTextbox.TabIndex = 0;
this.ServerIPTextbox.Text = "192.168.0.101";
//
// RfidNo
//
this.RfidNo.DataPropertyName = "RfidNo";
this.RfidNo.HeaderText = "Rfid";
this.RfidNo.MaxInputLength = 20;
this.RfidNo.MinimumWidth = 20;
this.RfidNo.Name = "RfidNo";
this.RfidNo.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.RfidNo.Width = 150;
//
// Green
//
this.Green.DataPropertyName = "Green";
this.Green.HeaderText = "绿灯";
this.Green.MaxInputLength = 2;
this.Green.MinimumWidth = 8;
this.Green.Name = "Green";
this.Green.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Green.Width = 80;
//
// Yellow
//
this.Yellow.DataPropertyName = "Yellow";
this.Yellow.HeaderText = "黄灯";
this.Yellow.MaxInputLength = 2;
this.Yellow.MinimumWidth = 8;
this.Yellow.Name = "Yellow";
this.Yellow.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Yellow.Width = 80;
//
// Red
//
this.Red.DataPropertyName = "Red";
this.Red.HeaderText = "红灯";
this.Red.MaxInputLength = 5;
this.Red.MinimumWidth = 8;
this.Red.Name = "Red";
this.Red.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Red.Width = 80;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(169, 9);
this.label3.Location = new System.Drawing.Point(127, 7);
this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(423, 15);
this.label3.Size = new System.Drawing.Size(335, 12);
this.label3.TabIndex = 4;
this.label3.Text = "配置报警灯时,请按照:绿->黄->红 的顺序从大到小填写DO口";
//
// Groupbox3
//
this.Groupbox3.Controls.Add(this.SetAlarmTimeValueButton);
this.Groupbox3.Controls.Add(this.label4);
this.Groupbox3.Controls.Add(this.AlarmTimeValueTextBox);
this.Groupbox3.Location = new System.Drawing.Point(651, 98);
this.Groupbox3.Location = new System.Drawing.Point(488, 78);
this.Groupbox3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Groupbox3.Name = "Groupbox3";
this.Groupbox3.Size = new System.Drawing.Size(351, 96);
this.Groupbox3.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Groupbox3.Size = new System.Drawing.Size(365, 69);
this.Groupbox3.TabIndex = 5;
this.Groupbox3.TabStop = false;
this.Groupbox3.Text = "超时报警时间设置";
//
// AlarmTimeValueTextBox
// SetAlarmTimeValueButton
//
this.AlarmTimeValueTextBox.Location = new System.Drawing.Point(120, 37);
this.AlarmTimeValueTextBox.Name = "AlarmTimeValueTextBox";
this.AlarmTimeValueTextBox.Size = new System.Drawing.Size(100, 25);
this.AlarmTimeValueTextBox.TabIndex = 0;
this.AlarmTimeValueTextBox.Text = "10";
this.SetAlarmTimeValueButton.Location = new System.Drawing.Point(488, 267);
this.SetAlarmTimeValueButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.SetAlarmTimeValueButton.Name = "SetAlarmTimeValueButton";
this.SetAlarmTimeValueButton.Size = new System.Drawing.Size(71, 40);
this.SetAlarmTimeValueButton.TabIndex = 2;
this.SetAlarmTimeValueButton.Text = "设置";
this.SetAlarmTimeValueButton.UseVisualStyleBackColor = true;
this.SetAlarmTimeValueButton.Click += new System.EventHandler(this.SetAlarmTimeValueButton_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(15, 42);
this.label4.Location = new System.Drawing.Point(11, 34);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(97, 15);
this.label4.Size = new System.Drawing.Size(77, 12);
this.label4.TabIndex = 1;
this.label4.Text = "报警时间阈值";
//
// SetAlarmTimeValueButton
// AlarmTimeValueTextBox
//
this.SetAlarmTimeValueButton.Location = new System.Drawing.Point(237, 24);
this.SetAlarmTimeValueButton.Name = "SetAlarmTimeValueButton";
this.SetAlarmTimeValueButton.Size = new System.Drawing.Size(95, 50);
this.SetAlarmTimeValueButton.TabIndex = 2;
this.SetAlarmTimeValueButton.Text = "设置";
this.SetAlarmTimeValueButton.UseVisualStyleBackColor = true;
this.SetAlarmTimeValueButton.Click += new System.EventHandler(this.SetAlarmTimeValueButton_Click);
this.AlarmTimeValueTextBox.Location = new System.Drawing.Point(90, 30);
this.AlarmTimeValueTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.AlarmTimeValueTextBox.Name = "AlarmTimeValueTextBox";
this.AlarmTimeValueTextBox.Size = new System.Drawing.Size(76, 21);
this.AlarmTimeValueTextBox.TabIndex = 0;
this.AlarmTimeValueTextBox.Text = "10";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.txtCom);
this.groupBox4.Location = new System.Drawing.Point(488, 168);
this.groupBox4.Margin = new System.Windows.Forms.Padding(2);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Padding = new System.Windows.Forms.Padding(2);
this.groupBox4.Size = new System.Drawing.Size(365, 69);
this.groupBox4.TabIndex = 6;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "RFid串口名称";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(11, 34);
this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 12);
this.label5.TabIndex = 1;
this.label5.Text = "串口名称";
//
// txtCom
//
this.txtCom.Location = new System.Drawing.Point(90, 30);
this.txtCom.Margin = new System.Windows.Forms.Padding(2);
this.txtCom.Name = "txtCom";
this.txtCom.Size = new System.Drawing.Size(76, 21);
this.txtCom.TabIndex = 0;
this.txtCom.Text = "COM13";
//
// FrmSetting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1160, 819);
this.ClientSize = new System.Drawing.Size(1160, 1092);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.SetAlarmTimeValueButton);
this.Controls.Add(this.Groupbox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.groupBox1);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "FrmSetting";
this.Text = "参数设置";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
@ -258,6 +295,8 @@
this.groupBox2.PerformLayout();
this.Groupbox3.ResumeLayout(false);
this.Groupbox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -273,7 +312,6 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox ServerPortTextbox;
private System.Windows.Forms.TextBox ServerIPTextbox;
private System.Windows.Forms.Button SetServerIPButton;
private System.Windows.Forms.DataGridViewTextBoxColumn RfidNo;
private System.Windows.Forms.DataGridViewTextBoxColumn Green;
private System.Windows.Forms.DataGridViewTextBoxColumn Yellow;
@ -283,5 +321,8 @@
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox AlarmTimeValueTextBox;
private System.Windows.Forms.Button SetAlarmTimeValueButton;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtCom;
}
}

@ -42,6 +42,16 @@ namespace NDSD_Screwdriver
dataGridView1.AllowUserToAddRows = true;
dataGridView1.AllowUserToDeleteRows = true;
var memorySetting = MemorySetting.Current;
ServerIPTextbox.Text = memorySetting.ServerIP;
ServerPortTextbox.Text=memorySetting.ServerPort;
AlarmTimeValueTextBox.Text = memorySetting.AlarmTimeValue.ToString();
txtCom.Text=memorySetting.Com;
}
@ -189,10 +199,12 @@ namespace NDSD_Screwdriver
return x >= a && x <= b;
}
private void SetServerIPButton_Click(object sender, EventArgs e)
{
MemorySetting.ServerIP = ServerIPTextbox.Text;
MemorySetting.ServerPort = ServerPortTextbox.Text;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
@ -202,7 +214,16 @@ namespace NDSD_Screwdriver
private void SetAlarmTimeValueButton_Click(object sender, EventArgs e)
{
MemorySetting.AlarmTimeValue = Convert.ToInt32(AlarmTimeValueTextBox.Text);
var memorySetting = MemorySetting.Current;
memorySetting.ServerIP = ServerIPTextbox.Text;
memorySetting.ServerPort = ServerPortTextbox.Text;
memorySetting.AlarmTimeValue = Convert.ToInt32(AlarmTimeValueTextBox.Text);
memorySetting.Com = txtCom.Text;
memorySetting.Save();
MessageBox.Show("设置成功");
}
}

@ -41,15 +41,20 @@
this.ServerRestartButton = new System.Windows.Forms.Button();
this.StartServerButton = new System.Windows.Forms.Button();
this.ServerStopButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// DOTest
//
this.DOTest.Location = new System.Drawing.Point(673, 12);
this.DOTest.Location = new System.Drawing.Point(15, 15);
this.DOTest.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.DOTest.Name = "DOTest";
this.DOTest.Size = new System.Drawing.Size(75, 23);
this.DOTest.Size = new System.Drawing.Size(63, 35);
this.DOTest.TabIndex = 0;
this.DOTest.Text = "DO测试";
this.DOTest.UseVisualStyleBackColor = true;
@ -63,12 +68,13 @@
this.LogValue,
this.RFIDValue});
this.LogDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.LogDataGridView.Location = new System.Drawing.Point(3, 21);
this.LogDataGridView.Location = new System.Drawing.Point(2, 16);
this.LogDataGridView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.LogDataGridView.Name = "LogDataGridView";
this.LogDataGridView.RowHeadersVisible = false;
this.LogDataGridView.RowHeadersWidth = 51;
this.LogDataGridView.RowTemplate.Height = 27;
this.LogDataGridView.Size = new System.Drawing.Size(587, 826);
this.LogDataGridView.Size = new System.Drawing.Size(441, 1251);
this.LogDataGridView.TabIndex = 1;
//
// logTime
@ -100,9 +106,11 @@
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.groupBox1.Controls.Add(this.LogDataGridView);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox1.Location = new System.Drawing.Point(754, 0);
this.groupBox1.Location = new System.Drawing.Point(713, 0);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(593, 850);
this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Size = new System.Drawing.Size(445, 1269);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "日志";
@ -110,6 +118,7 @@
// ScrewdriverMonitor
//
this.ScrewdriverMonitor.AssistHeaderText = "";
this.ScrewdriverMonitor.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ScrewdriverMonitor.BorderColor = System.Drawing.Color.Black;
this.ScrewdriverMonitor.ColumnHeader = new string[] {
"工作标识",
@ -120,14 +129,15 @@
0.1F,
0.9F,
1F};
this.ScrewdriverMonitor.Dock = System.Windows.Forms.DockStyle.Left;
this.ScrewdriverMonitor.Dock = System.Windows.Forms.DockStyle.Fill;
this.ScrewdriverMonitor.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ScrewdriverMonitor.ForeColor = System.Drawing.Color.Black;
this.ScrewdriverMonitor.HeaderColor = System.Drawing.Color.Black;
this.ScrewdriverMonitor.Location = new System.Drawing.Point(0, 0);
this.ScrewdriverMonitor.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ScrewdriverMonitor.Name = "ScrewdriverMonitor";
this.ScrewdriverMonitor.RowsTotalCount = 13;
this.ScrewdriverMonitor.Size = new System.Drawing.Size(667, 850);
this.ScrewdriverMonitor.Size = new System.Drawing.Size(622, 1269);
this.ScrewdriverMonitor.TabIndex = 3;
this.ScrewdriverMonitor.Text = "hslTable1";
this.ScrewdriverMonitor.TopHeaderColor = System.Drawing.Color.Black;
@ -138,9 +148,10 @@
//
// TestButton
//
this.TestButton.Location = new System.Drawing.Point(673, 70);
this.TestButton.Location = new System.Drawing.Point(15, 113);
this.TestButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.TestButton.Name = "TestButton";
this.TestButton.Size = new System.Drawing.Size(75, 23);
this.TestButton.Size = new System.Drawing.Size(63, 36);
this.TestButton.TabIndex = 4;
this.TestButton.Text = "测试";
this.TestButton.UseVisualStyleBackColor = true;
@ -148,9 +159,10 @@
//
// InitButton
//
this.InitButton.Location = new System.Drawing.Point(673, 41);
this.InitButton.Location = new System.Drawing.Point(15, 70);
this.InitButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.InitButton.Name = "InitButton";
this.InitButton.Size = new System.Drawing.Size(75, 23);
this.InitButton.Size = new System.Drawing.Size(63, 30);
this.InitButton.TabIndex = 7;
this.InitButton.Text = "初始化表";
this.InitButton.UseVisualStyleBackColor = true;
@ -158,9 +170,10 @@
//
// SettingButton
//
this.SettingButton.Location = new System.Drawing.Point(673, 769);
this.SettingButton.Location = new System.Drawing.Point(15, 400);
this.SettingButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.SettingButton.Name = "SettingButton";
this.SettingButton.Size = new System.Drawing.Size(75, 69);
this.SettingButton.Size = new System.Drawing.Size(63, 62);
this.SettingButton.TabIndex = 8;
this.SettingButton.Text = "设置";
this.SettingButton.UseVisualStyleBackColor = true;
@ -168,9 +181,10 @@
//
// ServerRestartButton
//
this.ServerRestartButton.Location = new System.Drawing.Point(673, 708);
this.ServerRestartButton.Location = new System.Drawing.Point(15, 327);
this.ServerRestartButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerRestartButton.Name = "ServerRestartButton";
this.ServerRestartButton.Size = new System.Drawing.Size(75, 55);
this.ServerRestartButton.Size = new System.Drawing.Size(63, 54);
this.ServerRestartButton.TabIndex = 9;
this.ServerRestartButton.Text = "重启服务器";
this.ServerRestartButton.UseVisualStyleBackColor = true;
@ -178,9 +192,10 @@
//
// StartServerButton
//
this.StartServerButton.Location = new System.Drawing.Point(673, 586);
this.StartServerButton.Location = new System.Drawing.Point(15, 169);
this.StartServerButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.StartServerButton.Name = "StartServerButton";
this.StartServerButton.Size = new System.Drawing.Size(75, 55);
this.StartServerButton.Size = new System.Drawing.Size(63, 55);
this.StartServerButton.TabIndex = 10;
this.StartServerButton.Text = "手动启动服务器";
this.StartServerButton.UseVisualStyleBackColor = true;
@ -188,33 +203,55 @@
//
// ServerStopButton
//
this.ServerStopButton.Location = new System.Drawing.Point(673, 647);
this.ServerStopButton.Location = new System.Drawing.Point(15, 250);
this.ServerStopButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerStopButton.Name = "ServerStopButton";
this.ServerStopButton.Size = new System.Drawing.Size(75, 55);
this.ServerStopButton.Size = new System.Drawing.Size(63, 58);
this.ServerStopButton.TabIndex = 11;
this.ServerStopButton.Text = "手动关闭服务器";
this.ServerStopButton.UseVisualStyleBackColor = true;
this.ServerStopButton.Click += new System.EventHandler(this.ServerStopButton_Click);
//
// panel1
//
this.panel1.Controls.Add(this.DOTest);
this.panel1.Controls.Add(this.SettingButton);
this.panel1.Controls.Add(this.ServerRestartButton);
this.panel1.Controls.Add(this.ServerStopButton);
this.panel1.Controls.Add(this.InitButton);
this.panel1.Controls.Add(this.StartServerButton);
this.panel1.Controls.Add(this.TestButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Location = new System.Drawing.Point(622, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(91, 1269);
this.panel1.TabIndex = 12;
//
// panel2
//
this.panel2.Controls.Add(this.ScrewdriverMonitor);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(622, 1269);
this.panel2.TabIndex = 13;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1347, 850);
this.Controls.Add(this.ServerStopButton);
this.Controls.Add(this.StartServerButton);
this.Controls.Add(this.ServerRestartButton);
this.Controls.Add(this.SettingButton);
this.Controls.Add(this.InitButton);
this.Controls.Add(this.TestButton);
this.Controls.Add(this.ScrewdriverMonitor);
this.ClientSize = new System.Drawing.Size(1158, 1269);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.DOTest);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "MainForm";
this.Text = "拧紧枪监控主界面";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).EndInit();
this.groupBox1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -234,5 +271,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn logTime;
private System.Windows.Forms.DataGridViewTextBoxColumn LogValue;
private System.Windows.Forms.DataGridViewTextBoxColumn RFIDValue;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
}
}

@ -77,13 +77,16 @@ namespace NDSD_Screwdriver
{
SqlLiteTool.CreateTable(AppTool.GetDb());
InitializeComponent();
var memorySetting = MemorySetting.Current;
LogContext = SqlLiteTool.GetDb(AppTool.GetDb());
RFIDLogsEntitys = LogContext.Query<RFIDLogsEntity>().OrderByDesc(a => a.CreateTime).Take(200).ToList();
LogDataGridView.AutoGenerateColumns = false;
LogDataGridView.DataSource = null;
LogDataGridView.DataSource = RFIDLogsEntitys;
DOperate = new DOperate();
if (!server.ServerOpen(MemorySetting.ServerIP, MemorySetting.ServerPort))
if (!server.ServerOpen(memorySetting.ServerIP, memorySetting.ServerPort))
{
MessageBox.Show("服务端打开失败!");
FormUtils.LogInsert(LogContext, "服务端打开失败");
@ -233,7 +236,10 @@ namespace NDSD_Screwdriver
/// <param name="e"></param>
private void ServerRestartButton_Click(object sender, EventArgs e)
{
if (server.ServerRestart(MemorySetting.ServerIP, MemorySetting.ServerPort))
var memorySetting = MemorySetting.Current;
if (server.ServerRestart(memorySetting.ServerIP, memorySetting.ServerPort))
{
MessageBox.Show("服务器重启成功!");
FormUtils.LogInsert(LogContext, "服务器重启成功");
@ -254,7 +260,8 @@ namespace NDSD_Screwdriver
/// <param name="e"></param>
private void StartServerButton_Click(object sender, EventArgs e)
{
if (!server.ServerOpen(MemorySetting.ServerIP, MemorySetting.ServerPort))
var memorySetting = MemorySetting.Current;
if (!server.ServerOpen(memorySetting.ServerIP, memorySetting.ServerPort))
{
MessageBox.Show("服务端打开失败!");
FormUtils.LogInsert(LogContext, "服务端打开失败");
@ -328,6 +335,9 @@ namespace NDSD_Screwdriver
/// <param name="rfid">读取到的RFID</param>
private void SetNowWorkRow(string rfid)
{
var memorySetting = MemorySetting.Current;
//设置RFID状态
int flag = 0;
for (int i = 0; i < RFIDStatesEntities.Count; i++)
@ -340,14 +350,14 @@ namespace NDSD_Screwdriver
if (i - 1 >= 0)
{
string rfidValue = RFIDStatesEntities[i - 1].RFIDValue;
var leastTime = RFIDLogsEntitys.Where(x => x.RFIDId == rfidValue)/*.OrderByDescending(x => x.CreateTime)*/.FirstOrDefault().CreateTime;
var leastTime = RFIDLogsEntitys.First(x => x.RFIDId == rfidValue).CreateTime;
double timeSpan = (DateTime.Now - leastTime).TotalSeconds;
if (timeSpan >= MemorySetting.AlarmTimeValue)
if (timeSpan >= memorySetting.AlarmTimeValue)
{
RFIDStatesEntities[i - 1].RFIDState = 4;
FormUtils.LogInsert(LogContext, "RFID " + i + " 超时结束", RFIDStatesEntities[i].RFIDValue);
}
if (timeSpan < MemorySetting.AlarmTimeValue)
if (timeSpan < memorySetting.AlarmTimeValue)
{
RFIDStatesEntities[i - 1].RFIDState = 3;
FormUtils.LogInsert(LogContext, "RFID " + (i - 1) + " 成功结束", RFIDStatesEntities[i].RFIDValue);
@ -371,19 +381,20 @@ namespace NDSD_Screwdriver
}
if (flag == 0) //列表里没有已读的RFID
{
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
if (RFIDStatesEntities[i].RFIDState == 1)
{
string rfidValue = RFIDStatesEntities[i - 1].RFIDValue;
var leastTime = RFIDLogsEntitys.Where(x => x.RFIDId == rfidValue)/*.OrderByDescending(x => x.CreateTime)*/.FirstOrDefault().CreateTime;
var leastTime = RFIDLogsEntitys.First(x => x.RFIDId == rfidValue).CreateTime;
double timeSpan = (DateTime.Now - leastTime).TotalSeconds;
if (timeSpan >= MemorySetting.AlarmTimeValue)
if (timeSpan >= memorySetting.AlarmTimeValue)
{
RFIDStatesEntities[i].RFIDState = 4;
FormUtils.LogInsert(LogContext, "RFID " + i + " 超时结束", RFIDStatesEntities[i].RFIDValue);
}
if (timeSpan < MemorySetting.AlarmTimeValue)
if (timeSpan < memorySetting.AlarmTimeValue)
{
RFIDStatesEntities[i].RFIDState = 3;
FormUtils.LogInsert(LogContext, "RFID " + (i - 1) + " 成功结束", RFIDStatesEntities[i].RFIDValue);

@ -1,26 +1,37 @@
using System;
using NewLife.Configuration;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NDSD_Screwdriver
{
public static class MemorySetting
[DisplayName("核心设置")]
[Config("MemorySetting")]
public class MemorySetting : Config<MemorySetting>
{
/// <summary>
/// 服务端IP
/// </summary>
public static string ServerIP { get; set; } = "192.168.0.101";
public string ServerIP { get; set; } = "192.168.0.101";
/// <summary>
/// 服务端端口
/// </summary>
public static string ServerPort { get; set; } = "6001";
public string ServerPort { get; set; } = "6001";
/// <summary>
/// 超时报警时间
/// </summary>
public static int AlarmTimeValue { get; set; } = 10;
public int AlarmTimeValue { get; set; } = 10;
public String Com { get; set; }
}
}

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using NewLife.Log;
using System;
using System.Windows.Forms;
using NewLife.Log;
namespace NDSD_Screwdriver
{

@ -50,7 +50,7 @@ namespace NDSD_Screwdriver.Tool
ResponsedData responsedData = waitClient.SendThenResponse(new byte[] { 0x00, 0x03, 0x00, 0x50, 0x00, 0x04, 0x45, 0xC9 });
IRequestInfo requestInfo = responsedData.RequestInfo;
var myFixedHeaderRequestInfo = requestInfo as MyFixedHeaderRequestInfo;
return myFixedHeaderRequestInfo.GetBody();
return myFixedHeaderRequestInfo?.GetBody();
}
catch (Exception e)
{

Loading…
Cancel
Save