1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Text;
- using System.Windows.Forms;
- using System.Xml.Serialization;
- using System.Text.RegularExpressions;
- using System.Net;
- using System.Reflection;
- using NPOI;
- using NPOI.SS.UserModel;
- using NPOI.HSSF.UserModel;
- using Spire.Xls;
- using Workbook = Spire.Xls.Workbook;
- namespace MOTINOVA_Motor_Factory_Set
- {
- public partial class ExportForm : Form
- {
- //参数按照字典类型存储
- Dictionary<string, UInt16> Params1 = new Dictionary<string, UInt16>();
- Dictionary<string, UInt16> Params2 = new Dictionary<string, UInt16>();
- Dictionary<string, UInt16> MotorParam = new Dictionary<string, UInt16>();
- Dictionary<string, string> Otherinfo = new Dictionary<string, string>();
- Dictionary<string, UInt16> TestThData = new Dictionary<string, ushort>();
- Dictionary<string, string> MarkInfo = new Dictionary<string, string>();
- //文件路径
- public string FilePath = "";
- public ExportForm()
- {
- InitializeComponent();
- }
- private void ExportForm_Load(object sender, EventArgs e)
- {
-
- }
- private void SetDefault()
- {
- //参数1
- Params1.Clear();
- Params1.Add("启动模式", 2);
- Params1.Add("停机时间", 100);
- Params1.Add("限速值", 25);
- Params1.Add("下降速度", 3);
- Params1.Add("前飞", 14);
- Params1.Add("后飞", 9);
- Params1.Add("限流", 15);
- Params1.Add("温度预警", 95);
- Params1.Add("温度保护", 125);
- Params1.Add("码表", 0x55);//有,不支持无码表
- Params1.Add("轮胎周长", 219);//cm
- Params1.Add("系列号", 0);
- Params1.Add("ECO增益", 100);//放大100倍
- Params1.Add("ECO加速", 100);
- Params1.Add("NORM增益", 100);
- Params1.Add("NORM加速", 100);
- Params1.Add("SPORT增益", 100);
- Params1.Add("SPORT加速", 100);
- Params1.Add("TURBO增益", 100);
- Params1.Add("TURBO加速", 100);
- Params1.Add("SMART增益", 100);
- Params1.Add("SMART加速", 100);
- Params1.Add("车速级数", 1);
- Params1.Add("踏频启动", 2);
- Params1.Add("指拨模式", 0x55);
- Params1.Add("速度信号来源", 0x55);//传感器
- Params1.Add("周长微调", 0);
- Params1.Add("低压保护", 3000);//mV
- Params1.Add("推行限速", 60);//放大10倍
- Params1.Add("推行转速", 135);
- //参数2
- Params2.Clear();
- Params2.Add("姿态传感器", 0x55);//不支持
- Params2.Add("俯仰角零偏", 0);
- Params2.Add("横滚角零偏", 0);
- Params2.Add("尾灯模式", 2);
- Params2.Add("前灯电压", 12);
- Params2.Add("尾灯电压", 12);
- Params2.Add("报警阈值", 150);//放大10倍
- Params2.Add("尾灯脉宽", 70);
- Params2.Add("尾灯周期", 150);
- //马达参数
- MotorParam.Clear();
- MotorParam.Add("额定功率", 250);
- MotorParam.Add("空载转速", 1200);
- MotorParam.Add("定子电阻", 10);
- MotorParam.Add("定子Lq", 10);
- MotorParam.Add("定子Ld", 10);
- MotorParam.Add("反电动势", 36000);
- MotorParam.Add("额定电压", 36);
- //其它信息
- Otherinfo.Clear();
- Otherinfo.Add("生产商", "TTIUM");
- Otherinfo.Add("生产地", "WUHAN");
- Otherinfo.Add("生产日期", DateTime.Now.ToString("yyyyMMdd"));
- Otherinfo.Add("校验密钥", "AVONITOM");
- Otherinfo.Add("信息1", "");
- Otherinfo.Add("信息2", "");
- Otherinfo.Add("信息3", "");
- //测试阈值
- TestThData.Clear();
- TestThData.Add("空载电流", 1000);
- TestThData.Add("车速", 150);
- TestThData.Add("指拨转速", 1225);
- TestThData.Add("零偏最小值", 100);
- TestThData.Add("零偏最大值", 1800);
- TestThData.Add("标定系数最小值", 25);
- TestThData.Add("标定系数最大值", 75);
- TestThData.Add("启动值最小值", 350);
- TestThData.Add("启动值最大值", 750);
- //其它测试备注信息
- MarkInfo.Clear();
- MarkInfo.Add("PCBA版号", "");
- }
- private void ParamsDisplayUpdate()
- {
- //参数1
- comboBox_StartMode.SelectedIndex = Params1["启动模式"] - 1;
- textBox_StopTime.Text = Params1["停机时间"].ToString();
- textBox_SpeedLimit.Text = Params1["限速值"].ToString();
- textBox_Dec.Text = Params1["下降速度"].ToString();
- textBox_T_Front.Text = Params1["前飞"].ToString();
- textBox_T_Tail.Text = Params1["后飞"].ToString();
- textBox_MaxCurrent.Text = Params1["限流"].ToString();
- textBox_NTC_Alarm.Text = Params1["温度预警"].ToString();
- textBox_NTC_Ptotect.Text = Params1["温度保护"].ToString();
- if (Params1["码表"] == 0x55)
- {
- comboBox_NoPBU.SelectedIndex = 1;
- }
- else if (Params1["码表"] == 0xAA)
- {
- comboBox_NoPBU.SelectedIndex = 0;
- }
- textBox_WheelSize.Text = Params1["轮胎周长"].ToString();
- textBox_Serial.Text = Params1["系列号"].ToString();
- textBox_ECO_Gain.Text = ((float)(Params1["ECO增益"]) / 100.0f).ToString("#0.00");
- textBox_ECO_Acc.Text = ((float)(Params1["ECO加速"]) / 100.0f).ToString("#0.00");
- textBox_NORM_Gain.Text = ((float)(Params1["NORM增益"]) / 100.0f).ToString("#0.00");
- textBox_NORM_Acc.Text = ((float)(Params1["NORM加速"]) / 100.0f).ToString("#0.00");
- textBox_SPORT_Gain.Text = ((float)(Params1["SPORT增益"]) / 100.0f).ToString("#0.00");
- textBox_SPORT_Acc.Text = ((float)(Params1["SPORT加速"]) / 100.0f).ToString("#0.00");
- textBox_TURBO_Gain.Text = ((float)(Params1["TURBO增益"]) / 100.0f).ToString("#0.00");
- textBox_TURBO_Acc.Text = ((float)(Params1["TURBO加速"]) / 100.0f).ToString("#0.00");
- textBox_SMART_Gain.Text = ((float)(Params1["SMART增益"]) / 100.0f).ToString("#0.00");
- textBox_SMART_Acc.Text = ((float)(Params1["SMART加速"]) / 100.0f).ToString("#0.00");
- textBox_SpeedSensor.Text = Params1["车速级数"].ToString();
- textBox_CadenceStart.Text = Params1["踏频启动"].ToString();
- if (Params1["指拨模式"] == 0x55)
- {
- comboBox_GasMode.SelectedIndex = 0;
- }
- else if (Params1["指拨模式"] == 0xAA)
- {
- comboBox_GasMode.SelectedIndex = 1;
- }
- if (Params1["速度信号来源"] == 0x55)
- {
- comboBox_SpeedSensor.SelectedIndex = 0;
- }
- else if (Params1["速度信号来源"] == 0xAA)
- {
- comboBox_SpeedSensor.SelectedIndex = 1;
- }
- else if (Params1["速度信号来源"] == 0xEE)
- {
- comboBox_SpeedSensor.SelectedIndex = 2;
- }
- textBox_WheelSizeAdj.Text = Params1["周长微调"].ToString();
- textBox_UV_Protect.Text = Params1["低压保护"].ToString();
- textBox_Walk_SpeedLimit.Text = ((float)(Params1["推行限速"]) / 10.0f).ToString("#0.0");
- textBox_WalkSpeed.Text = Params1["推行转速"].ToString();
- //参数2
- if (Params2["姿态传感器"] == 0x55)
- {
- comboBox_AstSensor.SelectedIndex = 0;
- }
- else if (Params1["姿态传感器"] == 0xAA)
- {
- comboBox_AstSensor.SelectedIndex = 1;
- }
- textBox_Angle_P.Text = ((float)(Params2["俯仰角零偏"]) / 10.0f).ToString("#0.0");
- textBox_Angle_R.Text = ((float)(Params2["横滚角零偏"]) / 10.0f).ToString("#0.0");
- comboBox_LightMode.SelectedIndex = Params2["尾灯模式"] - 1;
- if (Params2["前灯电压"] == 6)
- {
- comboBox_HeadLightVol.SelectedIndex = 0;
- }
- else if (Params2["前灯电压"] == 12)
- {
- comboBox_HeadLightVol.SelectedIndex = 1;
- }
- else if (Params2["前灯电压"] == 0xFF)
- {
- comboBox_HeadLightVol.SelectedIndex = 2;
- }
- else if (Params2["前灯电压"] == 0)
- {
- comboBox_HeadLightVol.SelectedIndex = 3;
- }
- if (Params2["尾灯电压"] == 6)
- {
- comboBox_TailLightVol.SelectedIndex = 0;
- }
- else if (Params2["尾灯电压"] == 12)
- {
- comboBox_TailLightVol.SelectedIndex = 1;
- }
- else if (Params2["尾灯电压"] == 0xFF)
- {
- comboBox_TailLightVol.SelectedIndex = 2;
- }
- else if (Params2["尾灯电压"] == 0)
- {
- comboBox_TailLightVol.SelectedIndex = 3;
- }
- textBox_AlarmSpeed.Text = ((float)(Params2["报警阈值"]) / 10.0f).ToString("#0.0");
- textBox_LightPluse.Text = Params2["尾灯脉宽"].ToString();
- textBox_LightPeriod.Text = Params2["尾灯周期"].ToString();
- //马达参数
- textBox_RatePower.Text = MotorParam["额定功率"].ToString();
- textBox_RateSpeed.Text = MotorParam["空载转速"].ToString();
- textBox_RotorR.Text = MotorParam["定子电阻"].ToString();
- textBox_Rotor_Lq.Text = MotorParam["定子Lq"].ToString();
- textBox_Rotor_Ld.Text = MotorParam["定子Ld"].ToString();
- textBox_E.Text = MotorParam["反电动势"].ToString();
- textBox_Rate_Vol.Text = MotorParam["额定电压"].ToString();
- //其它信息
- textBox_Mac.Text = Otherinfo["生产商"].ToString();
- textBox_Mac_Addr.Text = Otherinfo["生产地"].ToString();
- textBox_Mac_Date.Text = Otherinfo["生产日期"].ToString();
- textBox_Secrect.Text = Otherinfo["校验密钥"].ToString();
- textBox_Info1.Text = Otherinfo["信息1"].ToString();
- textBox_Info2.Text = Otherinfo["信息2"].ToString();
- textBox_Info3.Text = Otherinfo["信息3"].ToString();
-
- //测试阈值
- textBox_NC_Current.Text = TestThData["空载电流"].ToString();
- textBox_SpeedTh.Text = TestThData["车速"].ToString();
- textBox_GasSpeedTh.Text = TestThData["指拨转速"].ToString();
- textBox_Zero_Min.Text = TestThData["零偏最小值"].ToString();
- textBox_Zero_Max.Text = TestThData["零偏最大值"].ToString();
- textBox_K_Min.Text = ((float)(TestThData["标定系数最小值"]) / 100.0f).ToString("#0.00");
- textBox_K_Max.Text = ((float)(TestThData["标定系数最大值"]) / 100.0f).ToString("#0.00");
- textBox_Start_Min.Text = TestThData["启动值最小值"].ToString();
- textBox_Start_Max.Text = TestThData["启动值最大值"].ToString();
- //其它测试备注信息
- textBox_HW_Version.Text = MarkInfo["PCBA版号"];
- }
- private bool DisplaySetToParams()
- {
- try
- {
- //参数1
- Params1.Clear();
- if (comboBox_StartMode.Text == "柔和")
- {
- Params1.Add("启动模式", 1);
- }
- else if (comboBox_StartMode.Text == "正常")
- {
- Params1.Add("启动模式", 2);
- }
- else if (comboBox_StartMode.Text == "强劲")
- {
- Params1.Add("启动模式", 3);
- }
- else
- {
- MessageBox.Show("请检查启动模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("停机时间", Convert.ToUInt16(textBox_StopTime.Text));
- if (Params1["停机时间"] < 50 || Params1["停机时间"] > 500)
- {
- MessageBox.Show("停机时间有效值:50~500 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("限速值", Convert.ToUInt16(textBox_SpeedLimit.Text));
- if (Params1["限速值"] < 5 || Params1["限速值"] > 120)
- {
- MessageBox.Show("限速值有效值:5~120 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("下降速度", Convert.ToUInt16(textBox_Dec.Text));
- if (Params1["下降速度"] < 1 || Params1["下降速度"] > 5)
- {
- MessageBox.Show("下降速度有效值:1~5 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("前飞", Convert.ToUInt16(textBox_T_Front.Text));
- if (Params1["前飞"] < 5 || Params1["前飞"] > 100)
- {
- MessageBox.Show("前飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("后飞", Convert.ToUInt16(textBox_T_Tail.Text));
- if (Params1["后飞"] < 5 || Params1["后飞"] > 100)
- {
- MessageBox.Show("后飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("限流", Convert.ToUInt16(textBox_MaxCurrent.Text));
- if (Params1["限流"] < 5 || Params1["限流"] > 25)
- {
- MessageBox.Show("限流有效值:5~25 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("温度预警", Convert.ToUInt16(textBox_NTC_Alarm.Text));
- Params1.Add("温度保护", Convert.ToUInt16(textBox_NTC_Ptotect.Text));
- if (comboBox_NoPBU.Text == "有")
- {
- Params1.Add("码表", 0x55);
- }
- else if (comboBox_NoPBU.Text == "无")
- {
- Params1.Add("码表", 0xAA);
- }
- else
- {
- MessageBox.Show("请检查无码表设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("轮胎周长", Convert.ToUInt16(textBox_WheelSize.Text));
- if (Params1["轮胎周长"] < 80 || Params1["轮胎周长"] > 250)
- {
- MessageBox.Show("轮胎周长有效值:80~250 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("系列号", Convert.ToUInt16(textBox_Serial.Text));
- if (Params1["系列号"] < 1 || Params1["系列号"] > 16)
- {
- MessageBox.Show("系列号有效值:1~16 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("ECO增益", Convert.ToUInt16(float.Parse(textBox_ECO_Gain.Text) * 100));//放大100倍
- Params1.Add("ECO加速", Convert.ToUInt16(float.Parse(textBox_ECO_Acc.Text) * 100));
- Params1.Add("NORM增益", Convert.ToUInt16(float.Parse(textBox_NORM_Gain.Text) * 100));
- Params1.Add("NORM加速", Convert.ToUInt16(float.Parse(textBox_NORM_Acc.Text) * 100));
- Params1.Add("SPORT增益", Convert.ToUInt16(float.Parse(textBox_SPORT_Gain.Text) * 100));
- Params1.Add("SPORT加速", Convert.ToUInt16(float.Parse(textBox_SPORT_Acc.Text) * 100));
- Params1.Add("TURBO增益", Convert.ToUInt16(float.Parse(textBox_TURBO_Gain.Text) * 100));
- Params1.Add("TURBO加速", Convert.ToUInt16(float.Parse(textBox_TURBO_Acc.Text) * 100));
- Params1.Add("SMART增益", Convert.ToUInt16(float.Parse(textBox_SMART_Gain.Text) * 100));
- Params1.Add("SMART加速", Convert.ToUInt16(float.Parse(textBox_SMART_Acc.Text) * 100));
- Params1.Add("车速级数", Convert.ToUInt16(textBox_SpeedSensor.Text));
- Params1.Add("踏频启动", Convert.ToUInt16(textBox_CadenceStart.Text));
- if (comboBox_GasMode.Text == "不支持")
- {
- Params1.Add("指拨模式", 0x55);
- }
- else if (comboBox_GasMode.Text == "支持")
- {
- Params1.Add("指拨模式", 0xAA);
- }
- else
- {
- MessageBox.Show("请检查指拨模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (comboBox_SpeedSensor.Text == "传感器")
- {
- Params1.Add("速度信号来源", 0x55);
- }
- else if (comboBox_SpeedSensor.Text == "踏频")
- {
- Params1.Add("速度信号来源", 0xAA);
- }
- else if (comboBox_SpeedSensor.Text == "通信")
- {
- Params1.Add("速度信号来源", 0xEE);
- }
- else
- {
- MessageBox.Show("请检查速度信号来源设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params1.Add("周长微调", Convert.ToUInt16(textBox_WheelSizeAdj.Text));
- Params1.Add("低压保护", Convert.ToUInt16(textBox_UV_Protect.Text));//mV
- Params1.Add("推行限速", Convert.ToUInt16(float.Parse(textBox_Walk_SpeedLimit.Text) * 10));//放大10倍
- Params1.Add("推行转速", Convert.ToUInt16(textBox_WalkSpeed.Text));
- //参数2
- Params2.Clear();
- if (comboBox_AstSensor.Text == "不支持")
- {
- Params2.Add("姿态传感器", 0x55);
- }
- else if (comboBox_AstSensor.Text == "支持")
- {
- Params2.Add("姿态传感器", 0xAA);
- }
- else
- {
- MessageBox.Show("请检查姿态传感器设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- Params2.Add("俯仰角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_P.Text) * 10));
- Params2.Add("横滚角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_R.Text) * 10));
- if (comboBox_LightMode.Text == "模式 1")
- {
- Params2.Add("尾灯模式", 1);
- }
- else if(comboBox_LightMode.Text == "模式 2")
- {
- Params2.Add("尾灯模式", 2);
- }
- else if (comboBox_LightMode.Text == "模式 3")
- {
- Params2.Add("尾灯模式", 3);
- }
- else if (comboBox_LightMode.Text == "模式 4")
- {
- Params2.Add("尾灯模式", 4);
- }
- else if (comboBox_LightMode.Text == "模式 5")
- {
- Params2.Add("尾灯模式", 5);
- }
- else if (comboBox_LightMode.Text == "模式 6")
- {
- Params2.Add("尾灯模式", 6);
- }
- if (comboBox_HeadLightVol.Text == "6V")
- {
- Params2.Add("前灯电压", 6);
- }
- else if (comboBox_HeadLightVol.Text == "12V")
- {
- Params2.Add("前灯电压", 12);
- }
- else if (comboBox_HeadLightVol.Text == "随电池")
- {
- Params2.Add("前灯电压", 0xFF);
- }
- else if (comboBox_HeadLightVol.Text == "硬件配置")
- {
- Params2.Add("前灯电压", 0);
- }
- if (comboBox_TailLightVol.Text == "6V")
- {
- Params2.Add("尾灯电压", 6);
- }
- else if (comboBox_TailLightVol.Text == "12V")
- {
- Params2.Add("尾灯电压", 12);
- }
- else if (comboBox_TailLightVol.Text == "随电池")
- {
- Params2.Add("尾灯电压", 0xFF);
- }
- else if (comboBox_TailLightVol.Text == "硬件配置")
- {
- Params2.Add("尾灯电压", 0);
- }
- Params2.Add("报警阈值", Convert.ToUInt16(float.Parse(textBox_AlarmSpeed.Text) * 10));//放大10倍
- Params2.Add("尾灯脉宽", Convert.ToUInt16(textBox_LightPluse.Text));
- Params2.Add("尾灯周期", Convert.ToUInt16(textBox_LightPeriod.Text));
- //马达参数
- MotorParam.Clear();
- MotorParam.Add("额定功率", Convert.ToUInt16(textBox_RatePower.Text));
- MotorParam.Add("空载转速", Convert.ToUInt16(textBox_RateSpeed.Text));
- MotorParam.Add("定子电阻", Convert.ToUInt16(textBox_RotorR.Text));
- MotorParam.Add("定子Lq", Convert.ToUInt16(textBox_Rotor_Lq.Text));
- MotorParam.Add("定子Ld", Convert.ToUInt16(textBox_Rotor_Ld.Text));
- MotorParam.Add("反电动势", Convert.ToUInt16(textBox_E.Text));
- MotorParam.Add("额定电压", Convert.ToUInt16(textBox_Rate_Vol.Text));
- //其它信息
- Otherinfo.Clear();
- Otherinfo.Add("生产商", textBox_Mac.Text);
- Otherinfo.Add("生产地", textBox_Mac_Addr.Text);
- Otherinfo.Add("生产日期", textBox_Mac_Date.Text);
- Otherinfo.Add("校验密钥", textBox_Secrect.Text);
- Otherinfo.Add("信息1", textBox_Info1.Text);
- Otherinfo.Add("信息2", textBox_Info2.Text);
- Otherinfo.Add("信息3", textBox_Info3.Text);
- //测试阈值
- TestThData.Clear();
- TestThData.Add("空载电流", Convert.ToUInt16(textBox_NC_Current.Text));
- TestThData.Add("车速", Convert.ToUInt16(textBox_SpeedTh.Text));
- TestThData.Add("指拨转速", Convert.ToUInt16(textBox_GasSpeedTh.Text));
- TestThData.Add("零偏最小值", Convert.ToUInt16(textBox_Zero_Min.Text));
- TestThData.Add("零偏最大值", Convert.ToUInt16(textBox_Zero_Max.Text));
- TestThData.Add("标定系数最小值", Convert.ToUInt16(float.Parse(textBox_K_Min.Text) * 100));
- TestThData.Add("标定系数最大值", Convert.ToUInt16(float.Parse(textBox_K_Max.Text) * 100));
- TestThData.Add("启动值最小值", Convert.ToUInt16(textBox_Start_Min.Text));
- TestThData.Add("启动值最大值", Convert.ToUInt16(textBox_Start_Max.Text));
- //其它测试备注信息
- MarkInfo.Clear();
- if (textBox_HW_Version.Text == string.Empty)
- {
- MessageBox.Show("请输入PCBA版号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- else
- {
- MarkInfo.Add("PCBA版号", textBox_HW_Version.Text);
- }
- return true;
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- }
- private void button_Default_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("确认恢复默认值?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
- {
- return;
- }
- SetDefault();
- ParamsDisplayUpdate();
- }
- private void button_Generate_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("确认提交?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
- {
- return;
- }
- //空间内容更新到字典
- if (DisplaySetToParams() == false)
- {
- MessageBox.Show("参数生成失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //保存为配置文件
- if (textBox_Model.Text == string.Empty) //判断型号是否填写
- {
- MessageBox.Show("请输入电机型号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (textBox_Client.Text == string.Empty) //判断订单编号是否填写
- {
- MessageBox.Show("请输入订单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (textBox_HW_Version.Text == String.Empty) //判断PCBA板号是否填写
- {
- MessageBox.Show("请输入PCBA板号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (comboBox_Baudrate.SelectedIndex == -1)
- {
- MessageBox.Show("请设定波特率!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- Regex Reg = new Regex(@"[V][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9]_20\d{6}");
- if (Reg.IsMatch(textBox_FW_Version.Text) == false) //判断主控软件版本是否填写
- {
- MessageBox.Show("主控软件版本格式不正确,例如V1.0.0.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (textBox_TE_FW_Version.Text != "N_A")//兼容单MCU主控板,无TE时填写N_A
- {
- Reg = new Regex(@"[V][0-9].[0-9].[0-9]_20\d{6}"); //判断TE软件版本是否填写
- if (Reg.IsMatch(textBox_TE_FW_Version.Text) == false) //判断TE软件版本是否填写
- {
- MessageBox.Show("TE软件版本格式不正确,例如N_A或V1.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- button_Generate.BackColor = Color.Red;
- button_Generate.Text = "生成中";
- button_Generate.Enabled = false;
- if (System.IO.Directory.Exists(FilePath) == false)
- System.IO.Directory.CreateDirectory(FilePath);
- string Datenow = DateTime.Now.ToString("yyyy-MM-dd") + "\\";
- if (System.IO.Directory.Exists(FilePath + Datenow) == false)
- System.IO.Directory.CreateDirectory(FilePath + Datenow);
- string fileName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + textBox_FW_Version.Text + "_" + textBox_TE_FW_Version.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".ttcfg";
- using (StreamWriter file = new StreamWriter(fileName))
- {
- //用户参数1
- file.WriteLine("[{0}]", "用户参数1");
- foreach (var entry in Params1)
- if (entry.Key == "码表")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "有" : entry.Value == 0xAA ? "无" : "无效");
- else if (entry.Key == "指拨模式")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
- else if (entry.Key == "速度信号来源")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "传感器" : entry.Value == 0xAA ? "踏频" : entry.Value == 0xEE ? "通信" : "无效");
- else
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- //用户参数2
- file.WriteLine("");
- file.WriteLine("[{0}]", "用户参数2");
- foreach (var entry in Params2)
- if (entry.Key == "姿态传感器")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
- else if (entry.Key == "前灯电压")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0xFF ? "随电池" : entry.Value == 0 ? "硬件配置" : entry.Value + "V");
- else if (entry.Key == "尾灯电压")
- file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0xFF ? "随电池" : entry.Value == 0 ? "硬件配置" : entry.Value + "V");
- else
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- //马达参数
- file.WriteLine("");
- file.WriteLine("[{0}]", "马达参数");
- foreach (var entry in MotorParam)
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- //其它信息
- file.WriteLine("");
- file.WriteLine("[{0}]", "其它信息");
- foreach (var entry in Otherinfo)
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- //测试阈值
- file.WriteLine("");
- file.WriteLine("[{0}]", "测试阈值");
- foreach (var entry in TestThData)
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- //其它测试备注信息
- file.WriteLine("");
- file.WriteLine("[{0}]", "其它测试备注信息");
- foreach (var entry in MarkInfo)
- file.WriteLine("{0},{1}", entry.Key, entry.Value);
- }
- button_Generate.Text = "转换中";
- //保存为Excel文件
- string importExcelName = "FOQC成机参数检验标准_Temple3.xls";
- string exportExcelName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".xls";
- try
- {
-
- //导入文件
- IWorkbook workbook = WorkbookFactory.Create(importExcelName);
- //获取第一个工作薄
- ISheet sheet = workbook.GetSheetAt(0);
- #region 开始按行写入单元格
- //第3行,文件信息
- IRow row = sheet.GetRow(2);
- row.GetCell(0).SetCellValue("文件信息 File Info:" + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
- //第5行,第2列型号,第10列SPORT加速
- row = sheet.GetRow(4);
- row.GetCell(1).SetCellValue(textBox_Model.Text);
- row.GetCell(9).SetCellValue(textBox_SPORT_Acc.Text);
- //第6行,第2列SN,第10列TURBO增益
- row = sheet.GetRow(5);
- row.GetCell(1).SetCellValue("Same as marking");
- row.GetCell(9).SetCellValue(textBox_TURBO_Gain.Text);
- //第7行,第2列硬件板号,第10列TURBO加速
- row = sheet.GetRow(6);
- row.GetCell(1).SetCellValue(textBox_HW_Version.Text);
- row.GetCell(9).SetCellValue(textBox_TURBO_Acc.Text);
- //第8行,第2列主控软件版本,第10列SMART增益
- row = sheet.GetRow(7);
- row.GetCell(1).SetCellValue(textBox_FW_Version.Text);
- row.GetCell(9).SetCellValue(textBox_SMART_Gain.Text);
- //第9行,第2列TE软件版本,第10列SMART加速
- row = sheet.GetRow(8);
- row.GetCell(1).SetCellValue(textBox_TE_FW_Version.Text);
- row.GetCell(9).SetCellValue(textBox_SMART_Acc.Text);
- //第10行,第2列BOOT版本,第10列额定功率
- row = sheet.GetRow(9);
- row.GetCell(1).SetCellValue(comboBox_Baudrate.SelectedIndex == 0 ? "V1.2.2 125K" : "V2.0.0 250K");
- row.GetCell(9).SetCellValue(textBox_RatePower.Text + " W");
- //第11行,第2列静态电压,第10列空载转速
- row = sheet.GetRow(10);
- row.GetCell(1).SetCellValue(textBox_Rate_Vol.Text + " ± 1 V");
- row.GetCell(9).SetCellValue(textBox_RateSpeed.Text + " rpm");
- //第12行,第2列静态电流,第10列额定电压
- row = sheet.GetRow(11);
- row.GetCell(1).SetCellValue("≤ 0.050 A");
- row.GetCell(9).SetCellValue(textBox_Rate_Vol.Text + " V");
- //第13行,第2列指拨模式,第10列速度信号个数
- row = sheet.GetRow(12);
- row.GetCell(1).SetCellValue(comboBox_GasMode.Text == "不支持" ? "不支持 No" : "支持 Yes");
- row.GetCell(9).SetCellValue(textBox_SpeedSensor.Text);
- //第14行,第2列启动模式,第10列踏频启动信号个数
- row = sheet.GetRow(13);
- row.GetCell(1).SetCellValue(comboBox_StartMode.Text == "柔和" ? "柔和 Comfort" : comboBox_StartMode.Text == "正常" ? "正常 Normal" : "强劲 Dynamic");
- row.GetCell(9).SetCellValue(textBox_CadenceStart.Text);
- //第15行,第2列停机时间,第10列车速信号来源
- row = sheet.GetRow(14);
- row.GetCell(1).SetCellValue(textBox_StopTime.Text + " ms");
- row.GetCell(9).SetCellValue(comboBox_SpeedSensor.Text == "传感器" ? "传感器 Sensor" : comboBox_SpeedSensor.Text == "踏频" ? "踏频 Cadence" : "通信 CAN");
- //第16行,第2列限速,第10列轮胎周长微调
- row = sheet.GetRow(15);
- row.GetCell(1).SetCellValue(textBox_SpeedLimit.Text + " km/h");
- row.GetCell(9).SetCellValue(textBox_WheelSizeAdj.Text + " cm");
- //第17行,第2列下降速度,第10列推行转速
- row = sheet.GetRow(16);
- row.GetCell(1).SetCellValue("Level " + textBox_Dec.Text);
- row.GetCell(9).SetCellValue(textBox_WalkSpeed.Text + " rpm");
- //第18行,第2列前齿,第10列俯仰角零偏
- row = sheet.GetRow(17);
- row.GetCell(1).SetCellValue(textBox_T_Front.Text + " T");
- row.GetCell(9).SetCellValue(textBox_Angle_P.Text + " °");
- //第19行,第2列后齿,第10列横滚角零偏
- row = sheet.GetRow(18);
- row.GetCell(1).SetCellValue(textBox_T_Tail.Text + " T");
- row.GetCell(9).SetCellValue(textBox_Angle_R.Text + " °");
- //第20行,第2列限流,第10列姿态传感器
- row = sheet.GetRow(19);
- row.GetCell(1).SetCellValue(textBox_MaxCurrent.Text + " A");
- row.GetCell(9).SetCellValue(comboBox_AstSensor.Text == "不支持" ? "不支持 No" : "支持 Yes");
- //第21行,第2列温度预警,第10列尾灯模式
- row = sheet.GetRow(20);
- row.GetCell(1).SetCellValue(textBox_NTC_Alarm.Text + " ℃");
- row.GetCell(9).SetCellValue(comboBox_LightMode.Text.Replace("模式", "Mode"));
- //第22行,第2列温度保护,第10列前灯电压
- row = sheet.GetRow(21);
- row.GetCell(1).SetCellValue(textBox_NTC_Ptotect.Text + " ℃");
- row.GetCell(9).SetCellValue(comboBox_HeadLightVol.Text.Contains("随电池") ? comboBox_HeadLightVol.Text + " " + textBox_Rate_Vol.Text + " V" : comboBox_HeadLightVol.Text.Contains("硬件") ? "硬件配置 By HW" : comboBox_HeadLightVol.Text);
- //第23行,第2列码表,第10列后灯电压
- row = sheet.GetRow(22);
- row.GetCell(1).SetCellValue(comboBox_NoPBU.Text == "有" ? "有 Yes" : "无 No");
- row.GetCell(9).SetCellValue(comboBox_TailLightVol.Text.Contains("随电池") ? comboBox_TailLightVol.Text + " " + textBox_Rate_Vol.Text + " V" : comboBox_TailLightVol.Text.Contains("硬件") ? "硬件配置 By HW" : comboBox_TailLightVol.Text);
- //第24行,第2列轮胎周长,第10列启动值
- row = sheet.GetRow(23);
- row.GetCell(1).SetCellValue(textBox_WheelSize.Text + " cm");
- row.GetCell(9).SetCellValue(textBox_Start_Min.Text + " - " + textBox_Start_Max.Text);
- //第25行,第2列电机系列,第10列校正系数1
- row = sheet.GetRow(24);
- row.GetCell(1).SetCellValue(textBox_Serial.Text);
- row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
- //第26行,第2列低压保护,第10列校正系数2
- row = sheet.GetRow(25);
- row.GetCell(1).SetCellValue(textBox_UV_Protect.Text + " mV");
- if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
- row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
- else
- row.GetCell(9).SetCellValue("无此项目 None");
- //第27行,第2列推行限速,第10列校正系数3
- row = sheet.GetRow(26);
- row.GetCell(1).SetCellValue(textBox_Walk_SpeedLimit.Text + " km/h");
- if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
- row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
- else
- row.GetCell(9).SetCellValue("无此项目 None");
- //第28行,第2列ECO增益,第10列零点值1
- row = sheet.GetRow(27);
- row.GetCell(1).SetCellValue(textBox_ECO_Gain.Text);
- row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
- //第29行,第2列ECO加速,第10列零点值2
- row = sheet.GetRow(28);
- row.GetCell(1).SetCellValue(textBox_ECO_Acc.Text);
- if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
- row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
- else
- row.GetCell(9).SetCellValue("无此项目 None");
- //第30行,第2列NORM增益,第10列零点值3
- row = sheet.GetRow(29);
- row.GetCell(1).SetCellValue(textBox_NORM_Gain.Text);
- if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
- row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
- else
- row.GetCell(9).SetCellValue("无此项目 None");
- //第31行,第2列NORM加速,第10列骑行历史
- row = sheet.GetRow(30);
- row.GetCell(1).SetCellValue(textBox_NORM_Acc.Text);
- row.GetCell(9).SetCellValue("0 km / 0 min");
- //第32行,第2列SPORT增益,第10列故障码
- row = sheet.GetRow(31);
- row.GetCell(1).SetCellValue(textBox_SPORT_Gain.Text);
- row.GetCell(9).SetCellValue("无故障记录 None");
- //第33行,第2列尾灯脉宽,第10列尾灯周期
- row = sheet.GetRow(32);
- row.GetCell(1).SetCellValue(textBox_LightPluse.Text + "\n" + ((float)Convert.ToDouble(textBox_LightPluse.Text) / 15000f).ToString("0.000") + " s");
- row.GetCell(9).SetCellValue(textBox_LightPeriod.Text + "\n" + ((float)Convert.ToDouble(textBox_LightPeriod.Text) / 15000f).ToString("0.000") + " s");
- //第34行,第2列超速报警阈值
- row = sheet.GetRow(33);
- row.GetCell(1).SetCellValue(textBox_AlarmSpeed.Text + " km/h");
- #endregion
- using (FileStream file = File.OpenWrite(exportExcelName))
- {
- workbook.Write(file);
- workbook.Close();
- }
- }
- catch (Exception ex)
- {
- throw (ex);
- }
- //文件转换为pdf格式保存
- string exportPdfName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".pdf";
- Workbook workbook_1 = new Workbook();//创建Workbook类的实例
- workbook_1.LoadFromFile(exportExcelName);//加载Excel工作簿
- workbook_1.SaveToFile(exportPdfName, FileFormat.PDF);//将整个工作薄保存为PDF
- MessageBox.Show("参数已生成,进入文件管理页面查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- button_Generate.Text = "上传中";
- //发送文件到服务器
- if (StartForm.myFtp.IsNetConnected == true)
- {
- string DateNow = DateTime.Now.ToString("yyyy-MM-dd");
- int okCnt = 0;
- if (StartForm.myFtp.DirectoryExist(StartForm.myServerCfg.RootPath + "/cfg/", DateNow) == false)
- {
- StartForm.myFtp.MakeDir(StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
- }
- //上传配置文件
- bool result = StartForm.myFtp.UploadFile(fileName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
- if (result == true)
- {
- okCnt++;
- //MessageBox.Show("配置文件上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- //上传配置清单excel
- result = StartForm.myFtp.UploadFile(exportExcelName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
- if (result == true)
- {
- okCnt++;
- //MessageBox.Show("配置检验清单上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- //上传配置清单pdf
- result = StartForm.myFtp.UploadFile(exportPdfName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
- if (result == true)
- {
- okCnt++;
- //MessageBox.Show("配置检验清单上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- if (okCnt >= 3)
- {
- MessageBox.Show("配置检验文件上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("配置检验文件上传服务器失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- button_Generate.Text = "生成";
- button_Generate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
- button_Generate.Enabled = true;
- }
- private void button_keyboard_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("osk.exe");
- }
- //输入型号时自动更新关键参数
- private void textBox_Model_TextChanged(object sender, EventArgs e)
- {
- if (textBox_Model.Text.Contains("J01"))
- {
- textBox_Serial.Text = "1";//系列号
- textBox_MaxCurrent.Text = "13";//限流
- textBox_RatePower.Text = "250";//额定功率
- textBox_RateSpeed.Text = "1200";//额定转速
- textBox_Rate_Vol.Text = "36";//额定电压
- textBox_NC_Current.Text = "800";//空载电流
- textBox_Zero_Min.Text = "100";//零偏下限
- textBox_Zero_Max.Text = "2000";//零偏上限
- textBox_K_Min.Text = "0.40";//传感器标定值下限
- textBox_K_Max.Text = "1.20";//传感器标定值下限
- textBox_Start_Min.Text = "280";//启动值下限
- textBox_Start_Max.Text = "500";//启动值上限
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- else if (textBox_Model.Text.Contains("VL"))
- {
- textBox_Serial.Text = "1";//系列号
- textBox_MaxCurrent.Text = "13";//限流
- textBox_RatePower.Text = "250";//额定功率
- textBox_RateSpeed.Text = "1200";//额定转速
- textBox_Rate_Vol.Text = "36";//额定电压
- textBox_NC_Current.Text = "800";//空载电流
- textBox_Zero_Min.Text = "200";//零偏下限
- textBox_Zero_Max.Text = "1800";//零偏上限
- textBox_K_Min.Text = "0.25";//传感器标定值下限
- textBox_K_Max.Text = "0.75";//传感器标定值下限
- textBox_Start_Min.Text = "350";//启动值下限
- textBox_Start_Max.Text = "750";//启动值上限
- if (textBox_Model.Text.Contains("03") || textBox_Model.Text.Contains("13"))
- {
- textBox_GasSpeedTh.Text = "200";
- }
- else
- {
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- }
- else if (textBox_Model.Text.Contains("VS"))
- {
- textBox_Serial.Text = "2";//系列号
- textBox_MaxCurrent.Text = "15";//限流
- textBox_RatePower.Text = "250";//额定功率
- textBox_RateSpeed.Text = "1200";//额定转速
- textBox_Rate_Vol.Text = "36";//额定电压
- textBox_NC_Current.Text = "800";//空载电流
- textBox_Zero_Min.Text = "200";//零偏下限
- textBox_Zero_Max.Text = "1800";//零偏上限
- textBox_K_Min.Text = "0.25";//传感器标定值下限
- textBox_K_Max.Text = "0.75";//传感器标定值下限
- textBox_Start_Min.Text = "350";//启动值下限
- textBox_Start_Max.Text = "750";//启动值上限
- if (textBox_Model.Text.Contains("03") || textBox_Model.Text.Contains("13"))
- {
- textBox_GasSpeedTh.Text = "200";
- }
- else
- {
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- }
- else if (textBox_Model.Text.Contains("VR"))
- {
- textBox_Serial.Text = "2";//系列号
- textBox_MaxCurrent.Text = "15";//限流
- textBox_RatePower.Text = "250";//额定功率
- textBox_RateSpeed.Text = "1200";//额定转速
- textBox_Rate_Vol.Text = "36";//额定电压
- textBox_NC_Current.Text = "800";//空载电流
- textBox_Zero_Min.Text = "200";//零偏下限
- textBox_Zero_Max.Text = "1800";//零偏上限
- textBox_K_Min.Text = "0.25";//传感器标定值下限
- textBox_K_Max.Text = "0.75";//传感器标定值下限
- textBox_Start_Min.Text = "350";//启动值下限
- textBox_Start_Max.Text = "750";//启动值上限
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- else if (textBox_Model.Text.Contains("PG"))
- {
- textBox_Serial.Text = "3";//系列号
- textBox_MaxCurrent.Text = "17";//限流
- textBox_RatePower.Text = "250";//额定功率
- textBox_RateSpeed.Text = "1600";//额定转速
- textBox_Rate_Vol.Text = "36";//额定电压
- textBox_NC_Current.Text = "1000";//空载电流
- textBox_Zero_Min.Text = "100";//零偏下限
- textBox_Zero_Max.Text = "2000";//零偏上限
- textBox_K_Min.Text = "0.25";//传感器标定值下限
- textBox_K_Max.Text = "1.20";//传感器标定值下限
- textBox_Start_Min.Text = "280";//启动值下限
- textBox_Start_Max.Text = "500";//启动值上限
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- else if (textBox_Model.Text.Contains("PS"))
- {
- textBox_Serial.Text = "4";//系列号
- textBox_MaxCurrent.Text = "17";//限流
- textBox_RatePower.Text = "500";//额定功率
- textBox_RateSpeed.Text = "1800";//额定转速
- textBox_Rate_Vol.Text = "48";//额定电压
- textBox_NC_Current.Text = "1000";//空载电流
- textBox_Zero_Min.Text = "100";//零偏下限
- textBox_Zero_Max.Text = "2000";//零偏上限
- textBox_K_Min.Text = "0.25";//传感器标定值下限
- textBox_K_Max.Text = "1.20";//传感器标定值下限
- textBox_Start_Min.Text = "280";//启动值下限
- textBox_Start_Max.Text = "500";//启动值上限
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- else
- {
- textBox_Serial.Text = "";//系列号
- textBox_MaxCurrent.Text = "";//限流
- textBox_RatePower.Text = "";//额定功率
- textBox_RateSpeed.Text = "";//额定转速
- textBox_Rate_Vol.Text = "";//额定电压
- textBox_NC_Current.Text = "";//空载电流
- textBox_Zero_Min.Text = "";//零偏下限
- textBox_Zero_Max.Text = "";//零偏上限
- textBox_K_Min.Text = "";//传感器标定值下限
- textBox_K_Max.Text = "";//传感器标定值下限
- textBox_Start_Min.Text = "";//启动值下限
- textBox_Start_Max.Text = "";//启动值上限
- textBox_GasSpeedTh.Text = "";
- }
- }
- //输入限速时更改指拨转速阈值
- private void textBox_SpeedLimit_TextChanged(object sender, EventArgs e)
- {
- if (textBox_SpeedLimit.Text == "")
- return;
- if ((!textBox_Model.Text.Contains("6503")) && (!textBox_Model.Text.Contains("6513")) && (!textBox_Model.Text.Contains("7503")) && (!textBox_Model.Text.Contains("7513")))
- {
- textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
- }
- }
- //更改尾灯模式时更改尾灯脉宽和周期
- private void comboBox_LightMode_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (comboBox_LightMode.SelectedIndex == 0) // 模式1,开灯低亮,刹车高亮
- {
- textBox_AlarmSpeed.Text = "15.0";
- textBox_LightPluse.Text = "75";
- textBox_LightPeriod.Text = "150";
- }
- else if (comboBox_LightMode.SelectedIndex == 5) // 模式6,超速报警
- {
- textBox_AlarmSpeed.Text = "15.0";
- textBox_LightPluse.Text = "7500";
- textBox_LightPeriod.Text = "45000";
- }
- }
- //指拨转速阈值修改
- private void textBox_GasSpeedTh_TextChanged(object sender, EventArgs e)
- {
- UInt32 DataTemp = 0;
- if (textBox_GasSpeedTh.Text == "")
- {
- return;
- }
- DataTemp = Convert.ToUInt32(textBox_GasSpeedTh.Text);
- if (textBox_Model.Text.Contains("VL"))
- {
- if (DataTemp >= 1200)
- {
- textBox_GasSpeedTh.Text = "1200";
- }
- }
- else if (textBox_Model.Text.Contains("VS"))
- {
- if (DataTemp >= 1200)
- {
- textBox_GasSpeedTh.Text = "1200";
- }
- }
- else if (textBox_Model.Text.Contains("PG"))
- {
- if (DataTemp >= 1400)
- {
- textBox_GasSpeedTh.Text = "1400";
- }
- }
- else if (textBox_Model.Text.Contains("PS"))
- {
- if (DataTemp >= 1600)
- {
- textBox_GasSpeedTh.Text = "1600";
- }
- }
- }
- }
- }
|