项目 8 智慧校园管理平台:5 个任务的示例、自绘素材、WisdomCampus 数据库
- 示例 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:
1 parent
b20db5721e
commit
65a1b3a81e
109 files changed
+7807
-9
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user