DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 3555|回复: 1
打印 上一主题 下一主题

[UUProg] uuprog开发教程:芯片支持库维护5

[复制链接]
跳转到指定楼层
楼主
发表于 2014-12-28 11:38:47 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
这节我们讲下添加新的芯片型号,打开维护窗口就可以添加了,自己设置好各个参数然后点增加就可以了。

但是这样要填的东西不少,麻烦。这里我们有个快捷的方法,就是找到兼容的型号,点一下,直接修改,然后增加。例如我们添加个24c16的,直接选个24的,然后修改一下参数就可以添加了。

看下列表中有那个型号没

操作就这么简单。记住这里添加了实际上还没存入支持库的,为什么不直接保存呢,这里还出于一个原因就是先给用户检测没问题了,手动点一下保存按钮才行。
当然程序处理接不这么简单,需要考虑唯一性,还有个参数的校验,这可不能出错的。下面我们就来看看这个处理函数:
  1. void CProgDeviceManage::OnDeviceAddNew()
  2. {
  3.         // TODO: Add your control notification handler code here
  4.         CString temp;
  5.         ZeroMemory(&m_stDFile, sizeof(DeviceListFileStruct));
  6. //        ZeroMemory(&m_stDFileHead, sizeof(DeviceListFileHeadStruct));

  7.         UpdateData(true);
  8.         //device name
  9.         if (m_sDeviceName.IsEmpty())
  10.         {
  11.                 AfxMessageBox("芯片名称不能为空");
  12.                 return;
  13.         }
  14.         strcpy(m_stDFile.DeviceName,m_sDeviceName);
  15.         for (int n=0; n<parent->m_arDeviceList.GetSize(); n++)
  16.         {
  17.                 temp = parent->m_arDeviceList.GetAt(n).DeviceName;
  18.                 if(m_stDFile.DeviceName == temp)
  19.                 {
  20.                 AfxMessageBox("列表中已有该芯片型号");
  21.                 return;
  22.                 }
  23.         }
  24.         //Device Type
  25.         m_cDeviceType.GetWindowText(temp);
  26.         if (temp.IsEmpty())
  27.         {
  28.                 AfxMessageBox("芯片类型不能为空");
  29.                 return;
  30.         }

  31.         int index;
  32.         CString tname;
  33. //        m_cDeviceType.GetWindowText(temp);
  34.         for (int i=0; i<parent->m_arTypeList.GetSize(); i++)
  35.         {
  36.                 tname = parent->m_arTypeList.GetAt(i).TypeName;
  37.                 if (temp == tname)
  38.                         index = i;
  39.         }
  40.         m_stDFile.DeviceType = parent->m_arTypeList.GetAt(index).TypeVal;

  41. //        if (temp == "EPROM") m_stDFileHead.EpromCount += 1;
  42. //        if (temp == "PROM") m_stDFileHead.PromCount += 1;
  43. //        if (temp == "MPU") m_stDFileHead.MPUCount += 1;
  44. //        if (temp == "PLD") m_stDFileHead.PLDCount += 1;

  45.         m_stDFile.DeviceManuID = (DWORD)strtoul(m_sDeviceManuID, NULL, 16);
  46.         m_stDFile.DeviceID = (DWORD)strtoul(m_sDeviceID, NULL, 16);
  47.         m_stDFile.DeviceCheckCRC = (DWORD)strtoul(m_sDeviceCheckCRC, NULL, 16);
  48.         
  49.         m_cOperationID.GetWindowText(temp);
  50.         for (i=0; i<parent->m_arOperationList.GetSize(); i++)
  51.         {
  52.                 tname = parent->m_arOperationList.GetAt(i).TypeName;
  53.                 if (temp == tname)
  54.                         index = i;
  55.         }
  56.         m_stDFile.OperationID = parent->m_arOperationList.GetAt(index).TypeVal;

  57.         if (m_sDeviceManuName.IsEmpty())
  58.         {
  59.                 AfxMessageBox("厂家名称不能为空");
  60.                 return;
  61.         }
  62.         strcpy(m_stDFile.DeviceManuName,m_sDeviceManuName);

  63.         m_cDeviceSize.GetWindowText(temp);
  64.         for (i=0; i<parent->m_arSizeList.GetSize(); i++)
  65.         {
  66.                 tname = parent->m_arSizeList.GetAt(i).TypeName;
  67.                 if (temp == tname)
  68.                         index = i;
  69.         }
  70.         m_stDFile.DeviceSize = parent->m_arSizeList.GetAt(index).TypeVal;

  71.         m_cDeviceDataWidth.GetWindowText(temp);
  72.         for (i=0; i<parent->m_arDataWidthList.GetSize(); i++)
  73.         {
  74.                 tname = parent->m_arDataWidthList.GetAt(i).TypeName;
  75.                 if (temp == tname)
  76.                         index = i;
  77.         }
  78.         m_stDFile.DeviceDataWidth = parent->m_arDataWidthList.GetAt(index).TypeVal;

  79.         m_cDevicePackage.GetWindowText(temp);
  80.         for (i=0; i<parent->m_arPackageList.GetSize(); i++)
  81.         {
  82.                 tname = parent->m_arPackageList.GetAt(i).TypeName;
  83.                 if (temp == tname)
  84.                         index = i;
  85.         }
  86.         m_stDFile.DevicePackage = parent->m_arPackageList.GetAt(index).TypeVal;

  87.         m_cDevicePinCount.GetWindowText(temp);
  88.         for (i=0; i<parent->m_arPinList.GetSize(); i++)
  89.         {
  90.                 tname = parent->m_arPinList.GetAt(i).TypeName;
  91.                 if (temp == tname)
  92.                         index = i;
  93.         }
  94.         m_stDFile.DevicePinCount = parent->m_arPinList.GetAt(index).TypeVal;

  95.         m_cDeviceVCC.GetWindowText(temp);
  96.         for (i=0; i<parent->m_arVCCList.GetSize(); i++)
  97.         {
  98.                 tname = parent->m_arVCCList.GetAt(i).TypeName;
  99.                 if (temp == tname)
  100.                         index = i;
  101.         }
  102.         m_stDFile.DeviceVCC = parent->m_arVCCList.GetAt(index).TypeVal;

  103.         m_cDeviceVPP.GetWindowText(temp);
  104.         for (i=0; i<parent->m_arVPPList.GetSize(); i++)
  105.         {
  106.                 tname = parent->m_arVPPList.GetAt(i).TypeName;
  107.                 if (temp == tname)
  108.                         index = i;
  109.         }
  110.         m_stDFile.DeviceVPP = parent->m_arVPPList.GetAt(index).TypeVal;

  111.         m_cDeviceAdapter.GetWindowText(temp);
  112.         for (i=0; i<parent->m_arAdapterList.GetSize(); i++)
  113.         {
  114.                 tname = parent->m_arAdapterList.GetAt(i).TypeName;
  115.                 if (temp == tname)
  116.                         index = i;
  117.         }
  118.         m_stDFile.DeviceAdapter = parent->m_arAdapterList.GetAt(index).TypeVal;
  119.         strcpy(m_stDFile.Datasheet,m_sDeviceDatasheet);
  120.         strcpy(m_stDFile.DeviceManuICO,m_sDeviceManuICO);
  121.         strcpy(m_stDFile.DeviceICICO,m_sDeviceICICO);
  122.         strcpy(m_stDFile.DeviceNote,m_sDeviceNote);

  123.         parent->m_arDeviceList.Add(m_stDFile);
  124.         int DeviceCount;
  125.         CString DeviceName;

  126.         DeviceCount = parent->m_arDeviceList.GetSize();
  127.         m_cDeviceList.ResetContent();
  128.         for (n=0;n<DeviceCount;n++)
  129.         {
  130.         DeviceName = parent->m_arDeviceList.GetAt(n).DeviceName;
  131.         m_cDeviceList.AddString(DeviceName);
  132.         }
  133. }
复制代码
这些步骤光看代码很难理解的,建议debug一下。


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享分享 支持支持 反对反对
沙发
发表于 2018-12-27 21:59:03 | 只看该作者
谢谢分享  支持楼主
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|文字版|手机版|DIY编程器网 ( 桂ICP备14005565号-1 )

GMT+8, 2024-4-23 16:34 , 耗时 0.093377 秒, 24 个查询请求 , Gzip 开启.

各位嘉宾言论仅代表个人观点,非属DIY编程器网立场。

桂公网安备 45031202000115号

DIY编程器群(超员):41210778 DIY编程器

DIY编程器群1(满员):3044634 DIY编程器1

diy编程器群2:551025008 diy编程器群2

QQ:28000622;Email:libyoufer@sina.com

本站由桂林市临桂区技兴电子商务经营部独家赞助。旨在技术交流,请自觉遵守国家法律法规,一旦发现将做封号删号处理。

快速回复 返回顶部 返回列表