|
这节我们讲下添加新的芯片型号,打开维护窗口就可以添加了,自己设置好各个参数然后点增加就可以了。
但是这样要填的东西不少,麻烦。这里我们有个快捷的方法,就是找到兼容的型号,点一下,直接修改,然后增加。例如我们添加个24c16的,直接选个24的,然后修改一下参数就可以添加了。
看下列表中有那个型号没
操作就这么简单。记住这里添加了实际上还没存入支持库的,为什么不直接保存呢,这里还出于一个原因就是先给用户检测没问题了,手动点一下保存按钮才行。
当然程序处理接不这么简单,需要考虑唯一性,还有个参数的校验,这可不能出错的。下面我们就来看看这个处理函数:
- void CProgDeviceManage::OnDeviceAddNew()
- {
- // TODO: Add your control notification handler code here
- CString temp;
- ZeroMemory(&m_stDFile, sizeof(DeviceListFileStruct));
- // ZeroMemory(&m_stDFileHead, sizeof(DeviceListFileHeadStruct));
- UpdateData(true);
- //device name
- if (m_sDeviceName.IsEmpty())
- {
- AfxMessageBox("芯片名称不能为空");
- return;
- }
- strcpy(m_stDFile.DeviceName,m_sDeviceName);
- for (int n=0; n<parent->m_arDeviceList.GetSize(); n++)
- {
- temp = parent->m_arDeviceList.GetAt(n).DeviceName;
- if(m_stDFile.DeviceName == temp)
- {
- AfxMessageBox("列表中已有该芯片型号");
- return;
- }
- }
- //Device Type
- m_cDeviceType.GetWindowText(temp);
- if (temp.IsEmpty())
- {
- AfxMessageBox("芯片类型不能为空");
- return;
- }
- int index;
- CString tname;
- // m_cDeviceType.GetWindowText(temp);
- for (int i=0; i<parent->m_arTypeList.GetSize(); i++)
- {
- tname = parent->m_arTypeList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceType = parent->m_arTypeList.GetAt(index).TypeVal;
- // if (temp == "EPROM") m_stDFileHead.EpromCount += 1;
- // if (temp == "PROM") m_stDFileHead.PromCount += 1;
- // if (temp == "MPU") m_stDFileHead.MPUCount += 1;
- // if (temp == "PLD") m_stDFileHead.PLDCount += 1;
- m_stDFile.DeviceManuID = (DWORD)strtoul(m_sDeviceManuID, NULL, 16);
- m_stDFile.DeviceID = (DWORD)strtoul(m_sDeviceID, NULL, 16);
- m_stDFile.DeviceCheckCRC = (DWORD)strtoul(m_sDeviceCheckCRC, NULL, 16);
-
- m_cOperationID.GetWindowText(temp);
- for (i=0; i<parent->m_arOperationList.GetSize(); i++)
- {
- tname = parent->m_arOperationList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.OperationID = parent->m_arOperationList.GetAt(index).TypeVal;
- if (m_sDeviceManuName.IsEmpty())
- {
- AfxMessageBox("厂家名称不能为空");
- return;
- }
- strcpy(m_stDFile.DeviceManuName,m_sDeviceManuName);
- m_cDeviceSize.GetWindowText(temp);
- for (i=0; i<parent->m_arSizeList.GetSize(); i++)
- {
- tname = parent->m_arSizeList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceSize = parent->m_arSizeList.GetAt(index).TypeVal;
- m_cDeviceDataWidth.GetWindowText(temp);
- for (i=0; i<parent->m_arDataWidthList.GetSize(); i++)
- {
- tname = parent->m_arDataWidthList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceDataWidth = parent->m_arDataWidthList.GetAt(index).TypeVal;
- m_cDevicePackage.GetWindowText(temp);
- for (i=0; i<parent->m_arPackageList.GetSize(); i++)
- {
- tname = parent->m_arPackageList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DevicePackage = parent->m_arPackageList.GetAt(index).TypeVal;
- m_cDevicePinCount.GetWindowText(temp);
- for (i=0; i<parent->m_arPinList.GetSize(); i++)
- {
- tname = parent->m_arPinList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DevicePinCount = parent->m_arPinList.GetAt(index).TypeVal;
- m_cDeviceVCC.GetWindowText(temp);
- for (i=0; i<parent->m_arVCCList.GetSize(); i++)
- {
- tname = parent->m_arVCCList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceVCC = parent->m_arVCCList.GetAt(index).TypeVal;
- m_cDeviceVPP.GetWindowText(temp);
- for (i=0; i<parent->m_arVPPList.GetSize(); i++)
- {
- tname = parent->m_arVPPList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceVPP = parent->m_arVPPList.GetAt(index).TypeVal;
- m_cDeviceAdapter.GetWindowText(temp);
- for (i=0; i<parent->m_arAdapterList.GetSize(); i++)
- {
- tname = parent->m_arAdapterList.GetAt(i).TypeName;
- if (temp == tname)
- index = i;
- }
- m_stDFile.DeviceAdapter = parent->m_arAdapterList.GetAt(index).TypeVal;
- strcpy(m_stDFile.Datasheet,m_sDeviceDatasheet);
- strcpy(m_stDFile.DeviceManuICO,m_sDeviceManuICO);
- strcpy(m_stDFile.DeviceICICO,m_sDeviceICICO);
- strcpy(m_stDFile.DeviceNote,m_sDeviceNote);
- parent->m_arDeviceList.Add(m_stDFile);
- int DeviceCount;
- CString DeviceName;
- DeviceCount = parent->m_arDeviceList.GetSize();
- m_cDeviceList.ResetContent();
- for (n=0;n<DeviceCount;n++)
- {
- DeviceName = parent->m_arDeviceList.GetAt(n).DeviceName;
- m_cDeviceList.AddString(DeviceName);
- }
- }
复制代码 这些步骤光看代码很难理解的,建议debug一下。
|
|