Version.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace Welling_Motor_Debug_Tool
  13. {
  14. public partial class Version : Form
  15. {
  16. //修改记录
  17. string ChangeLog = "修改记录:\r\n" +
  18. "V" + mainForm.Version + "\r\n" +
  19. "" +
  20. "\r\n" +
  21. "V2.2.2\r\n" +
  22. "1,增加自动更新按钮,解决离线使用时打开慢的问题;\r\n" +
  23. "2,删除发送进入5S协议指令,新版本UART控制器不需要配置协议,考虑还原提高兼容性;\r\n" +
  24. "3,部分工序增加延时,解决通信异常问题;\r\n" +
  25. "4,量产测试和检验模式增加重发机制;\r\n" +
  26. "5,控制参数预留1低8位作为转把定速巡航开关,仪表用户参数增加转把定速巡航开关;\r\n" +
  27. "6, 增加指令窗口,可显示接收和发送的数据;\r\n" +
  28. "7,解决导入本地记录文件时,自定义字符串以\\0结尾高级参数界面异常问题,目前关闭自定义字符串指令。\r\n" +
  29. "\r\n"+
  30. "V2.2.1\r\n" +
  31. "1,优化修改配置模式时重复发送指令的问题;\r\n" +
  32. "2,解决刹车检测报错的问题;\r\n" +
  33. "3, 解决力矩传感器测试结果不显示问题。\r\n" +
  34. "\r\n" +
  35. "V2.2.0\r\n" +
  36. "1,优化新增协议内容;\r\n" +
  37. "2,增加协议类型选择,支持CAN和UART;\r\n" +
  38. "3,针对UART控制器在量产测试过程中增加5S协议设定和联动装置盒波特率设定,以正确接收UART控制器数据和Boot版本信息;\r\n" +
  39. "4,基础功能测试控制电机启动由修改运行模式改为Walk模式;\r\n" +
  40. "5,量产功能测试增加MOS内阻校准环节,支持可选;\r\n" +
  41. "6,增加流水号记录。\r\n" +
  42. "\r\n" +
  43. "V2.1.9\r\n" +
  44. "1,增加整车信息2、用户骑行参数界面,支持上位机读写;\r\n" +
  45. "2,增加车架ODO里程写入和读取;\r\n" +
  46. "3,增加产品标签写入,支持32位字符;\r\n" +
  47. "4,生成参数界面可选择HUB_FCT,支持仅导出到本地;\r\n" +
  48. "5,FCT治具测试账户登录后,测试路径自动改为HUB_FCT_Test;\r\n" +
  49. "6,增加删除指定配置文件和样机测试记录文件,支持文件夹递归删除。\r\n" +
  50. "\r\n" +
  51. "V2.1.8\r\n" +
  52. "1,限制FCT治具测试账户需要联网使用;\r\n" +
  53. "2,量产测试和检验模式下,双击配置文件可删除选中的配置文件。\r\n" +
  54. "\r\n" +
  55. "V2.1.7\r\n" +
  56. "1,解决系统显示缩放后,截图显示不完全的问题;\r\n" +
  57. "2,允许离线使用是关闭网络定时检测;\r\n" +
  58. "3,定时检测网络断开时不自动关闭,此时不允许使用,等待网络恢复;\r\n" +
  59. "4,启动登录密码错误时不自动关闭,重新进入登录;\r\n" +
  60. "5,部分提示框修改为自动关闭;\r\n" +
  61. "6,增加读取本机信息功能;\r\n" +
  62. "7,启动时自动上传登录日志,包含本机信息。\r\n" +
  63. "\r\n" +
  64. "V2.1.6\r\n" +
  65. "1,修改控制器内阻校准指令,增加写入存储标志;\r\n" +
  66. "2,参数生成界面增加导入样机测试记录的文件功能;\r\n" +
  67. "3,参数生成界面增加锁,防止误触。\r\n"
  68. ;
  69. //存储路径文件
  70. LocalInfo localInfo = new LocalInfo();
  71. //服务器配置
  72. string IP, Port, User, PassWD;
  73. //FTP
  74. ftp myFtp = new ftp();
  75. public Version()
  76. {
  77. InitializeComponent();
  78. }
  79. private void Version_Load(object sender, EventArgs e)
  80. {
  81. //更新版本信息
  82. label_Ver.Text = "版本: V" + mainForm.Version;
  83. label_BT.Text = "编译时间:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString("yyyy-MM-dd HH:mm:ss");
  84. //修改日志
  85. richTextBox_Log.Text = "";
  86. richTextBox_Log.AppendText(ChangeLog);
  87. //导入网络配置
  88. if (System.IO.File.Exists(localInfo.LocalPath + localInfo.ConfigFileName)) //存在配置文件,导入配置信息
  89. {
  90. //打开文件
  91. StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.ConfigFileName);
  92. string sLine = "";
  93. ArrayList array_CfgInfo = new ArrayList();
  94. array_CfgInfo.Clear();
  95. while (sLine != null)
  96. {
  97. sLine = objReader.ReadLine();
  98. array_CfgInfo.Add(sLine);
  99. }
  100. objReader.Close();
  101. //解析配置文件
  102. try
  103. {
  104. //Server Set IP, Port, User, PassWS, ModelPath;
  105. IP = array_CfgInfo[12].ToString().Split(':')[1];
  106. Port = array_CfgInfo[13].ToString().Split(':')[1];
  107. User = array_CfgInfo[14].ToString().Split(':')[1];
  108. PassWD = array_CfgInfo[15].ToString().Split(':')[1];
  109. myFtp.FtpOption(IP, Port, User, PassWD, "admin", "ttium_admin");
  110. }
  111. catch (System.Exception)
  112. {
  113. MessageBox.Show("参数格式错误,写入默认值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  114. }
  115. }
  116. else
  117. {
  118. MessageBox.Show("参数文件丢失!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  119. this.Close();
  120. }
  121. }
  122. private void button_CheckVersion_Click(object sender, EventArgs e)
  123. {
  124. //检查网络状态
  125. if (myFtp.CheckFtp() == false)
  126. {
  127. MessageBox.Show("网络断开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  128. return;
  129. }
  130. else
  131. {
  132. //检查本地文件删除
  133. if (System.IO.File.Exists(localInfo.LocalPath + "\\Version"))
  134. System.IO.File.Delete(localInfo.LocalPath + "\\Version");
  135. //读取最新版本号
  136. myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/Version", localInfo.LocalPath);
  137. StreamReader objReader = new StreamReader(localInfo.LocalPath + "\\Version");
  138. string sLine = "";
  139. ArrayList arrText = new ArrayList();//创建一个动态数组
  140. while (sLine != null)
  141. {
  142. sLine = objReader.ReadLine();
  143. arrText.Add(sLine);
  144. }
  145. objReader.Close();
  146. System.IO.File.Delete(localInfo.LocalPath + "\\Version");
  147. //检查是否有最新版本
  148. string[] VerOld = mainForm.Version.Trim().Split('.');
  149. string[] VerNew = arrText[0].ToString().Trim().Split('.');
  150. int VerOld_int = Convert.ToInt32(VerOld[0]) * 10000 + Convert.ToInt32(VerOld[1].PadLeft(2, '0')) * 100 + Convert.ToInt32(VerOld[2].PadLeft(2, '0'));
  151. int VerNew_int = Convert.ToInt32(VerNew[0]) * 10000 + Convert.ToInt32(VerNew[1].PadLeft(2, '0')) * 100 + Convert.ToInt32(VerNew[2].PadLeft(2, '0'));
  152. if (VerNew_int <= VerOld_int)
  153. {
  154. //版本已是最新,跳出
  155. MessageBox.Show("版本已是最新", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  156. return;
  157. }
  158. //下载最新版本
  159. string SavePath = Directory.GetCurrentDirectory();
  160. string[] FileList = myFtp.GetFileNameList("/Tools/Welling_Motor_Debug_Tool");
  161. foreach (string file in FileList)
  162. {
  163. if (file.Contains(".exe"))
  164. {
  165. myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/" + file, SavePath);
  166. MessageBox.Show("最新版本下载完成,请手动删除旧版本\r\n最新版本:" + file, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  167. System.Environment.Exit(0);
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }