项目 8 智慧校园管理平台:5 个任务的示例、自绘素材、WisdomCampus 数据库
CI/CD / test (push) Canceled after 0s
CI/CD / deploy (push) Canceled after 0s

- 示例 p8-t1…t5(代码逐个累加):主界面、校园环境界面、环境采集与分析(路灯手动 / 自动控制、
  LED 推送、自动推送火情、7 天温度图表)、校园安防(入侵提示、摄像机方向、拍照入库)、历史图片
  (按日期查询、左右切换),各有评分规则
- 按书补全参考工程里空着的"推送LED信息""自动控制",给"自动推送火情"绑定 CheckedChanged
  (书上第 23 步写成了 ch_autoLamp);任务 5 每次查询前清空 Keys
- 素材:项目 8 的 20 多张图片全部自绘,名字和尺寸与教材一致(project8.py 生成 SVG,
  build-gallery.sh 渲染成 PNG;源文件移到 svg/)
- 数据库 WisdomCampus 按教材的表结构建(EnvironmentData、SecurityData、Users),预置 7 天环境数据
- 测试:参考答案全部通过;没绑定"自动推送火情"、开灯换错背景图片时报出对应原因
- 文档:教材 8 个项目全部有示例,共 23 个

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-23 15:15:00 +08:00
1 parent b20db5721e
commit 65a1b3a81e
109 files changed
+7807 -9

No files matched your search

+142
View File
@@ -0,0 +1,142 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
+39
View File
@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
}
}
+14
View File
@@ -0,0 +1,14 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 主界面显示标题和三个功能入口
steps:
- expect: { control: pictureBox1, image: ico_title, desc: 显示"智慧校园"标题图(ico_title) }
- expect: { control: panel2, background: bg_home, desc: 背景是校园图片(bg_home) }
- expect: { control: pic_environment, image: icon_02, desc: 显示"校园环境"图标(icon_02) }
- expect: { control: pic_security, image: icon_03, desc: 显示"校园安防"图标(icon_03) }
- expect: { control: pic_exit, image: icon_04, desc: 显示"退出"图标(icon_04) }
- title: 实现退出功能
steps:
- click: pic_exit
- expect: { exited: true, desc: 点"退出"后关闭主窗体、程序退出 }
+4
View File
@@ -0,0 +1,4 @@
{
"title": "项目8 任务1 制作管理平台的主界面",
"source": "教材书 p157–159,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致)"
}
+545
View File
@@ -0,0 +1,545 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
}
}
+143
View File
@@ -0,0 +1,143 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,54 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
}
}
@@ -0,0 +1,38 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 主界面能打开"校园环境"界面
steps:
- click: pic_environment
- expect: { window: Environment, desc: 点"校园环境"打开 Environment 窗体 }
- expect: { control: panel_bg, background: day_02, desc: 背景是路灯场景(day_02) }
- title: 界面有环境数据栏
steps:
- click: pic_environment
- expect: { control: txt_fire, visible: true }
- expect: { control: txt_smoke, visible: true }
- expect: { control: txt_light, visible: true }
- expect: { control: txt_temperature, visible: true }
- expect: { control: txt_humidity, visible: true }
- expect: { control: btn_dataAnalyse, text: 数据分析 }
- expect: { control: btn_ledEnvironment1, text: 推送天气信息 }
- title: 界面有路灯控制、LED 推送和图表
steps:
- click: pic_environment
- expect: { control: ch_autoLamp, text: 自动控制 }
- expect: { control: txt_autoLight, visible: true }
- expect: { control: pic_lampOpen, background: switch_off, desc: 灯光控制显示"关"的开关图片(switch_off) }
- expect: { control: ch_autoLedFire, text: 自动推送火情 }
- expect: { control: txt_ledMsg, visible: true }
- expect: { control: btn_ledSendMsg, text: 推送LED信息 }
- expect: { control: btn_ledEnvironment2, text: 推送天气信息 }
- expect: { control: chart1, visible: true }
- title: 能返回主窗体
steps:
- click: pic_environment
- expect: { window: Environment }
- click: lb_return
- expect: { window: Environment, open: false, desc: 点"<返回主窗体"关闭 Environment 窗体 }
- expect: { window: Main, desc: 主窗体还在 }
@@ -0,0 +1,4 @@
{
"title": "项目8 任务2 制作\"校园环境\"界面",
"source": "教材书 p159–164,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);本任务只做界面,为了能看效果,加上了主界面\"校园环境\"打开窗体和\"<返回主窗体\"关闭窗体(书上在任务 3 第 10、22 步)"
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+144
View File
@@ -0,0 +1,144 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,64 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLHelper
{
public static string strConn = AppSet.SqlConn;
public static bool SaveData(string sql, DataTable dt)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(sda);
sda.Update(dt);
conn.Close();
return true;
}
catch (Exception e)
{
string Error = e.Message;
return false;
}
}
public static DataSet getData(string sql, params SqlParameter[] para)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch(Exception e)
{
string Error = e.Message;
}
return ds;
}
public static DataSet getData(SqlCommand cmd)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch (Exception e)
{
string Error = e.Message;
}
return ds;
}
public static int Exec(string sql, params SqlParameter[] para)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
int iRsult = cmd.ExecuteNonQuery();
conn.Close();
return iRsult;
}
catch (Exception e)
{
string Error = e.Message;
return -1;
}
}
}
}
@@ -0,0 +1,71 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
# 采集线程每 5.5 秒左右采集一次,所以等待时间写 8s。
- title: 能实时显示环境数据和火情、烟情
steps:
- click: pic_environment
- board: { temperature: 28, humidity: 55, light: 650 }
- expect: { control: txt_temperature, text: '28', within: 8s }
- expect: { control: txt_humidity, text: '55', within: 8s }
- expect: { control: txt_light, text: '650', within: 8s }
- expect: { control: txt_fire, text: 正常, within: 8s }
- board: { fire: true, smoke: true }
- expect: { control: txt_fire, text: 发生火情, within: 8s }
- expect: { control: txt_smoke, text: 发生烟情, within: 8s }
- title: 路灯能手动控制
steps:
- click: pic_environment
- click: pic_lampOpen
- expect: { zigbee: 1, on: true, desc: 点灯光开关打开路灯 }
- expect: { control: pic_lampOpen, background: switch_on, desc: 开关换成"开"的图片(switch_on) }
- expect: { control: panel_bg, background: day_01, desc: 背景换成亮灯的场景(day_01) }
- click: pic_lampOpen
- expect: { zigbee: 1, on: false, desc: 再点一次关闭路灯 }
- expect: { control: pic_lampOpen, background: switch_off }
- expect: { control: panel_bg, background: day_02 }
- title: 路灯能根据光照度自动控制
steps:
- click: pic_environment
- text: { control: txt_autoLight, value: '400' }
- click: ch_autoLamp
- board: { light: 200 }
- expect: { zigbee: 1, on: true, within: 8s, desc: 光照低于设定值 400 时自动打开路灯 }
- expect: { control: panel_bg, background: day_01 }
- board: { light: 800 }
- expect: { zigbee: 1, on: false, within: 8s, desc: 光照高于设定值时自动关闭路灯 }
- title: 能推送天气信息和自定义信息到 LED 屏
steps:
- board: { temperature: 26, humidity: 50 }
- click: pic_environment
- expect: { control: txt_temperature, text: '26', within: 8s }
- click: btn_ledEnvironment1
- expect: { led: 当前温度:26℃ 湿度:50%, desc: 显示"当前温度:26℃ 湿度:50%"(点下方的"推送天气信息") }
- text: { control: txt_ledMsg, value: 欢迎参观智慧校园 }
- click: btn_ledSendMsg
- expect: { led: 欢迎参观智慧校园, desc: 显示输入的文字(点"推送LED信息") }
- click: btn_ledEnvironment2
- expect: { led: 当前温度:26℃, desc: 显示天气信息(点右边的"推送天气信息") }
- title: 能自动推送火情到 LED 屏
steps:
- click: pic_environment
- click: ch_autoLedFire
- board: { fire: true }
- expect: { led: 发现火情, within: 8s, desc: 显示"发现火情"(勾选"自动推送火情"后有火焰) }
- board: { smoke: true }
- expect: { led: 发生严重火灾, within: 8s, desc: 显示"发生严重火灾"(火焰和烟雾都有) }
- title: 图表能正确显示数据
steps:
- click: pic_environment
- expect: { control: chart1, visible: false, desc: 刚打开时图表隐藏 }
- click: btn_dataAnalyse
- expect: { control: chart1, visible: true, desc: 点"数据分析"显示图表 }
- expect: { control: chart1, points: 7, desc: 显示最近 7 天的最高温度和平均温度 }
- expect: { control: btn_dataAnalyse, text: 关闭图表 }
- click: btn_dataAnalyse
- expect: { control: chart1, visible: false, desc: 点"关闭图表"隐藏图表 }
- expect: { control: btn_dataAnalyse, text: 数据分析 }
@@ -0,0 +1,54 @@
-- 实验的初始数据库 WisdomCampus(教材"综合实训"附带的库):环境数据表 EnvironmentData、报警图片表 SecurityData、用户表 Users。
-- EnvironmentData 预置了 7 天的历史数据,"数据分析"的图表一打开就有内容;SecurityData 是空的,拍照或有人入侵时才有记录。
-- 学生可以在数据库页面"恢复实验初始数据";评分时每个检查项用一份新的。
CREATE DATABASE WisdomCampus
GO
USE WisdomCampus
GO
CREATE TABLE Users (Id int IDENTITY(1,1) PRIMARY KEY, UserName nvarchar(50) NOT NULL, Password nvarchar(50) NOT NULL)
CREATE TABLE EnvironmentData (Id int IDENTITY(1,1) PRIMARY KEY, Fire bit NOT NULL, Smoke bit NOT NULL, Temperature float NULL, Humidity float NULL, Light float NULL, _Time datetime NOT NULL)
CREATE TABLE SecurityData (Id int IDENTITY(1,1) PRIMARY KEY, EvenTime datetime NOT NULL, EvenImage image NOT NULL)
GO
INSERT INTO Users (UserName, Password) VALUES ('admin', '123')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 58, 258, '2026-10-14 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.1, 53, 475, '2026-10-14 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 761, '2026-10-14 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.5, 49, 733, '2026-10-14 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 54, 528, '2026-10-14 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 283, '2026-10-14 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.9, 59, 261, '2026-10-15 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 53, 499, '2026-10-15 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 764, '2026-10-15 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.5, 47, 778, '2026-10-15 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 503, '2026-10-15 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 56, 218, '2026-10-15 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 13.9, 63, 258, '2026-10-16 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 60, 477, '2026-10-16 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 741, '2026-10-16 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.5, 54, 796, '2026-10-16 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 488, '2026-10-16 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 59, 214, '2026-10-16 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 11.9, 67, 234, '2026-10-17 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 63, 544, '2026-10-17 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.3, 60, 804, '2026-10-17 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.5, 54, 801, '2026-10-17 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.8, 59, 524, '2026-10-17 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 58, 286, '2026-10-17 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.4, 59, 250, '2026-10-18 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 55, 533, '2026-10-18 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.3, 50, 749, '2026-10-18 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 24, 48, 766, '2026-10-18 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.8, 54, 534, '2026-10-18 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.1, 53, 241, '2026-10-18 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.4, 54, 253, '2026-10-19 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.1, 50, 474, '2026-10-19 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.3, 48, 778, '2026-10-19 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 26, 46, 783, '2026-10-19 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.3, 50, 520, '2026-10-19 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.6, 50, 213, '2026-10-19 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 62, 230, '2026-10-20 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.6, 52, 471, '2026-10-20 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 53, 751, '2026-10-20 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.5, 48, 747, '2026-10-20 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 527, '2026-10-20 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 220, '2026-10-20 18:00:00')
@@ -0,0 +1,4 @@
{
"title": "项目8 任务3 实现\"校园环境\"数据采集及数据分析功能",
"source": "教材书 p164–174,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);按书补全了参考工程里空着的\"推送LED信息\"\"自动控制\",给\"自动推送火情\"复选框加上 CheckedChanged(书上第 23 步把控件名写成了 ch_autoLamp);数据库 WisdomCampus 是平台按教材的表结构建的,预置 7 天环境数据"
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
+555
View File
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
+279
View File
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+145
View File
@@ -0,0 +1,145 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
this.pic_security.Click += new System.EventHandler(this.pic_security_Click);
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+72
View File
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_security_Click(object sender, EventArgs e)
{
try
{
new Security().Show();
}
catch
{
}
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
/// <summary>监控:无画面</summary>
internal static System.Drawing.Bitmap icon_monitor {
get { return global::Sim.Host.ProjectResources.Image("icon_monitor.png"); }
}
/// <summary>监控:方向盘底座</summary>
internal static System.Drawing.Bitmap panel_video_ctrl {
get { return global::Sim.Host.ProjectResources.Image("panel_video_ctrl.png"); }
}
/// <summary>方向键:上</summary>
internal static System.Drawing.Bitmap btn_arrow_up_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_normal.png"); }
}
/// <summary>方向键:上(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_up_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_press.png"); }
}
/// <summary>方向键:下</summary>
internal static System.Drawing.Bitmap btn_arrow_down_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_normal.png"); }
}
/// <summary>方向键:下(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_down_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_press.png"); }
}
/// <summary>方向键:左</summary>
internal static System.Drawing.Bitmap btn_arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_normal.png"); }
}
/// <summary>方向键:左(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_left_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_press.png"); }
}
/// <summary>方向键:右</summary>
internal static System.Drawing.Bitmap btn_arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_normal.png"); }
}
/// <summary>方向键:右(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_right_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_press.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLHelper
{
public static string strConn = AppSet.SqlConn;
public static bool SaveData(string sql, DataTable dt)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(sda);
sda.Update(dt);
conn.Close();
return true;
}
catch (Exception e)
{
string Error = e.Message;
return false;
}
}
public static DataSet getData(string sql, params SqlParameter[] para)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch(Exception e)
{
string Error = e.Message;
}
return ds;
}
public static DataSet getData(SqlCommand cmd)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch (Exception e)
{
string Error = e.Message;
}
return ds;
}
public static int Exec(string sql, params SqlParameter[] para)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
int iRsult = cmd.ExecuteNonQuery();
conn.Close();
return iRsult;
}
catch (Exception e)
{
string Error = e.Message;
return -1;
}
}
}
}
+296
View File
@@ -0,0 +1,296 @@
namespace 智慧校园
{
partial class Security
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel_bg_video = new System.Windows.Forms.Panel();
this.btn_history = new System.Windows.Forms.Button();
this.btn_camera = new System.Windows.Forms.Button();
this.panel_video_ctrl = new System.Windows.Forms.Panel();
this.pic_left = new System.Windows.Forms.PictureBox();
this.pic_right = new System.Windows.Forms.PictureBox();
this.pic_down = new System.Windows.Forms.PictureBox();
this.pic_up = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.lb_infrared = new System.Windows.Forms.Label();
this.pic_video = new System.Windows.Forms.PictureBox();
this.panel3.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel_bg_video.SuspendLayout();
this.panel_video_ctrl.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_left)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).BeginInit();
this.SuspendLayout();
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 100);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1081, 39);
this.panel3.TabIndex = 1;
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1081, 100);
this.panel1.TabIndex = 2;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel_bg_video
//
this.panel_bg_video.BackColor = System.Drawing.Color.White;
this.panel_bg_video.Controls.Add(this.btn_history);
this.panel_bg_video.Controls.Add(this.btn_camera);
this.panel_bg_video.Controls.Add(this.panel_video_ctrl);
this.panel_bg_video.Controls.Add(this.panel2);
this.panel_bg_video.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg_video.Location = new System.Drawing.Point(0, 139);
this.panel_bg_video.Name = "panel_bg_video";
this.panel_bg_video.Size = new System.Drawing.Size(1081, 499);
this.panel_bg_video.TabIndex = 3;
this.panel_bg_video.Paint += new System.Windows.Forms.PaintEventHandler(this.panel_bg_video_Paint);
//
// btn_history
//
this.btn_history.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(213)))), ((int)(((byte)(122)))));
this.btn_history.Font = new System.Drawing.Font("微软雅黑", 14F);
this.btn_history.Location = new System.Drawing.Point(804, 410);
this.btn_history.Name = "btn_history";
this.btn_history.Size = new System.Drawing.Size(160, 49);
this.btn_history.TabIndex = 10;
this.btn_history.Text = "查看历史图像";
this.btn_history.UseVisualStyleBackColor = false;
//
// btn_camera
//
this.btn_camera.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(200)))), ((int)(((byte)(81)))));
this.btn_camera.Font = new System.Drawing.Font("微软雅黑", 16F);
this.btn_camera.Location = new System.Drawing.Point(804, 326);
this.btn_camera.Name = "btn_camera";
this.btn_camera.Size = new System.Drawing.Size(160, 49);
this.btn_camera.TabIndex = 9;
this.btn_camera.Text = "拍照";
this.btn_camera.UseVisualStyleBackColor = false;
this.btn_camera.Click += new System.EventHandler(this.btn_camera_Click);
//
// panel_video_ctrl
//
this.panel_video_ctrl.BackgroundImage = global::智慧校园.Properties.Resources.panel_video_ctrl;
this.panel_video_ctrl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_video_ctrl.Controls.Add(this.pic_left);
this.panel_video_ctrl.Controls.Add(this.pic_right);
this.panel_video_ctrl.Controls.Add(this.pic_down);
this.panel_video_ctrl.Controls.Add(this.pic_up);
this.panel_video_ctrl.Location = new System.Drawing.Point(741, 15);
this.panel_video_ctrl.Name = "panel_video_ctrl";
this.panel_video_ctrl.Size = new System.Drawing.Size(328, 294);
this.panel_video_ctrl.TabIndex = 1;
//
// pic_left
//
this.pic_left.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_left_normal;
this.pic_left.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_left.Location = new System.Drawing.Point(63, 116);
this.pic_left.Name = "pic_left";
this.pic_left.Size = new System.Drawing.Size(39, 54);
this.pic_left.TabIndex = 6;
this.pic_left.TabStop = false;
this.pic_left.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseDown);
this.pic_left.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseUp);
//
// pic_right
//
this.pic_right.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_right_normal;
this.pic_right.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_right.Location = new System.Drawing.Point(223, 116);
this.pic_right.Name = "pic_right";
this.pic_right.Size = new System.Drawing.Size(39, 54);
this.pic_right.TabIndex = 5;
this.pic_right.TabStop = false;
this.pic_right.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseDown);
this.pic_right.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseUp);
//
// pic_down
//
this.pic_down.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_down_normal;
this.pic_down.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_down.Location = new System.Drawing.Point(143, 202);
this.pic_down.Name = "pic_down";
this.pic_down.Size = new System.Drawing.Size(39, 54);
this.pic_down.TabIndex = 4;
this.pic_down.TabStop = false;
this.pic_down.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseDown);
this.pic_down.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseUp);
//
// pic_up
//
this.pic_up.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_up_normal;
this.pic_up.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_up.Location = new System.Drawing.Point(142, 20);
this.pic_up.Name = "pic_up";
this.pic_up.Size = new System.Drawing.Size(39, 54);
this.pic_up.TabIndex = 1;
this.pic_up.TabStop = false;
this.pic_up.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseDown);
this.pic_up.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseUp);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.DimGray;
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.lb_infrared);
this.panel2.Controls.Add(this.pic_video);
this.panel2.Location = new System.Drawing.Point(69, 15);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(666, 472);
this.panel2.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Location = new System.Drawing.Point(545, 91);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 21);
this.label2.TabIndex = 12;
this.label2.Text = "入侵:";
//
// lb_infrared
//
this.lb_infrared.AutoSize = true;
this.lb_infrared.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_infrared.ForeColor = System.Drawing.Color.White;
this.lb_infrared.Location = new System.Drawing.Point(597, 91);
this.lb_infrared.Name = "lb_infrared";
this.lb_infrared.Size = new System.Drawing.Size(41, 21);
this.lb_infrared.TabIndex = 11;
this.lb_infrared.Text = "N/A";
//
// pic_video
//
this.pic_video.BackColor = System.Drawing.Color.DarkGray;
this.pic_video.BackgroundImage = global::智慧校园.Properties.Resources.icon_monitor;
this.pic_video.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pic_video.Location = new System.Drawing.Point(32, 38);
this.pic_video.Name = "pic_video";
this.pic_video.Size = new System.Drawing.Size(478, 322);
this.pic_video.TabIndex = 0;
this.pic_video.TabStop = false;
this.pic_video.Click += new System.EventHandler(this.pictureBox2_Click);
//
// Security
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1081, 638);
this.Controls.Add(this.panel_bg_video);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Security";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Security";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Security_FormClosed);
this.Load += new System.EventHandler(this.Security_Load);
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel_bg_video.ResumeLayout(false);
this.panel_video_ctrl.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_left)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel_bg_video;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_video;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lb_infrared;
private System.Windows.Forms.Button btn_history;
private System.Windows.Forms.Button btn_camera;
private System.Windows.Forms.Panel panel_video_ctrl;
private System.Windows.Forms.PictureBox pic_left;
private System.Windows.Forms.PictureBox pic_right;
private System.Windows.Forms.PictureBox pic_down;
private System.Windows.Forms.PictureBox pic_up;
}
}
+240
View File
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using DeviceCtrlLibrary;
using 智慧校园.SQLHelpers;
namespace 智慧校园
{
public partial class Security : Form
{ //显示图像
Image img = null;
//入侵标识
bool IsInfrared = false;
//图像文件夹路径
string ImgDir = AppDomain.CurrentDomain.BaseDirectory + "Camera\\";
//用于数据采集和SQL操作
Thread thread;
SynchronizationContext _main;
public Security()
{
InitializeComponent();
}
void ipCameraHelper_ImageRead(ImageReadEvenArgs e)
{
img = e.img;
pic_video.Image = e.img;
}
void tick()
{
try
{
while (true)
{
try
{
//采集入侵状态
IsInfrared = DeviceCtrlHelper.adam4150Helper.SetData().infraredValue;
//UI显示入侵状态
_main.Send(_ =>
{
lb_infrared.Text = IsInfrared ? "发现入侵" : "正常";
}, null);
if (IsInfrared)
{
if (img != null)
//上传报警信息
SQLBLL.SecurityUpData(img);
}
}
catch
{
}
Thread.Sleep(1000);
}
}
catch
{
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel_bg_video_Paint(object sender, PaintEventArgs e)
{
}
private void Security_Load(object sender, EventArgs e)
{
try
{
//实例化摄像头控制类
DeviceCtrlHelper.ipCameraHelper.Open(AppSet.Camera_Ip, AppSet.Camera_Uid, AppSet.Camera_Pwd);
DeviceCtrlHelper.ipCameraHelper.ImageRead += ipCameraHelper_ImageRead;
DeviceCtrlHelper.ipCameraHelper.Start();
thread = new Thread(new ThreadStart(tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
if (!Directory.Exists(ImgDir))
//创建文件夹
Directory.CreateDirectory(ImgDir);
}
catch
{
}
}
private void Security_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
DeviceCtrlHelper.ipCameraHelper.Stop();
DeviceCtrlHelper.ipCameraHelper.Close();
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_camera_Click(object sender, EventArgs e)
{
try
{
pic_video.Image.Save(ImgDir + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg");
SQLBLL.SecurityUpData(pic_video.Image);
}
catch
{
}
}
private void pic_up_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_press;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_up_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_normal;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_down_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_press;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_down_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_normal;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_left_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_press;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_left_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_normal;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_right_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_press;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void pic_right_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_normal;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+46
View File
@@ -0,0 +1,46 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
- title: 摄像机能正常打开
steps:
- click: pic_security
- expect: { window: Security, desc: 点"校园安防"打开 Security 窗体 }
- expect: { camera: on }
- expect: { control: pic_video, image: true, within: 3s, desc: 显示摄像机拍到的图像 }
- title: 人体入侵有文字提示
steps:
- click: pic_security
- board: { infrared: true }
- expect: { control: lb_infrared, text: 发现入侵, within: 3s, desc: 红外对射被遮挡时显示"发现入侵" }
- board: { infrared: false }
- expect: { control: lb_infrared, text: 正常, within: 3s }
- title: 摄像机可以调整方向
steps:
- click: pic_security
- click: pic_up
- expect: { camera: up, desc: 按"↑"向上转 }
- expect: { control: pic_up, background: btn_arrow_up_normal, desc: 松开后方向键换回原来的图片 }
- click: pic_left
- expect: { camera: left, desc: 按"←"向左转 }
- click: pic_down
- click: pic_down
- expect: { camera: down, desc: 按"↓"向下转 }
- click: pic_right
- click: pic_right
- expect: { camera: right, desc: 按"→"向右转 }
- title: 摄像机能拍照并保存图片
steps:
- click: pic_security
- expect: { control: pic_video, image: true, within: 3s }
- click: btn_camera
- expect: { savedImage: Camera/, desc: 把照片保存到 Camera 文件夹 }
- title: 返回主窗体时关闭摄像机
steps:
- click: pic_security
- expect: { camera: on }
- click: lb_return
- expect: { window: Security, open: false }
- expect: { camera: off }
+54
View File
@@ -0,0 +1,54 @@
-- 实验的初始数据库 WisdomCampus(教材"综合实训"附带的库):环境数据表 EnvironmentData、报警图片表 SecurityData、用户表 Users。
-- EnvironmentData 预置了 7 天的历史数据,"数据分析"的图表一打开就有内容;SecurityData 是空的,拍照或有人入侵时才有记录。
-- 学生可以在数据库页面"恢复实验初始数据";评分时每个检查项用一份新的。
CREATE DATABASE WisdomCampus
GO
USE WisdomCampus
GO
CREATE TABLE Users (Id int IDENTITY(1,1) PRIMARY KEY, UserName nvarchar(50) NOT NULL, Password nvarchar(50) NOT NULL)
CREATE TABLE EnvironmentData (Id int IDENTITY(1,1) PRIMARY KEY, Fire bit NOT NULL, Smoke bit NOT NULL, Temperature float NULL, Humidity float NULL, Light float NULL, _Time datetime NOT NULL)
CREATE TABLE SecurityData (Id int IDENTITY(1,1) PRIMARY KEY, EvenTime datetime NOT NULL, EvenImage image NOT NULL)
GO
INSERT INTO Users (UserName, Password) VALUES ('admin', '123')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 58, 258, '2026-10-14 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.1, 53, 475, '2026-10-14 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 761, '2026-10-14 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.5, 49, 733, '2026-10-14 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 54, 528, '2026-10-14 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 283, '2026-10-14 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.9, 59, 261, '2026-10-15 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 53, 499, '2026-10-15 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 764, '2026-10-15 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.5, 47, 778, '2026-10-15 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 503, '2026-10-15 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 56, 218, '2026-10-15 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 13.9, 63, 258, '2026-10-16 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 60, 477, '2026-10-16 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 741, '2026-10-16 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.5, 54, 796, '2026-10-16 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 488, '2026-10-16 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 59, 214, '2026-10-16 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 11.9, 67, 234, '2026-10-17 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 63, 544, '2026-10-17 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.3, 60, 804, '2026-10-17 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.5, 54, 801, '2026-10-17 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.8, 59, 524, '2026-10-17 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 58, 286, '2026-10-17 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.4, 59, 250, '2026-10-18 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 55, 533, '2026-10-18 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.3, 50, 749, '2026-10-18 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 24, 48, 766, '2026-10-18 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.8, 54, 534, '2026-10-18 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.1, 53, 241, '2026-10-18 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.4, 54, 253, '2026-10-19 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.1, 50, 474, '2026-10-19 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.3, 48, 778, '2026-10-19 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 26, 46, 783, '2026-10-19 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.3, 50, 520, '2026-10-19 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.6, 50, 213, '2026-10-19 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 62, 230, '2026-10-20 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.6, 52, 471, '2026-10-20 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 53, 751, '2026-10-20 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.5, 48, 747, '2026-10-20 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 527, '2026-10-20 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 220, '2026-10-20 18:00:00')
+4
View File
@@ -0,0 +1,4 @@
{
"title": "项目8 任务4 实现\"校园安防\"功能模块",
"source": "教材书 p174–180,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);\"查看历史图像\"在任务 5 做"
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园
{
class AppSet
{
//串口设置
public static string ADAM4017_COM = "COM2";
public static string ADAM4150_COM = "COM3";
public static string LED_COM = "COM5";
public static string ZigBee_COM = "COM4";
//摄像机参数
public static string Camera_Ip = "192.168.1.100";
public static string Camera_Uid = "admin";
public static string Camera_Pwd = "";
//数据库连接字符串
public static string SqlConn = "Data Source=.;Initial Catalog=WisdomCampus;User ID=sa;Password=123";
}
}
+555
View File
@@ -0,0 +1,555 @@
namespace 智慧校园
{
partial class Environment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel_bg = new System.Windows.Forms.Panel();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.panel_form = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.pic_lampOpen = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txt_autoLight = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.ch_autoLamp = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btn_ledEnvironment2 = new System.Windows.Forms.Button();
this.ch_autoLedFire = new System.Windows.Forms.CheckBox();
this.btn_ledSendMsg = new System.Windows.Forms.Button();
this.txt_ledMsg = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.btn_dataAnalyse = new System.Windows.Forms.Button();
this.btn_ledEnvironment1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txt_humidity = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txt_fire = new System.Windows.Forms.TextBox();
this.txt_temperature = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txt_smoke = new System.Windows.Forms.TextBox();
this.txt_light = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
this.panel_bg.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.panel_form.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).BeginInit();
this.groupBox3.SuspendLayout();
this.panel5.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1043, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.panel_bg);
this.panel2.Controls.Add(this.panel3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1043, 691);
this.panel2.TabIndex = 1;
//
// panel_bg
//
this.panel_bg.BackgroundImage = global::智慧校园.Properties.Resources.day_02;
this.panel_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_bg.Controls.Add(this.chart1);
this.panel_bg.Controls.Add(this.panel_form);
this.panel_bg.Controls.Add(this.panel5);
this.panel_bg.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg.Location = new System.Drawing.Point(0, 39);
this.panel_bg.Name = "panel_bg";
this.panel_bg.Size = new System.Drawing.Size(1043, 652);
this.panel_bg.TabIndex = 1;
//
// chart1
//
chartArea2.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea2);
legend3.Name = "MaxLegend";
legend3.TitleForeColor = System.Drawing.Color.DimGray;
legend4.Name = "AVGLegend";
legend4.TitleForeColor = System.Drawing.Color.DimGray;
this.chart1.Legends.Add(legend3);
this.chart1.Legends.Add(legend4);
this.chart1.Location = new System.Drawing.Point(44, 172);
this.chart1.Name = "chart1";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Legend = "MaxLegend";
series3.LegendText = "最大值";
series3.Name = "MaxSeries";
series3.XValueMember = "_Time";
series3.YValueMembers = "MaxTemperature";
series4.ChartArea = "ChartArea1";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series4.Legend = "AVGLegend";
series4.LegendText = "平均值";
series4.Name = "AVGSeries";
series4.XValueMember = "_Time";
series4.YValueMembers = "AVGTemperature";
this.chart1.Series.Add(series3);
this.chart1.Series.Add(series4);
this.chart1.Size = new System.Drawing.Size(455, 327);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
//
// panel_form
//
this.panel_form.BackColor = System.Drawing.Color.Transparent;
this.panel_form.BackgroundImage = global::智慧校园.Properties.Resources.bg_from2;
this.panel_form.Controls.Add(this.groupBox2);
this.panel_form.Controls.Add(this.groupBox3);
this.panel_form.Dock = System.Windows.Forms.DockStyle.Right;
this.panel_form.Location = new System.Drawing.Point(617, 0);
this.panel_form.Name = "panel_form";
this.panel_form.Size = new System.Drawing.Size(426, 552);
this.panel_form.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.pic_lampOpen);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txt_autoLight);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.ch_autoLamp);
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.Color.White;
this.groupBox2.Location = new System.Drawing.Point(22, 21);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(392, 150);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "路灯控制";
//
// pic_lampOpen
//
this.pic_lampOpen.BackgroundImage = global::智慧校园.Properties.Resources.switch_off;
this.pic_lampOpen.Location = new System.Drawing.Point(103, 103);
this.pic_lampOpen.Name = "pic_lampOpen";
this.pic_lampOpen.Size = new System.Drawing.Size(48, 24);
this.pic_lampOpen.TabIndex = 5;
this.pic_lampOpen.TabStop = false;
this.pic_lampOpen.Click += new System.EventHandler(this.pic_lampOpen_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(33, 105);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 17);
this.label10.TabIndex = 4;
this.label10.Text = "灯光控制:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(278, 58);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(17, 17);
this.label9.TabIndex = 3;
this.label9.Text = "lx";
//
// txt_autoLight
//
this.txt_autoLight.Location = new System.Drawing.Point(128, 55);
this.txt_autoLight.Name = "txt_autoLight";
this.txt_autoLight.Size = new System.Drawing.Size(144, 23);
this.txt_autoLight.TabIndex = 2;
this.txt_autoLight.TextChanged += new System.EventHandler(this.txt_autoLight_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(33, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(92, 17);
this.label7.TabIndex = 1;
this.label7.Text = "设定开灯光照值";
//
// ch_autoLamp
//
this.ch_autoLamp.AutoSize = true;
this.ch_autoLamp.Location = new System.Drawing.Point(35, 30);
this.ch_autoLamp.Name = "ch_autoLamp";
this.ch_autoLamp.Size = new System.Drawing.Size(75, 21);
this.ch_autoLamp.TabIndex = 0;
this.ch_autoLamp.Text = "自动控制";
this.ch_autoLamp.UseVisualStyleBackColor = true;
this.ch_autoLamp.CheckedChanged += new System.EventHandler(this.ch_autoLamp_CheckedChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btn_ledEnvironment2);
this.groupBox3.Controls.Add(this.ch_autoLedFire);
this.groupBox3.Controls.Add(this.btn_ledSendMsg);
this.groupBox3.Controls.Add(this.txt_ledMsg);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.ForeColor = System.Drawing.Color.White;
this.groupBox3.Location = new System.Drawing.Point(22, 209);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(392, 316);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "LED推送";
//
// btn_ledEnvironment2
//
this.btn_ledEnvironment2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment2.Location = new System.Drawing.Point(234, 217);
this.btn_ledEnvironment2.Name = "btn_ledEnvironment2";
this.btn_ledEnvironment2.Size = new System.Drawing.Size(145, 32);
this.btn_ledEnvironment2.TabIndex = 11;
this.btn_ledEnvironment2.Text = "推送天气信息";
this.btn_ledEnvironment2.UseVisualStyleBackColor = false;
this.btn_ledEnvironment2.Click += new System.EventHandler(this.btn_ledEnvironment2_Click);
//
// ch_autoLedFire
//
this.ch_autoLedFire.AutoSize = true;
this.ch_autoLedFire.Location = new System.Drawing.Point(265, 35);
this.ch_autoLedFire.Name = "ch_autoLedFire";
this.ch_autoLedFire.Size = new System.Drawing.Size(99, 21);
this.ch_autoLedFire.TabIndex = 4;
this.ch_autoLedFire.Text = "自动推送火情";
this.ch_autoLedFire.UseVisualStyleBackColor = true;
this.ch_autoLedFire.CheckedChanged += new System.EventHandler(this.ch_autoLedFire_CheckedChanged);
//
// btn_ledSendMsg
//
this.btn_ledSendMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_ledSendMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledSendMsg.Location = new System.Drawing.Point(26, 217);
this.btn_ledSendMsg.Name = "btn_ledSendMsg";
this.btn_ledSendMsg.Size = new System.Drawing.Size(145, 32);
this.btn_ledSendMsg.TabIndex = 2;
this.btn_ledSendMsg.Text = "推送LED信息";
this.btn_ledSendMsg.UseVisualStyleBackColor = false;
this.btn_ledSendMsg.Click += new System.EventHandler(this.btn_ledSendMsg_Click);
//
// txt_ledMsg
//
this.txt_ledMsg.Location = new System.Drawing.Point(23, 62);
this.txt_ledMsg.Multiline = true;
this.txt_ledMsg.Name = "txt_ledMsg";
this.txt_ledMsg.Size = new System.Drawing.Size(356, 130);
this.txt_ledMsg.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(54, 17);
this.label8.TabIndex = 0;
this.label8.Text = "LED信息";
//
// panel5
//
this.panel5.Controls.Add(this.btn_dataAnalyse);
this.panel5.Controls.Add(this.btn_ledEnvironment1);
this.panel5.Controls.Add(this.label6);
this.panel5.Controls.Add(this.txt_humidity);
this.panel5.Controls.Add(this.label1);
this.panel5.Controls.Add(this.label5);
this.panel5.Controls.Add(this.txt_fire);
this.panel5.Controls.Add(this.txt_temperature);
this.panel5.Controls.Add(this.label2);
this.panel5.Controls.Add(this.label4);
this.panel5.Controls.Add(this.txt_smoke);
this.panel5.Controls.Add(this.txt_light);
this.panel5.Controls.Add(this.label3);
this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel5.Location = new System.Drawing.Point(0, 552);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1043, 100);
this.panel5.TabIndex = 1;
//
// btn_dataAnalyse
//
this.btn_dataAnalyse.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(168)))), ((int)(((byte)(255)))));
this.btn_dataAnalyse.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_dataAnalyse.Location = new System.Drawing.Point(792, 35);
this.btn_dataAnalyse.Name = "btn_dataAnalyse";
this.btn_dataAnalyse.Size = new System.Drawing.Size(119, 32);
this.btn_dataAnalyse.TabIndex = 23;
this.btn_dataAnalyse.Text = "数据分析";
this.btn_dataAnalyse.UseVisualStyleBackColor = false;
this.btn_dataAnalyse.Click += new System.EventHandler(this.btn_dataAnalyse_Click);
//
// btn_ledEnvironment1
//
this.btn_ledEnvironment1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(149)))), ((int)(((byte)(212)))));
this.btn_ledEnvironment1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btn_ledEnvironment1.Location = new System.Drawing.Point(910, 35);
this.btn_ledEnvironment1.Name = "btn_ledEnvironment1";
this.btn_ledEnvironment1.Size = new System.Drawing.Size(121, 32);
this.btn_ledEnvironment1.TabIndex = 15;
this.btn_ledEnvironment1.Text = "推送天气信息";
this.btn_ledEnvironment1.UseVisualStyleBackColor = false;
this.btn_ledEnvironment1.Click += new System.EventHandler(this.btn_ledEnvironment1_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 18F);
this.label6.Location = new System.Drawing.Point(12, 31);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 31);
this.label6.TabIndex = 11;
this.label6.Text = "环境数据";
//
// txt_humidity
//
this.txt_humidity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_humidity.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_humidity.Location = new System.Drawing.Point(716, 36);
this.txt_humidity.Name = "txt_humidity";
this.txt_humidity.Size = new System.Drawing.Size(70, 32);
this.txt_humidity.TabIndex = 22;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label1.Location = new System.Drawing.Point(132, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 25);
this.label1.TabIndex = 12;
this.label1.Text = "火焰";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label5.Location = new System.Drawing.Point(660, 39);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 25);
this.label5.TabIndex = 21;
this.label5.Text = "湿度";
//
// txt_fire
//
this.txt_fire.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_fire.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_fire.Location = new System.Drawing.Point(188, 35);
this.txt_fire.Name = "txt_fire";
this.txt_fire.Size = new System.Drawing.Size(70, 32);
this.txt_fire.TabIndex = 13;
//
// txt_temperature
//
this.txt_temperature.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_temperature.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_temperature.Location = new System.Drawing.Point(584, 35);
this.txt_temperature.Name = "txt_temperature";
this.txt_temperature.Size = new System.Drawing.Size(70, 32);
this.txt_temperature.TabIndex = 20;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label2.Location = new System.Drawing.Point(264, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 25);
this.label2.TabIndex = 14;
this.label2.Text = "烟雾";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label4.Location = new System.Drawing.Point(528, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(50, 25);
this.label4.TabIndex = 19;
this.label4.Text = "温度";
//
// txt_smoke
//
this.txt_smoke.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_smoke.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_smoke.Location = new System.Drawing.Point(320, 33);
this.txt_smoke.Name = "txt_smoke";
this.txt_smoke.Size = new System.Drawing.Size(70, 32);
this.txt_smoke.TabIndex = 16;
//
// txt_light
//
this.txt_light.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(206)))), ((int)(((byte)(206)))), ((int)(((byte)(206)))));
this.txt_light.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_light.Location = new System.Drawing.Point(452, 32);
this.txt_light.Name = "txt_light";
this.txt_light.Size = new System.Drawing.Size(70, 32);
this.txt_light.TabIndex = 18;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 14F);
this.label3.Location = new System.Drawing.Point(396, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 25);
this.label3.TabIndex = 17;
this.label3.Text = "光照";
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1043, 39);
this.panel3.TabIndex = 0;
this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// Environment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1043, 791);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Environment";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Environment";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Environment_FormClosed);
this.Load += new System.EventHandler(this.Environment_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
this.panel_bg.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.panel_form.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_lampOpen)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel_bg;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel_form;
private System.Windows.Forms.Button btn_dataAnalyse;
private System.Windows.Forms.Button btn_ledEnvironment1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_humidity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_fire;
private System.Windows.Forms.TextBox txt_temperature;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txt_smoke;
private System.Windows.Forms.TextBox txt_light;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pic_lampOpen;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_autoLight;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox ch_autoLamp;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btn_ledEnvironment2;
private System.Windows.Forms.CheckBox ch_autoLedFire;
private System.Windows.Forms.Button btn_ledSendMsg;
private System.Windows.Forms.TextBox txt_ledMsg;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}
+279
View File
@@ -0,0 +1,279 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using DeviceCtrlLibrary.Model;
using 智慧校园.SQLHelpers;
using System.Threading;
namespace 智慧校园
{
public partial class Environment : Form
{
public Environment()
{
InitializeComponent();
}
//用于各类耗时长的操作(SQL、数据采集、设备控制等)
Thread thread;
//用于异步通行
SynchronizationContext _main;
//结果模型
ADAM4017ResModel ResModel_4017;
ADAM4150ResModel ResModel_4150;
//设置自动控制路灯的光照值
double environmentLight, setLight;
//按钮状态标志
bool IsAuto_Lamp = false;
bool IsAuto_FireMsg = false;
bool IsLampOpen = false;
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
private void Environment_Load(object sender, EventArgs e)
{
try
{
//隐藏曲线图
chart1.Visible = false;
thread = new Thread(new ThreadStart(Tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
}
catch
{
}
}
private void Tick()
{
try
{
while (true)
{
//数据采集
ResModel_4017 = DeviceCtrlHelper.adam4017Helper.SetData();
Thread.Sleep(500);
ResModel_4150 = DeviceCtrlHelper.adam4150Helper.SetData();
//UI显示数据
_main.Send(_ =>
{
try //防止无数据出错
{
txt_fire.Text = (ResModel_4150.fireValue ? "发生火情" : "正常");
txt_smoke.Text = (ResModel_4150.smokeValue ? "发生烟情" : "正常");
txt_light.Text = ResModel_4017.lightValue;
txt_temperature.Text = ResModel_4017.temperatureValue;
txt_humidity.Text = ResModel_4017.humidityValue;
}
catch { }
}, null);
//自动路灯控制
double.TryParse(ResModel_4017.lightValue, out environmentLight);
if (IsAuto_Lamp && environmentLight < setLight)
{
LampOnOff(1, true);
}
else if (IsAuto_Lamp && !(environmentLight < setLight))
{
LampOnOff(1, false);
}
//自动推送火情LED信息控制
if (IsAuto_FireMsg)
{
if (ResModel_4150.fireValue && ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发生严重火灾 ");
else if (ResModel_4150.fireValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现火情 ");
else if (ResModel_4150.smokeValue)
DeviceCtrlHelper.ledHelper.SendLedString("发现烟情 ");
}
//执行数据上传
SQLBLL.EnvironmentUpData(ResModel_4150.fireValue, ResModel_4150.smokeValue, ResModel_4017.lightValue, ResModel_4017.temperatureValue, ResModel_4017.humidityValue);
Thread.Sleep(5000);
}
}
catch
{
}
}
private void LampOnOff(int RelayNum, bool IsOpen)
{
try
{
//开启路灯
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
//切换UI背景
_main.Send(_ =>
{
if (IsOpen)
{
pic_lampOpen.BackgroundImage = Properties.Resources.switch_on;
panel_bg.BackgroundImage = Properties.Resources.day_01;
}
else
{
panel_bg.BackgroundImage = Properties.Resources.day_02;
pic_lampOpen.BackgroundImage = Properties.Resources.switch_off;
}
}, null);
}
catch
{
}
}
private void Environment_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_dataAnalyse_Click(object sender, EventArgs e)
{
try
{
if (btn_dataAnalyse.Text.Equals("数据分析"))
{
//绑定图标数据
chart1.DataSource = SQLBLL.GetEnvironmentGraphData();
//更新图标数据
chart1.DataBind();
chart1.Visible = true;
btn_dataAnalyse.Text = "关闭图表";
}
else if (btn_dataAnalyse.Text.Equals("关闭图表"))
{
chart1.Visible = false;
btn_dataAnalyse.Text = "数据分析";
}
}
catch
{
}
}
private void pic_lampOpen_Click(object sender, EventArgs e)
{
//手动路灯控制
try
{
if (!IsLampOpen)
{
LampOnOff(1, true);
}
else
{
LampOnOff(1, false);
}
IsLampOpen = !IsLampOpen;
}
catch
{
}
}
private void btn_ledEnvironment1_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void btn_ledEnvironment2_Click(object sender, EventArgs e)
{
try
{
//推送LED天气信息
if (ResModel_4017 != null && ResModel_4150 != null)
DeviceCtrlHelper.ledHelper.SendLedString("当前温度:" + ResModel_4017.temperatureValue + "℃ 湿度:" + ResModel_4017.humidityValue + "%");
}
catch
{
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void txt_autoLight_TextChanged(object sender, EventArgs e)
{
try
{
//获取光照比较值
double.TryParse(txt_autoLight.Text,out setLight);
}
catch
{
}
}
private void btn_ledSendMsg_Click(object sender, EventArgs e)
{
try
{
//推送LED信息
DeviceCtrlHelper.ledHelper.SendLedString(txt_ledMsg.Text);
}
catch
{
}
}
private void ch_autoLamp_CheckedChanged(object sender, EventArgs e)
{
//自动控制路灯
IsAuto_Lamp = ch_autoLamp.Checked;
}
private void ch_autoLedFire_CheckedChanged(object sender, EventArgs e)
{
//自动推送火情
IsAuto_FireMsg = ch_autoLedFire.Checked;
}
}
}
+145
View File
@@ -0,0 +1,145 @@
namespace 智慧校园
{
partial class Main
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pic_exit = new System.Windows.Forms.PictureBox();
this.pic_security = new System.Windows.Forms.PictureBox();
this.pic_environment = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(147)))), ((int)(((byte)(237)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1018, 100);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(57, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(197, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel2
//
this.panel2.BackgroundImage = global::智慧校园.Properties.Resources.bg_home;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.pic_exit);
this.panel2.Controls.Add(this.pic_security);
this.panel2.Controls.Add(this.pic_environment);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 100);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1018, 516);
this.panel2.TabIndex = 1;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pic_exit
//
this.pic_exit.BackColor = System.Drawing.Color.Transparent;
this.pic_exit.Image = global::智慧校园.Properties.Resources.icon_04;
this.pic_exit.Location = new System.Drawing.Point(660, 124);
this.pic_exit.Name = "pic_exit";
this.pic_exit.Size = new System.Drawing.Size(180, 210);
this.pic_exit.TabIndex = 6;
this.pic_exit.TabStop = false;
this.pic_exit.Click += new System.EventHandler(this.pic_exit_Click);
//
// pic_security
//
this.pic_security.BackColor = System.Drawing.Color.Transparent;
this.pic_security.Image = global::智慧校园.Properties.Resources.icon_03;
this.pic_security.Location = new System.Drawing.Point(404, 124);
this.pic_security.Name = "pic_security";
this.pic_security.Size = new System.Drawing.Size(180, 210);
this.pic_security.TabIndex = 5;
this.pic_security.TabStop = false;
this.pic_security.Click += new System.EventHandler(this.pic_security_Click);
//
// pic_environment
//
this.pic_environment.BackColor = System.Drawing.Color.Transparent;
this.pic_environment.Image = global::智慧校园.Properties.Resources.icon_02;
this.pic_environment.Location = new System.Drawing.Point(133, 124);
this.pic_environment.Name = "pic_environment";
this.pic_environment.Size = new System.Drawing.Size(180, 210);
this.pic_environment.TabIndex = 4;
this.pic_environment.TabStop = false;
this.pic_environment.Click += new System.EventHandler(this.pic_environment_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 616);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_exit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_security)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_environment)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_exit;
private System.Windows.Forms.PictureBox pic_security;
private System.Windows.Forms.PictureBox pic_environment;
}
}
+72
View File
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
namespace 智慧校园
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pic_environment_Click(object sender, EventArgs e)
{
try
{
new Environment().Show();
}
catch
{
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Main_Load(object sender, EventArgs e)
{
try
{
//实例化工具类
DeviceCtrlHelper.adam4017Helper.Open(AppSet.ADAM4017_COM);
DeviceCtrlHelper.adam4150Helper.Open(AppSet.ADAM4150_COM);
DeviceCtrlHelper.zigBeeHelper.Open(AppSet.ZigBee_COM);
DeviceCtrlHelper.ledHelper.OpenLedCom(AppSet.LED_COM);
}
catch { }
}
private void pic_security_Click(object sender, EventArgs e)
{
try
{
new Security().Show();
}
catch
{
}
}
private void pic_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 智慧校园
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
@@ -0,0 +1,129 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 项目资源(平台素材库)。在"项目资源"里添加或移除,不要手动修改这个文件。
// </auto-generated>
//------------------------------------------------------------------------------
namespace 智慧校园.Properties {
/// <summary>
/// 项目资源:Properties.Resources.资源名
/// </summary>
internal class Resources {
/// <summary>标题:智慧校园</summary>
internal static System.Drawing.Bitmap ico_title {
get { return global::Sim.Host.ProjectResources.Image("ico_title.png"); }
}
/// <summary>主界面背景:校园</summary>
internal static System.Drawing.Bitmap bg_home {
get { return global::Sim.Host.ProjectResources.Image("bg_home.png"); }
}
/// <summary>图标:校园环境</summary>
internal static System.Drawing.Bitmap icon_02 {
get { return global::Sim.Host.ProjectResources.Image("icon_02.png"); }
}
/// <summary>图标:校园安防</summary>
internal static System.Drawing.Bitmap icon_03 {
get { return global::Sim.Host.ProjectResources.Image("icon_03.png"); }
}
/// <summary>图标:退出</summary>
internal static System.Drawing.Bitmap icon_04 {
get { return global::Sim.Host.ProjectResources.Image("icon_04.png"); }
}
/// <summary>路灯场景:亮灯</summary>
internal static System.Drawing.Bitmap day_01 {
get { return global::Sim.Host.ProjectResources.Image("day_01.png"); }
}
/// <summary>路灯场景:灭灯</summary>
internal static System.Drawing.Bitmap day_02 {
get { return global::Sim.Host.ProjectResources.Image("day_02.png"); }
}
/// <summary>面板背景(窄)</summary>
internal static System.Drawing.Bitmap bg_from2 {
get { return global::Sim.Host.ProjectResources.Image("bg_from2.png"); }
}
/// <summary>开关:开</summary>
internal static System.Drawing.Bitmap switch_on {
get { return global::Sim.Host.ProjectResources.Image("switch_on.png"); }
}
/// <summary>开关:关</summary>
internal static System.Drawing.Bitmap switch_off {
get { return global::Sim.Host.ProjectResources.Image("switch_off.png"); }
}
/// <summary>监控:无画面</summary>
internal static System.Drawing.Bitmap icon_monitor {
get { return global::Sim.Host.ProjectResources.Image("icon_monitor.png"); }
}
/// <summary>监控:方向盘底座</summary>
internal static System.Drawing.Bitmap panel_video_ctrl {
get { return global::Sim.Host.ProjectResources.Image("panel_video_ctrl.png"); }
}
/// <summary>方向键:上</summary>
internal static System.Drawing.Bitmap btn_arrow_up_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_normal.png"); }
}
/// <summary>方向键:上(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_up_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_up_press.png"); }
}
/// <summary>方向键:下</summary>
internal static System.Drawing.Bitmap btn_arrow_down_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_normal.png"); }
}
/// <summary>方向键:下(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_down_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_down_press.png"); }
}
/// <summary>方向键:左</summary>
internal static System.Drawing.Bitmap btn_arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_normal.png"); }
}
/// <summary>方向键:左(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_left_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_left_press.png"); }
}
/// <summary>方向键:右</summary>
internal static System.Drawing.Bitmap btn_arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_normal.png"); }
}
/// <summary>方向键:右(按下)</summary>
internal static System.Drawing.Bitmap btn_arrow_right_press {
get { return global::Sim.Host.ProjectResources.Image("btn_arrow_right_press.png"); }
}
/// <summary>翻页:上一张</summary>
internal static System.Drawing.Bitmap arrow_left_normal {
get { return global::Sim.Host.ProjectResources.Image("arrow_left_normal.png"); }
}
/// <summary>翻页:下一张</summary>
internal static System.Drawing.Bitmap arrow_right_normal {
get { return global::Sim.Host.ProjectResources.Image("arrow_right_normal.png"); }
}
/// <summary>关闭按钮</summary>
internal static System.Drawing.Bitmap windowstate_closed_hover {
get { return global::Sim.Host.ProjectResources.Image("windowstate_closed_hover.png"); }
}
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLBLL
{
public static SQLRes SecurityUpData(Image img)//把图片保存到数据库
{
SQLRes sqlRes = new SQLRes();
byte[] imgByte = null;
using (MemoryStream ms = new MemoryStream())//图片转换为二进制数组
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imgByte = new byte[ms.Length];
imgByte = ms.ToArray();
}
string sqlStr = "INSERT INTO SecurityData (EvenTime,EvenImage) VALUES (@time,@img)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("img", imgByte) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static Dictionary<string, Image> GetSecurityData(DateTime startDate, DateTime endDate)
{
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
if (string.IsNullOrWhiteSpace(startDate.Month.ToString()) && string.IsNullOrWhiteSpace(endDate.Month .ToString()))
{
return ImgDictionary;
}
//选择查询日期日期
string sql = "SELECT * FROM SecurityData WHERE EvenTime between @time_start and @time_end";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time_start", startDate.Year + "/" + startDate.Month + "/" + startDate.Day), new SqlParameter("time_end", endDate.Year + "/" + endDate.Month + "/" + endDate.Day+" 23:59:59" )};
DataSet ds = SQLHelper.getData(sql, sqlParameter);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ImgDictionary.Add(ds.Tables[0].Rows[i]["EvenTime"].ToString(), Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i]["EvenImage"])));
}
return ImgDictionary;
}
public static SQLRes EnvironmentUpData(bool fire, bool smoke, string light, string temperature, string humidity)
{
SQLRes sqlRes = new SQLRes();
string sqlStr = "INSERT INTO EnvironmentData (Fire ,Smoke ,Temperature ,Humidity , Light, _Time) VALUES (@fire,@smoke,@temperature,@humidity,@light,@time)";
SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("time", DateTime.Now.ToString()), new SqlParameter("fire", fire), new SqlParameter("smoke", smoke), new SqlParameter("temperature", temperature), new SqlParameter("humidity", humidity), new SqlParameter("light", light) };
if (SQLHelper.Exec(sqlStr, sqlParameter) >= 1)
{
sqlRes.Result = true;
sqlRes.Msg = "成功!";
}
else
{
sqlRes.Result = false;
sqlRes.Msg = "失败!";
}
return sqlRes;
}
public static DataTable GetEnvironmentGraphData()
{
string sqlStr = "SELECT TOP 7 CONVERT(varchar(10),_Time,120) AS _Time, ROUND(Max(Temperature),2) AS MaxTemperature, ROUND(AVG(Temperature),2) AS AVGTemperature FROM EnvironmentData GROUP BY CONVERT(varchar(10),_Time,120) ORDER BY CONVERT(varchar(10),_Time,120) DESC ";
return SQLHelper.getData(sqlStr, null).Tables[0];
}
}
class SQLRes
{
public string Msg { get; set; }
public bool Result { get; set; }
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智慧校园.SQLHelpers
{
class SQLHelper
{
public static string strConn = AppSet.SqlConn;
public static bool SaveData(string sql, DataTable dt)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(sda);
sda.Update(dt);
conn.Close();
return true;
}
catch (Exception e)
{
string Error = e.Message;
return false;
}
}
public static DataSet getData(string sql, params SqlParameter[] para)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch(Exception e)
{
string Error = e.Message;
}
return ds;
}
public static DataSet getData(SqlCommand cmd)
{
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
cmd.Parameters.Clear();
conn.Close();
}
catch (Exception e)
{
string Error = e.Message;
}
return ds;
}
public static int Exec(string sql, params SqlParameter[] para)
{
try
{
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
if (para != null)
{
foreach (SqlParameter item in para)
{
cmd.Parameters.Add(item);
}
}
int iRsult = cmd.ExecuteNonQuery();
conn.Close();
return iRsult;
}
catch (Exception e)
{
string Error = e.Message;
return -1;
}
}
}
}
+297
View File
@@ -0,0 +1,297 @@
namespace 智慧校园
{
partial class Security
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel3 = new System.Windows.Forms.Panel();
this.lb_return = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel_bg_video = new System.Windows.Forms.Panel();
this.btn_history = new System.Windows.Forms.Button();
this.btn_camera = new System.Windows.Forms.Button();
this.panel_video_ctrl = new System.Windows.Forms.Panel();
this.pic_left = new System.Windows.Forms.PictureBox();
this.pic_right = new System.Windows.Forms.PictureBox();
this.pic_down = new System.Windows.Forms.PictureBox();
this.pic_up = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.lb_infrared = new System.Windows.Forms.Label();
this.pic_video = new System.Windows.Forms.PictureBox();
this.panel3.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel_bg_video.SuspendLayout();
this.panel_video_ctrl.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_left)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).BeginInit();
this.SuspendLayout();
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel3.Controls.Add(this.lb_return);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 100);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1081, 39);
this.panel3.TabIndex = 1;
//
// lb_return
//
this.lb_return.AutoSize = true;
this.lb_return.Location = new System.Drawing.Point(25, 12);
this.lb_return.Name = "lb_return";
this.lb_return.Size = new System.Drawing.Size(83, 12);
this.lb_return.TabIndex = 0;
this.lb_return.Text = "< 返回主窗体";
this.lb_return.Click += new System.EventHandler(this.lb_return_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1081, 100);
this.panel1.TabIndex = 2;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// pictureBox1
//
this.pictureBox1.Image = global::智慧校园.Properties.Resources.ico_title;
this.pictureBox1.Location = new System.Drawing.Point(44, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(226, 54);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panel_bg_video
//
this.panel_bg_video.BackColor = System.Drawing.Color.White;
this.panel_bg_video.Controls.Add(this.btn_history);
this.panel_bg_video.Controls.Add(this.btn_camera);
this.panel_bg_video.Controls.Add(this.panel_video_ctrl);
this.panel_bg_video.Controls.Add(this.panel2);
this.panel_bg_video.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_bg_video.Location = new System.Drawing.Point(0, 139);
this.panel_bg_video.Name = "panel_bg_video";
this.panel_bg_video.Size = new System.Drawing.Size(1081, 499);
this.panel_bg_video.TabIndex = 3;
this.panel_bg_video.Paint += new System.Windows.Forms.PaintEventHandler(this.panel_bg_video_Paint);
//
// btn_history
//
this.btn_history.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(213)))), ((int)(((byte)(122)))));
this.btn_history.Font = new System.Drawing.Font("微软雅黑", 14F);
this.btn_history.Location = new System.Drawing.Point(804, 410);
this.btn_history.Name = "btn_history";
this.btn_history.Size = new System.Drawing.Size(160, 49);
this.btn_history.TabIndex = 10;
this.btn_history.Text = "查看历史图像";
this.btn_history.UseVisualStyleBackColor = false;
this.btn_history.Click += new System.EventHandler(this.btn_history_Click);
//
// btn_camera
//
this.btn_camera.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(200)))), ((int)(((byte)(81)))));
this.btn_camera.Font = new System.Drawing.Font("微软雅黑", 16F);
this.btn_camera.Location = new System.Drawing.Point(804, 326);
this.btn_camera.Name = "btn_camera";
this.btn_camera.Size = new System.Drawing.Size(160, 49);
this.btn_camera.TabIndex = 9;
this.btn_camera.Text = "拍照";
this.btn_camera.UseVisualStyleBackColor = false;
this.btn_camera.Click += new System.EventHandler(this.btn_camera_Click);
//
// panel_video_ctrl
//
this.panel_video_ctrl.BackgroundImage = global::智慧校园.Properties.Resources.panel_video_ctrl;
this.panel_video_ctrl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel_video_ctrl.Controls.Add(this.pic_left);
this.panel_video_ctrl.Controls.Add(this.pic_right);
this.panel_video_ctrl.Controls.Add(this.pic_down);
this.panel_video_ctrl.Controls.Add(this.pic_up);
this.panel_video_ctrl.Location = new System.Drawing.Point(741, 15);
this.panel_video_ctrl.Name = "panel_video_ctrl";
this.panel_video_ctrl.Size = new System.Drawing.Size(328, 294);
this.panel_video_ctrl.TabIndex = 1;
//
// pic_left
//
this.pic_left.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_left_normal;
this.pic_left.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_left.Location = new System.Drawing.Point(63, 116);
this.pic_left.Name = "pic_left";
this.pic_left.Size = new System.Drawing.Size(39, 54);
this.pic_left.TabIndex = 6;
this.pic_left.TabStop = false;
this.pic_left.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseDown);
this.pic_left.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_left_MouseUp);
//
// pic_right
//
this.pic_right.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_right_normal;
this.pic_right.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_right.Location = new System.Drawing.Point(223, 116);
this.pic_right.Name = "pic_right";
this.pic_right.Size = new System.Drawing.Size(39, 54);
this.pic_right.TabIndex = 5;
this.pic_right.TabStop = false;
this.pic_right.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseDown);
this.pic_right.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_right_MouseUp);
//
// pic_down
//
this.pic_down.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_down_normal;
this.pic_down.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_down.Location = new System.Drawing.Point(143, 202);
this.pic_down.Name = "pic_down";
this.pic_down.Size = new System.Drawing.Size(39, 54);
this.pic_down.TabIndex = 4;
this.pic_down.TabStop = false;
this.pic_down.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseDown);
this.pic_down.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_down_MouseUp);
//
// pic_up
//
this.pic_up.BackgroundImage = global::智慧校园.Properties.Resources.btn_arrow_up_normal;
this.pic_up.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pic_up.Location = new System.Drawing.Point(142, 20);
this.pic_up.Name = "pic_up";
this.pic_up.Size = new System.Drawing.Size(39, 54);
this.pic_up.TabIndex = 1;
this.pic_up.TabStop = false;
this.pic_up.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseDown);
this.pic_up.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pic_up_MouseUp);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.DimGray;
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.lb_infrared);
this.panel2.Controls.Add(this.pic_video);
this.panel2.Location = new System.Drawing.Point(69, 15);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(666, 472);
this.panel2.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Location = new System.Drawing.Point(545, 91);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 21);
this.label2.TabIndex = 12;
this.label2.Text = "入侵:";
//
// lb_infrared
//
this.lb_infrared.AutoSize = true;
this.lb_infrared.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_infrared.ForeColor = System.Drawing.Color.White;
this.lb_infrared.Location = new System.Drawing.Point(597, 91);
this.lb_infrared.Name = "lb_infrared";
this.lb_infrared.Size = new System.Drawing.Size(41, 21);
this.lb_infrared.TabIndex = 11;
this.lb_infrared.Text = "N/A";
//
// pic_video
//
this.pic_video.BackColor = System.Drawing.Color.DarkGray;
this.pic_video.BackgroundImage = global::智慧校园.Properties.Resources.icon_monitor;
this.pic_video.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pic_video.Location = new System.Drawing.Point(32, 38);
this.pic_video.Name = "pic_video";
this.pic_video.Size = new System.Drawing.Size(478, 322);
this.pic_video.TabIndex = 0;
this.pic_video.TabStop = false;
this.pic_video.Click += new System.EventHandler(this.pictureBox2_Click);
//
// Security
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1081, 638);
this.Controls.Add(this.panel_bg_video);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Security";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Security";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Security_FormClosed);
this.Load += new System.EventHandler(this.Security_Load);
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel_bg_video.ResumeLayout(false);
this.panel_video_ctrl.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pic_left)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_right)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_video)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lb_return;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Panel panel_bg_video;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pic_video;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lb_infrared;
private System.Windows.Forms.Button btn_history;
private System.Windows.Forms.Button btn_camera;
private System.Windows.Forms.Panel panel_video_ctrl;
private System.Windows.Forms.PictureBox pic_left;
private System.Windows.Forms.PictureBox pic_right;
private System.Windows.Forms.PictureBox pic_down;
private System.Windows.Forms.PictureBox pic_up;
}
}
+252
View File
@@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using DeviceCtrlLibrary;
using 智慧校园.SQLHelpers;
namespace 智慧校园
{
public partial class Security : Form
{ //显示图像
Image img = null;
//入侵标识
bool IsInfrared = false;
//图像文件夹路径
string ImgDir = AppDomain.CurrentDomain.BaseDirectory + "Camera\\";
//用于数据采集和SQL操作
Thread thread;
SynchronizationContext _main;
public Security()
{
InitializeComponent();
}
void ipCameraHelper_ImageRead(ImageReadEvenArgs e)
{
img = e.img;
pic_video.Image = e.img;
}
void tick()
{
try
{
while (true)
{
try
{
//采集入侵状态
IsInfrared = DeviceCtrlHelper.adam4150Helper.SetData().infraredValue;
//UI显示入侵状态
_main.Send(_ =>
{
lb_infrared.Text = IsInfrared ? "发现入侵" : "正常";
}, null);
if (IsInfrared)
{
if (img != null)
//上传报警信息
SQLBLL.SecurityUpData(img);
}
}
catch
{
}
Thread.Sleep(1000);
}
}
catch
{
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel_bg_video_Paint(object sender, PaintEventArgs e)
{
}
private void Security_Load(object sender, EventArgs e)
{
try
{
//实例化摄像头控制类
DeviceCtrlHelper.ipCameraHelper.Open(AppSet.Camera_Ip, AppSet.Camera_Uid, AppSet.Camera_Pwd);
DeviceCtrlHelper.ipCameraHelper.ImageRead += ipCameraHelper_ImageRead;
DeviceCtrlHelper.ipCameraHelper.Start();
thread = new Thread(new ThreadStart(tick));
_main = WindowsFormsSynchronizationContext.Current;
thread.Start();
if (!Directory.Exists(ImgDir))
//创建文件夹
Directory.CreateDirectory(ImgDir);
}
catch
{
}
}
private void Security_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
DeviceCtrlHelper.ipCameraHelper.Stop();
DeviceCtrlHelper.ipCameraHelper.Close();
thread.Suspend();
thread = null;
}
catch
{
}
}
private void btn_camera_Click(object sender, EventArgs e)
{
try
{
pic_video.Image.Save(ImgDir + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg");
SQLBLL.SecurityUpData(pic_video.Image);
}
catch
{
}
}
private void btn_history_Click(object sender, EventArgs e)
{
try
{
new SecurityCameraData().ShowDialog();
}
catch
{
}
}
private void pic_up_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_press;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_up_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_up.BackgroundImage = Properties.Resources.btn_arrow_up_normal;
DeviceCtrlHelper.ipCameraHelper.PanUp();
}
catch
{
}
}
private void pic_down_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_press;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_down_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_down.BackgroundImage = Properties.Resources.btn_arrow_down_normal;
DeviceCtrlHelper.ipCameraHelper.PanDown();
}
catch
{
}
}
private void pic_left_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_press;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_left_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_left.BackgroundImage = Properties.Resources.btn_arrow_left_normal;
DeviceCtrlHelper.ipCameraHelper.PanLeft();
}
catch
{
}
}
private void pic_right_MouseDown(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_press;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void pic_right_MouseUp(object sender, MouseEventArgs e)
{
try
{
pic_right.BackgroundImage = Properties.Resources.btn_arrow_right_normal;
DeviceCtrlHelper.ipCameraHelper.PanRight();
}
catch
{
}
}
private void lb_return_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
+246
View File
@@ -0,0 +1,246 @@
namespace 智慧校园
{
partial class SecurityCameraData
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pic_close = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.panel_toolBar = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.btn_get = new System.Windows.Forms.Button();
this.lb_noData = new System.Windows.Forms.Label();
this.lb_time = new System.Windows.Forms.Label();
this.pic_down = new System.Windows.Forms.PictureBox();
this.pic_up = new System.Windows.Forms.PictureBox();
this.pic_camera = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_close)).BeginInit();
this.panel_toolBar.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic_camera)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(116)))), ((int)(((byte)(133)))));
this.panel1.Controls.Add(this.pic_close);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(835, 53);
this.panel1.TabIndex = 0;
//
// pic_close
//
this.pic_close.BackgroundImage = global::智慧校园.Properties.Resources.windowstate_closed_hover;
this.pic_close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pic_close.Location = new System.Drawing.Point(789, 6);
this.pic_close.Name = "pic_close";
this.pic_close.Size = new System.Drawing.Size(36, 42);
this.pic_close.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pic_close.TabIndex = 1;
this.pic_close.TabStop = false;
this.pic_close.Click += new System.EventHandler(this.pictureBox1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(12, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(129, 20);
this.label1.TabIndex = 0;
this.label1.Text = "历史报警记录";
//
// panel_toolBar
//
this.panel_toolBar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(229)))), ((int)(((byte)(229)))));
this.panel_toolBar.Controls.Add(this.label2);
this.panel_toolBar.Controls.Add(this.label3);
this.panel_toolBar.Controls.Add(this.dateTimePicker2);
this.panel_toolBar.Controls.Add(this.dateTimePicker1);
this.panel_toolBar.Controls.Add(this.btn_get);
this.panel_toolBar.Location = new System.Drawing.Point(0, 53);
this.panel_toolBar.Name = "panel_toolBar";
this.panel_toolBar.Size = new System.Drawing.Size(835, 56);
this.panel_toolBar.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(364, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 19;
this.label2.Text = "结束时间";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(88, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 18;
this.label3.Text = "开始时间";
//
// dateTimePicker2
//
this.dateTimePicker2.Location = new System.Drawing.Point(423, 18);
this.dateTimePicker2.Name = "dateTimePicker2";
this.dateTimePicker2.Size = new System.Drawing.Size(200, 21);
this.dateTimePicker2.TabIndex = 17;
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(147, 18);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(200, 21);
this.dateTimePicker1.TabIndex = 16;
//
// btn_get
//
this.btn_get.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(203)))), ((int)(((byte)(81)))));
this.btn_get.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_get.Location = new System.Drawing.Point(660, 12);
this.btn_get.Name = "btn_get";
this.btn_get.Size = new System.Drawing.Size(75, 32);
this.btn_get.TabIndex = 15;
this.btn_get.Text = "查询";
this.btn_get.UseVisualStyleBackColor = false;
this.btn_get.Click += new System.EventHandler(this.btn_get_Click);
//
// lb_noData
//
this.lb_noData.AutoSize = true;
this.lb_noData.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.lb_noData.Font = new System.Drawing.Font("宋体", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_noData.ForeColor = System.Drawing.Color.Red;
this.lb_noData.Location = new System.Drawing.Point(259, 320);
this.lb_noData.Name = "lb_noData";
this.lb_noData.Size = new System.Drawing.Size(252, 64);
this.lb_noData.TabIndex = 3;
this.lb_noData.Text = "NO DATA";
//
// lb_time
//
this.lb_time.AutoSize = true;
this.lb_time.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.lb_time.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_time.ForeColor = System.Drawing.Color.Red;
this.lb_time.Location = new System.Drawing.Point(527, 539);
this.lb_time.Name = "lb_time";
this.lb_time.Size = new System.Drawing.Size(40, 16);
this.lb_time.TabIndex = 4;
this.lb_time.Text = "TIME";
//
// pic_down
//
this.pic_down.Image = global::智慧校园.Properties.Resources.arrow_right_normal;
this.pic_down.Location = new System.Drawing.Point(668, 138);
this.pic_down.Name = "pic_down";
this.pic_down.Size = new System.Drawing.Size(67, 479);
this.pic_down.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pic_down.TabIndex = 6;
this.pic_down.TabStop = false;
this.pic_down.Click += new System.EventHandler(this.pic_down_Click);
//
// pic_up
//
this.pic_up.Image = global::智慧校园.Properties.Resources.arrow_left_normal;
this.pic_up.Location = new System.Drawing.Point(49, 138);
this.pic_up.Name = "pic_up";
this.pic_up.Size = new System.Drawing.Size(67, 479);
this.pic_up.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pic_up.TabIndex = 5;
this.pic_up.TabStop = false;
this.pic_up.Click += new System.EventHandler(this.pic_up_Click);
//
// pic_camera
//
this.pic_camera.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.pic_camera.Location = new System.Drawing.Point(49, 138);
this.pic_camera.Name = "pic_camera";
this.pic_camera.Size = new System.Drawing.Size(686, 479);
this.pic_camera.TabIndex = 2;
this.pic_camera.TabStop = false;
//
// SecurityCameraData
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(835, 629);
this.Controls.Add(this.pic_down);
this.Controls.Add(this.pic_up);
this.Controls.Add(this.lb_time);
this.Controls.Add(this.lb_noData);
this.Controls.Add(this.pic_camera);
this.Controls.Add(this.panel_toolBar);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "SecurityCameraData";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SecurityCameraData";
this.Load += new System.EventHandler(this.SecurityCameraData_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_close)).EndInit();
this.panel_toolBar.ResumeLayout(false);
this.panel_toolBar.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pic_down)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_up)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic_camera)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pic_close;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel_toolBar;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DateTimePicker dateTimePicker2;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Button btn_get;
private System.Windows.Forms.PictureBox pic_camera;
private System.Windows.Forms.Label lb_noData;
private System.Windows.Forms.Label lb_time;
private System.Windows.Forms.PictureBox pic_up;
private System.Windows.Forms.PictureBox pic_down;
}
}
@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceCtrlLibrary;
using 智慧校园.SQLHelpers;
namespace 智慧校园
{
public partial class SecurityCameraData : Form
{
public SecurityCameraData()
{
InitializeComponent();
}
//存放报警信息的集合
Dictionary<string, Image> ImgDictionary = new Dictionary<string, Image>();
//图片下标
int index = -1;
Image img;
//KEY的列表(报警时间为KEY)
List<string> Keys = new List<string>();
private void SecurityCameraData_Load(object sender, EventArgs e)
{
try
{
//设置父容器
pic_up.Parent = pic_camera;
pic_down.Parent = pic_camera;
//设置加载坐标
pic_up.Location = new Point(20, 0);
pic_down.Location = new Point(560, 0);
GetData();
}
catch
{
}
}
//更新数据
private void GetData()
{
try
{
DateTime startdt = dateTimePicker1.Value;
DateTime enddt = dateTimePicker2.Value;
ImgDictionary = SQLBLL.GetSecurityData(startdt, enddt);
index = -1;
Keys.Clear();
if (ImgDictionary.Count != 0)
lb_noData.Visible = false;
else
{
lb_noData.Visible = true;
return;
}
foreach (string key in ImgDictionary.Keys)
{
Keys.Add(key);
}
ImageChanged();
}
catch
{
}
}
//切换图片
private void ImageChanged(char UpOrDown = '+')
{
try
{
if (ImgDictionary.Count == 0)
return;
if (UpOrDown == '+')
index++;
else if (UpOrDown == '-')
index--;
if (index == ImgDictionary.Count)
index = 0;
if (index == -1)
index = ImgDictionary.Count - 1;
ImgDictionary.TryGetValue(Keys[index], out img);
pic_camera.Image = img;
lb_time.Text = Keys[index];
}
catch
{
}
}
private void btn_get_Click(object sender, EventArgs e)
{
try
{
GetData();
}
catch
{
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Close();
}
private void pic_up_Click(object sender, EventArgs e)
{
ImageChanged('-');
}
private void pic_down_Click(object sender, EventArgs e)
{
ImageChanged();
}
}
}
+55
View File
@@ -0,0 +1,55 @@
# 评分规则:书上评价表的功能项。每项单独启动一次程序,按步骤操作,核对结果。
# 格式说明见 server/src/grading/checks.ts
# 先拨虚拟时钟再拍照,照片的时间就是确定的(9:00:00、10:30:00 左右)。
- title: 能查看拍下的历史照片
steps:
- clock: '09:00:00'
- click: pic_security
- expect: { control: pic_video, image: true, within: 3s }
- click: btn_camera
- click: btn_history
- expect: { window: SecurityCameraData, desc: 点"查看历史图像"打开历史报警记录窗体 }
- expect: { control: pic_camera, image: true, desc: 显示今天拍的照片 }
- expect: { control: lb_noData, visible: false, desc: 有照片时不显示"NO DATA" }
- expect: { control: lb_time, contains: ' 9:00:0', desc: 显示照片的拍摄时间 }
- title: 照片能根据图片按钮切换
steps:
- clock: '09:00:00'
- click: pic_security
- expect: { control: pic_video, image: true, within: 3s }
- click: btn_camera
- clock: '10:30:00'
- click: btn_camera
- click: btn_history
- expect: { control: lb_time, contains: ' 9:00:0', desc: 先显示第一张照片 }
- click: pic_down
- expect: { control: lb_time, contains: '10:30:0', desc: 点右箭头显示下一张 }
- click: pic_down
- expect: { control: lb_time, contains: ' 9:00:0', desc: 最后一张再往后回到第一张 }
- click: pic_up
- expect: { control: lb_time, contains: '10:30:0', desc: 点左箭头显示上一张 }
- title: 能正确查找时间段内的历史图片
steps:
- clock: '09:00:00'
- click: pic_security
- expect: { control: pic_video, image: true, within: 3s }
- click: btn_camera
- click: btn_history
- pick: { control: dateTimePicker1, value: '2024-01-01' }
- click: btn_get
- expect: { control: lb_noData, visible: false, desc: 2024-01-01 到今天之间有照片 }
- expect: { control: lb_time, contains: ' 9:00:0' }
- pick: { control: dateTimePicker2, value: '2024-01-31' }
- click: btn_get
- expect: { control: lb_noData, visible: true, desc: 2024 年 1 月没有照片,显示"NO DATA" }
- title: 能关闭历史报警记录窗体
steps:
- click: pic_security
- click: btn_history
- expect: { window: SecurityCameraData }
- click: pic_close
- expect: { window: SecurityCameraData, open: false }
- expect: { window: Security, desc: 回到校园安防窗体 }
+54
View File
@@ -0,0 +1,54 @@
-- 实验的初始数据库 WisdomCampus(教材"综合实训"附带的库):环境数据表 EnvironmentData、报警图片表 SecurityData、用户表 Users。
-- EnvironmentData 预置了 7 天的历史数据,"数据分析"的图表一打开就有内容;SecurityData 是空的,拍照或有人入侵时才有记录。
-- 学生可以在数据库页面"恢复实验初始数据";评分时每个检查项用一份新的。
CREATE DATABASE WisdomCampus
GO
USE WisdomCampus
GO
CREATE TABLE Users (Id int IDENTITY(1,1) PRIMARY KEY, UserName nvarchar(50) NOT NULL, Password nvarchar(50) NOT NULL)
CREATE TABLE EnvironmentData (Id int IDENTITY(1,1) PRIMARY KEY, Fire bit NOT NULL, Smoke bit NOT NULL, Temperature float NULL, Humidity float NULL, Light float NULL, _Time datetime NOT NULL)
CREATE TABLE SecurityData (Id int IDENTITY(1,1) PRIMARY KEY, EvenTime datetime NOT NULL, EvenImage image NOT NULL)
GO
INSERT INTO Users (UserName, Password) VALUES ('admin', '123')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 58, 258, '2026-10-14 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.1, 53, 475, '2026-10-14 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 761, '2026-10-14 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.5, 49, 733, '2026-10-14 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 54, 528, '2026-10-14 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 283, '2026-10-14 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.9, 59, 261, '2026-10-15 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 53, 499, '2026-10-15 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 764, '2026-10-15 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.5, 47, 778, '2026-10-15 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.8, 52, 503, '2026-10-15 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 56, 218, '2026-10-15 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 13.9, 63, 258, '2026-10-16 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 60, 477, '2026-10-16 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.8, 51, 741, '2026-10-16 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.5, 54, 796, '2026-10-16 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 488, '2026-10-16 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.6, 59, 214, '2026-10-16 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 11.9, 67, 234, '2026-10-17 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 63, 544, '2026-10-17 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.3, 60, 804, '2026-10-17 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.5, 54, 801, '2026-10-17 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.8, 59, 524, '2026-10-17 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.1, 58, 286, '2026-10-17 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 16.4, 59, 250, '2026-10-18 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.6, 55, 533, '2026-10-18 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.3, 50, 749, '2026-10-18 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 24, 48, 766, '2026-10-18 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.8, 54, 534, '2026-10-18 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.1, 53, 241, '2026-10-18 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.4, 54, 253, '2026-10-19 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.1, 50, 474, '2026-10-19 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 22.3, 48, 778, '2026-10-19 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 26, 46, 783, '2026-10-19 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 23.3, 50, 520, '2026-10-19 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 20.6, 50, 213, '2026-10-19 18:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 15.9, 62, 230, '2026-10-20 08:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 18.6, 52, 471, '2026-10-20 10:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 53, 751, '2026-10-20 12:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 21.5, 48, 747, '2026-10-20 14:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 19.3, 55, 527, '2026-10-20 16:00:00')
INSERT INTO EnvironmentData (Fire, Smoke, Temperature, Humidity, Light, _Time) VALUES (0, 0, 17.1, 57, 220, '2026-10-20 18:00:00')
+4
View File
@@ -0,0 +1,4 @@
{
"title": "项目8 任务5 实现\"校园安防\"模块中显示历史图片的功能",
"source": "教材书 p181–185,界面和代码取自配套参考工程;图片是平台素材库里自绘的同名素材(尺寸和教材一致);每次查询前清空 Keys(书上没清空,重复查询时照片和时间对不上)"
}