资源简介
C#开发,用于采集一些设备的电流,电压信息,图形化界面,用devexpress开发,可以校准
代码片段和文件信息
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.Ports;
using ZedGraph;
using System.Threading;
using System.Collections;
namespace DC_POWER
{
public partial class Mainform : Form
{
private const float VOLTAGE_MAX = 30.00f CURRENT_MAX = 4.000f;
public enum MODE
{
MODE_VOLTAGE = 0x00
MODE_CURRENT = 0x01
}
private MODE currentMode = MODE.MODE_VOLTAGE;
//与下位机通讯相关
public enum COM_CMD
{
//M2S: master to slave cmd S2M: slave to master
USART_M2S_Output = 0x01 //输出控制(默认关)
USART_M2S_Mode = 0x02 //输出模式切换(默认电压模式)
USART_M2S_SetVal = 0x03 //Master2Slave设置期望值:[1-4]:电压; [5-8]:电流
USART_M2S_Cal = 0x04 //进入校准模式(只在下位机开机前几秒内能够进入校准模式)
USART_M2S_StepAdd = 0x05 //步进加
USART_M2S_StepSub = 0x06 //步进减
USART_M2S_FAN = 0x07 //风扇控制:[1]0关;1开;2自动(默认)
USART_M2S_STATE = 0x08 //实时数据发送状态:[1]1发送数据 0停止发送
USART_M2S_GetVal = 0x09 //获取前一次的设定值
USART_S2M_PreVal = 0x0A //Slave2Master返回前一次的设定值:[1-4]:电压值; [5-8]:电流值
USART_S2M_RealVal = 0x0B //Slave2Master返回的实际值:[1-4]:电压值; [5-8]:电流值
USART_S2M_RealTemp= 0x0C //Slave2Master返回温度值:[1-4]:当前温度值
}
private const byte USART_frameHEAD = 0xAA USART_frametaIL = 0x55 USART_frameCTRL = 0xA5;
private long m_TotalRxLostPackages = 0; //记录总的丢包数
private long m_RxPackageDataCount = 0; //记录接收到的一帧的字节数
private const int m_MaxPackageSize = 4096; //一帧最大的字节数
private byte[] m_pRxBuf = new byte[m_MaxPackageSize]; //接收缓存
float voltageSet = 0.0f currentSet = 0.0f voltageGet = 0.0f currentGet = 0.0f;
//绘图相关
public struct CurveStruct
{
public PointPairList pointList;//曲线数据
public Color lineColor;//曲线颜色
public SymbolType linestyle;//线型
public string curveName;//名称
public LineItem curve; //曲线
public float scaleFactor;//比例系数
public byte lineWidth; //线宽
}
private Hashtable curveHashTable = new Hashtable();//用来保存所有的曲线
private GraphPane mGraphPane;
private long tickStart = 0;
double currentTime;
//double previousTime = 0;
CurveStruct mCurveStructVolSet = new CurveStruct();
CurveStruct mCurveStructVolGet = new CurveStruct();
CurveStruct mCurveStructCurSet = new CurveStruct();
CurveStruct mCurveStructCurGet = new CurveStruct();
//线程相关
private Queue receiveByteQueue = new Queue();//串口缓存队列
private Thread _dataParseThread = null; //解析串口接收数据线程
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2014-07-15 10:30 DC_POWER\DC_POWER\App.config
文件 151552 2014-07-15 14:36 DC_POWER\DC_POWER\bin\Debug\DC_POWER.exe
文件 187 2014-07-15 10:30 DC_POWER\DC_POWER\bin\Debug\DC_POWER.exe.config
文件 26112 2014-07-15 14:36 DC_POWER\DC_POWER\bin\Debug\DC_POWER.pdb
文件 22984 2014-07-15 14:36 DC_POWER\DC_POWER\bin\Debug\DC_POWER.vshost.exe
文件 187 2014-07-15 10:30 DC_POWER\DC_POWER\bin\Debug\DC_POWER.vshost.exe.config
文件 36864 2007-03-13 14:40 DC_POWER\DC_POWER\bin\Debug\EnhancedGlassButton.dll
文件 67646 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_128.ico
文件 1150 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_16.ico
文件 2462 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_24.ico
文件 4286 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_32.ico
文件 9662 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_48.ico
文件 16958 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Debug\ICON\POWER_64.ico
文件 9662 2010-11-14 11:45 DC_POWER\DC_POWER\bin\Debug\ICON\shutdown.ico
文件 9662 2010-11-14 11:45 DC_POWER\DC_POWER\bin\Debug\ICON\standby.ico
文件 13824 2013-08-27 02:04 DC_POWER\DC_POWER\bin\Debug\Knob.dll
文件 57344 2014-07-15 11:59 DC_POWER\DC_POWER\bin\Debug\LBIndustrialCtrls.dll
文件 36864 2007-07-08 07:56 DC_POWER\DC_POWER\bin\Debug\Manometers.dll
文件 329728 2013-10-07 23:09 DC_POWER\DC_POWER\bin\Debug\System.Windows.Forms.Ribbon35.dll
文件 307200 2008-12-12 16:01 DC_POWER\DC_POWER\bin\Debug\ZedGraph.dll
文件 224768 2014-07-16 16:45 DC_POWER\DC_POWER\bin\Release\DC_POWER.exe
文件 187 2014-07-15 10:30 DC_POWER\DC_POWER\bin\Release\DC_POWER.exe.config
文件 56832 2014-07-16 16:45 DC_POWER\DC_POWER\bin\Release\DC_POWER.pdb
文件 22984 2014-07-16 16:46 DC_POWER\DC_POWER\bin\Release\DC_POWER.vshost.exe
文件 187 2014-07-15 10:30 DC_POWER\DC_POWER\bin\Release\DC_POWER.vshost.exe.config
文件 490 2012-06-06 02:06 DC_POWER\DC_POWER\bin\Release\DC_POWER.vshost.exe.manifest
文件 36864 2007-03-13 14:40 DC_POWER\DC_POWER\bin\Release\EnhancedGlassButton.dll
文件 67646 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Release\ICON\POWER_128.ico
文件 1150 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Release\ICON\POWER_16.ico
文件 2462 2014-07-15 10:42 DC_POWER\DC_POWER\bin\Release\ICON\POWER_24.ico
............此处省略139个文件信息
评论
共有 条评论