📄 common.h
字号:
//****************************
// Type struct definition
//****************************
typedef struct _PINDEF{
CString pinNum; //Electrical pin number of the pin in the gate
bool swapType; //Swap type of the pin
byte pinType; //Pin electrical type. Values are:
//S source pin
//B bidirectional pin L load pin
//C open collector pin Z terminator pin P power pin
//O or-tieable source pin T tristate pin G ground pin
//U undefined pin
CString pinName; //Optional Electrical pin name of the pin in the gate
/* DWORD GetSize()
{
DWORD dwSize = 0;
dwSize += sizeof(BOOL);
dwSize += sizeof(BYTE);
dwSize += sizeof(DWORD);
dwSize += (pinNum.GetLength()+1)*sizeof(char);
dwSize += sizeof(DWORD);
dwSize += (pinName.GetLength()+1)*sizeof(char);
return dwSize;
}
LRESULT Save(LPBYTE buf,int& nSize) //BYTE*
{
nSize = 0;
*(DWORD*)buf = pinNum.GetLength();
strcpy((char*)(buf+sizeof(DWORD)),(LPCTSTR)pinNum);
*(buf+sizeof(DWORD)+pinNum.GetLength()*sizeof(char)) = '\0';
buf +=(pinNum.GetLength()+1)*sizeof(char) +sizeof(DWORD);
nSize +=(pinNum.GetLength()+1)*sizeof(char) +sizeof(DWORD);
*(BOOL*)buf = swapType;
buf += sizeof(BOOL);
nSize += sizeof(BOOL);
*(BYTE*)buf = pinType;
buf += sizeof(BYTE);
nSize += sizeof(BYTE);
*(DWORD*)buf = pinName.GetLength();
strcpy((char*)(buf+sizeof(DWORD)),(LPCTSTR)pinNamem);
*(buf+sizeof(DWORD)+pinName.GetLength()*sizeof(char)) = '\0';
buf +=(pinName.GetLength()+1)*sizeof(char) +sizeof(DWORD);
nSize +=(pinName.GetLength()+1)*sizeof(char) +sizeof(DWORD);
return S_OK;
}
LRESULT Read(LPBYTE buf,int& nSize)
{
nSize = 0;
DWORD dwLength = *(DWORD*)buf;
buf += sizeof(DWORD);
nSize += sizeof(DWORD);
pinNum = (char*)buf;
buf +=(dwLength+1)*sizeof(char) ;
nSize +=(dwLength+1)*sizeof(char) ;
swapType = *(BOOL*)buf ;
buf += sizeof(BOOL);
nSize += sizeof(BOOL);
pinType = *(BYTE*)buf;
buf += sizeof(BYTE);
nSize += sizeof(BYTE);
dwLength = *(DWORD*)buf;
buf += sizeof(DWORD);
nSize += sizeof(DWORD);
pinName = (char*)buf;
buf +=(dwLength+1)*sizeof(char) ;
nSize +=(dwLength+1)*sizeof(char) ;
return S_OK;
}*/
} PINDEF,*LPPINDEF;
typedef struct _ATTRIBUTEDEF{
CString attrName;
CString attrVal;
} ATTRIBUTEDEF;
typedef struct _GATADEF{
CString gateDecals; //List of alternate schematic decal names,
//separated by colons: NAME:NAME:… A gate decal
//may be up to 40 alphanumeric characters.
//The list may contain a maximum of four alternates.
bool gateswap; //Gate swap type
UINT pins; //Number of pins in the gate
CArray <LPPINDEF,LPPINDEF> pinCA;
CArray <CString,CString&> pinStrCA;
/* LRESULT Save(LPBYTE buf,int& nSize)
{
nSize = 0;
int size;
*(DWORD*)buf = pinCA.GetSize();
buf += sizeof(DWORD);
nSize += sizeof(DWORD);
for(int i = 0;i<pinCA.GetSize();i++)
{
pinCA.GetAt(i)->Save(buf,size);
buf +=size;
nSize += size;
}
}
LRESULT Read(LPBYTE buf,int& nSize)
{
nSize = 0;
int size;
DWORD dwLength = *(DWORD*)buf;
buf += sizeof(DWORD);
nSize += sizeof(DWORD);
for(int i = 0;i<dwLength;i++)
{
PINDEF* pt = new PINDEF;
PINDEF->Read(buf,size);
buf +=size;
nSize += size;
pinCA.Add(pt);
}
}*/
~_GATADEF()
{
pinStrCA.RemoveAll();
for(int i=0;i<pinCA.GetSize();i++)
if(pinCA.GetAt(i))
delete pinCA.GetAt(i);
}
}GATEDEF,*LPGATEDEF;
typedef struct _PARTDEF{
CString partName; //
CString pcbDecal; //
CString alphaNumeric;
CString UNIT; //Coordinate units type Can be either Imperial (mils) or Metric (mm),
bool isalpha;
UINT numPins; //
UINT numSignals; //Number of standard signals predefined in the part,
UINT numCpins; //Number of connector pins
UINT numGates; //Number of gates in the part Values range from 0 to 702.
UINT numAlphaN; //Number of alphanumeric pins defined in the part Values range from 0 to 32,767.
byte flag; //Decimal value of an eight-bit binary bit string:
//0 = normal part 1 = connector 2 = off-page reference.
CString type; //Logic type Values can be any three alphanumeric characters.
CArray <CString,CString&> alphaNumericCA;
CArray <LPGATEDEF,LPGATEDEF> gateCA;
CArray <LPPINDEF,LPPINDEF> pinCA;
CArray <CString,CString&> pinStrCA;
//CArray <GATEDEF,GATEDEF&> gateCA;
LRESULT GetAlphaNumeric(void* LP)
{
CString tmpStr,pinNum;
CString alpaStr;
// bool flag;
_PARTDEF* pPart = (_PARTDEF*) LP;
tmpStr=pPart->alphaNumeric;
tmpStr.Remove(10);
tmpStr.Remove(13);
alphaNumericCA.RemoveAll();
do{
if(tmpStr.Find(' ',0)!=-1) //' ' SPACE
{
pinNum=tmpStr.Left(tmpStr.Find(' ',0));
tmpStr=tmpStr.Right(tmpStr.GetLength()-tmpStr.Find(' ')-1);
}
else //the last pinNum
{
pinNum=tmpStr;
tmpStr="";
}
if(pinNum!="")
{
pPart->alphaNumericCA.Add(pinNum);
// pinName="";
}
}while(tmpStr!="");
if(UINT(pPart->alphaNumericCA.GetSize())==pPart->numPins)
return true;
else
return false;
}
LRESULT GetPinDef(struct _PARTDEF* pPart,CString srcDefStr)
{
CString pinNumStr,tmpStr,pinName,log,pinDefStr;
char CHAR;
//*******get pinNum ********
if(srcDefStr.Find(',')!=-1)
CHAR=',';
else if(srcDefStr.Find(' ')!=-1)
CHAR=' '; //set up TAB
pPart->pinStrCA.RemoveAll();
do {
//********* read one line from m_log
if(srcDefStr.Find(10)!=-1)
{
pinDefStr=srcDefStr.Left(srcDefStr.Find(10,0)+1);
srcDefStr=srcDefStr.Right(srcDefStr.GetLength()-srcDefStr.Find(13)-2);
}
else
{
pinDefStr=srcDefStr;
srcDefStr="";
}
pinDefStr.Remove(10);
pinDefStr.Remove(13);
pinNumStr=pinDefStr.Left(pinDefStr.Find(CHAR)); //get pin number
pinDefStr=pinDefStr.Right(pinDefStr.GetLength()-pinDefStr.Find(CHAR)-1);
for(int sequence=0;sequence<=pPart->alphaNumericCA.GetSize();sequence++)
{
if(sequence==pPart->alphaNumericCA.GetSize())
{
tmpStr="Can't find alphaNumeric pinNum of "+pinNumStr;
AfxMessageBox(tmpStr);
return false;
}
else if(pinNumStr==pPart->alphaNumericCA.GetAt(sequence))
{
pinNumStr.Format("%d",sequence+1);
break;
}
}
//******** get pinName
if(pinDefStr.Find(CHAR)!=-1)
{
pinName=pinDefStr.Left(pinDefStr.Find(CHAR));
if(pinName=="IO")
pinName=pinName+pinNumStr;
pinDefStr=pinDefStr.Right(pinDefStr.GetLength()-pinDefStr.Find(CHAR));
pinName=pinName+pinDefStr;
}
else
{
pinName=pinDefStr; //Ex:pinDefStr= GND;
if(pinName=="IO")
pinName=pinName+pinNumStr;
}
//deal with duplicate TAB and TAB_end
if(pinName.GetAt(pinName.Find(CHAR)+1)==CHAR)
{
pinName.SetAt(pinName.Find(CHAR),'.');
pinName.Remove('.');
}
if(pinName.ReverseFind(CHAR)==pinName.GetLength()-1)
pinName.SetAt(pinName.ReverseFind(CHAR),0);
pinName.Replace(CHAR,47); //47:/
if(pinName.GetLength()>14 && pinName.Find(47)!=-1)
pinName=pinName.Right(pinName.GetLength()-pinName.Find(47)-1);
pinDefStr=pinNumStr+".0.U."+pinName;
pPart->pinStrCA.Add(pinDefStr);
} while(srcDefStr!="");
if(pPart->pinStrCA.GetSize()!=(int)pPart->numPins)
AfxMessageBox("Number of pins in sourceFile not equal with alphaNumeric pinNumer!",2);
return true;
}
~_PARTDEF()
{
alphaNumericCA.RemoveAll();
for(int i=0;i<gateCA.GetSize();i++)
if(gateCA.GetAt(i))
delete gateCA.GetAt(i); //set free ram :delete point
for(i=0;i<pinCA.GetSize();i++)
if(pinCA.GetAt(i))
delete pinCA.GetAt(i);
if(pinStrCA.GetSize()!=0)
pinStrCA.RemoveAll();
}
} PARTDEF,*LPPARTDEF;
PARTDEF part;
/*
friend LRESULT GetNumeric(void* part, CString alpaStr,int part_type)
{
switch part_type:
case 1:
_PARTDEF* pDef = (_PARTDEF*) part;
case 2:
int* pDef = (int*) part;
;
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -