/* SCM_MSG (SCM) -- SCM Message System Action */ /* SCM_MSG (SCM) -- SCM Messagesystem-Aktion */ /* -- EXECUTED AFTER RECEIVING A MESSAGE -- */ /* // Copyright (c) 2000-2013 Bartels System GmbH, Muenchen // Author: Roman Ludwig // Changes History: // rl (131029) RELEASED FOR BAE V8.0. // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (080624) ENHANCEMENT: // Added part group selection support. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040826) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (000821) ENHANCEMENT: // Added multi symbol part scan support. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (000821) RELEASED FOR BAE V4.6. // rl (000821) ENHANCEMENT: // Added HighEnd schematic part search function. // rl (000418) ORIGINAL CODING. // // DESCRIPTION // // The scm_msg User Language program provides functions to be // performed when receiving messages from other modules. // The actions depend on the input string received. */ // Includes #include "pop.ulh" // User Language popup utilities // Disable undo state request #pragma ULCALLERNOUNDO // Messages string REPSFOUND = M("Symbol '%s' aus Bauteil '%s'.", "Symbol '%s' of Part '%s'."); string REPSNFOUND = M("Symbol '%s' zu Bauteil '%s' nicht gefunden!", "Symbol '%s' for Part '%s' not found!"); string REPSCANSYM = M(" +/- Blaettern, Liste mit ", " +/- Scan others. for list."); string REPSYMLIST = M("Symbole zu Layoutbauteil '%s' :", "Symbols packed into layout part '%s' :"); string REPSYMBOL = M("'%s' Blatt '%s'","'%s' Sheet '%s'"); string ERRNOTFOUND = M("Layoutbauteil '%s' nicht gefunden!", "Layout part '%s' not found!"); string ERRLOAD = M("Fehler beim Laden des Elementes '%s'!", "Error loading element '%s'!"); string ERRILLMSG = M("Unbekannter Messagetyp empfangen!", "Received unknown message type!"); // INI file parameter name definitions #define PAR_ZOOMEXP "SYMZOOMEXP_SCM"// Symbol zoom expansion value // Global User Language program variables #define UL_SCMCON "scmcon" // ULP: SCM connection utilities #define GV_HLREQUEST "hlrequest" // Highlight request variable // Global variables static string msgbuf /* Message string buffer */; static double ZOOMEXP = bae_inidblval(PAR_ZOOMEXP,0.0001) /* Symbol zoom window expansion */; // Main program void main() { // Get the message string if ((msgbuf=bae_getmsg())=="") { // No message found bae_prtdialog(""); exit(0); } // Evaluate the message ID switch (atoi(getmsgitem())) { // Set integer variable case MSGID_SETIVAR : setivar(); break; // Set double variable case MSGID_SETDVAR : setdvar(); break; // Set string variable case MSGID_SETSVAR : setsvar(); break; // Run ULC script case MSGID_RUNULC : runulc(); break; // Find schematic part case MSGID_FINDSPRT : findsprt(); break; // Find hierarchical schematic part case MSGID_FINDSHPRT : findshprt(); break; // Select part group case MSGID_SELPGRP : selpgroup(); break; // Highlight/zoom net case MSGID_NETZOOMHL : highlightzoomnet(); break; // Center mouse, activate window case MSGID_MOUSEGRAB : mousegrab(1); break; // Ignore layout editor specific messages case MSGID_PLCPART : case MSGID_PLCHPART : case MSGID_SELPSET : case MSGID_LLPRTMAC : case MSGID_SELHPGRP : case MSGID_SELHPSET : case MSGID_PLCHSPART : case MSGID_DSELPOPT : case MSGID_PLCPGRP : break; default : error(ERRILLMSG); } } static void setivar() /* // Set global integer variable */ { string varname /* Variable name */; string varvalue /* Variable value string */; // Get the variable name and value if ((varname=getmsgitem())=="" || (varvalue=getmsgitem())=="") return; // Set the variable varset(varname,atoi(varvalue)); } static void setdvar() /* // Set global double variable */ { string varname /* Variable name */; string varvalue /* Variable value string */; // Get the variable name and value if ((varname=getmsgitem())=="" || (varvalue=getmsgitem())=="") return; // Set the variable varset(varname,atof(varvalue)); } static void setsvar() /* // Set global string variable */ { string varname /* Variable name */; string varvalue /* Variable value string */; // Get the variable name and value if ((varname=getmsgitem())=="" || (varvalue=getmsgitem())=="") return; // Set the variable varset(varname,varvalue); } static void runulc() /* // Run ULC script */ { string progname /* Program name */; // Get the program name if ((progname=getmsgitem())=="") return; // Run the program ulsystem(progname,0); } static void selpgroup() /* // Group select the requested parts */ { index C_FIGURE fig /* Figure list index */; index C_NREF nref /* Named reference index */; index C_ATTRIBUTE attr /* Attribute index */; string rasspname /* Requested assigned part name */; // Get the part name while ((rasspname=getmsgitem())!="") { strlower(rasspname); forall (fig where fig.TYP==C_FIGNREF) { nref=fig.NREF; forall (attr of nref) if (attr.NAME=="$") { if (attr.VALUE==rasspname) scm_elemgrpchg(fig,1); break; } } } } static void findsprt() /* // Find schematic part */ { index C_FIGURE fig /* Figure list index */; string filename /* Plan file name */; string planname /* Plan name */; string asspname /* Assigned part name */; string rasspname /* Requested assigned part name */; string partname /* Part name */; string rpinname /* Requested part pin name */; string pinname /* Part pin name */; string pinval /* Part pin attribute value */; string partl[] /* Part name list */; int partn = 0 /* Part name count */; STRINGS headl /* Header string list */; int headn = 2 /* Header string count */; STRINGS el /* Entry string list */; int en = 0 /* Entry list */; string msg /* Message string buffer */; char c /* Character input buffer */; int i /* Loop control variable */; // Abort if invalid plan class if (bae_planddbclass()!=DDBCLSCM) error_class(); // Get the plan file name filename=bae_planfname(); // Get part name if ((rasspname=getmsgitem())=="") return; strlower(rasspname); // Scan the SCM parts list partname=""; while (scanddbenames(filename,DDBCLSPLST,partname)==1) { // Get the assigned part name con_getddbpattrib(filename,partname,"","$",asspname); // Check if part found if (asspname==rasspname) { partl[partn]=partname; partn++; // Get the part plan name planname=cap_partplan(filename,partname); sprintf(el[en],REPSYMBOL,partname,planname); en++; } } // Check if part found if (!partn) errormsg(ERRNOTFOUND,rasspname); // Check if part pin known if ((rpinname=getmsgitem())!="" && (pinname=getmsgitem())!="") // Search pin gate for (i=0;i=en) i=0; } // Check if previous error request else if (c=='-') { i--; if (i<0) i=en-1; } else { break; } } break; } } } static void findshprt() /* // Find schematic hierarchical part */ { index C_FIGURE fig /* Figure list index */; string filename /* Plan file name */; string planname /* Plan name */; string asspname /* Assigned part name */; string partname /* Part name */; string brefname /* Block reference name */; string msg /* Message string buffer */; int i /* Loop control variable */; // Abort if invalid plan class if (bae_planddbclass()!=DDBCLSCM) error_class(); // Get the plan file name filename=bae_planfname(); // Get part name if ((partname=getmsgitem())=="") return; for (i=0;partname[i]!='\0';i++) if (partname[i]==',') { partname[i]='\0'; break; } // Get assigned part name if ((asspname=getmsgitem())=="") return; for (i=0;asspname[i]!='\0';i++) if (asspname[i]==',') { asspname[i]='\0'; break; } // Get plan name if ((planname=getmsgitem())=="") return; for (i=0;planname[i]!='\0';i++) if (planname[i]==',') { planname[i]='\0'; break; } // Get block reference name if ((brefname=getmsgitem())=="") return; for (i=0;brefname[i]!='\0';i++) if (brefname[i]==',') { brefname[i]='\0'; break; } // Test if valid part on other plan selected if (planname!=bae_planename()) { // Save current plan with verification verifysave(); // Load other plan if (bae_loadelem(filename,planname,DDBCLSCM)==(-1)) errormsg(ERRLOAD,planname); } // Search for the selected part if (cap_nrefsearch(partname,fig)) { // Part not found; build message sprintf(msg,REPSNFOUND,partname,asspname); error(msg); } else { // Part found // Perform zoom window to the part bae_clriactqueue(); bae_storemouseiact(1,fig.RLX-ZOOMEXP,fig.RLY-ZOOMEXP,0,LMB); bae_storemouseiact(1,fig.RUX+ZOOMEXP,fig.RUY+ZOOMEXP,0,LMB); call(MNU_BAEZOOMWND); // Build message sprintf(msg,REPSFOUND,partname,asspname); bae_prtdialog(msg); } } static void highlightzoomnet() /* // Highlight and zoom to the requested net */ { string netname /* Net name */; // Get the net name netname=getmsgitem(); varset(GV_HLREQUEST,netname); // Zoom to net bae_clriactqueue(); bae_storemenuiact(1,5,LMB); bae_storetextiact(1,netname); ulsystem(UL_SCMCON,1); } static string getmsgitem() /* // Get the next message item from the message buffer */ { string item /* Message item string */; int spos /* Item seperator position */; // Get the item seperator position spos=strscannext(msgbuf," ",0,1); // Get the message item item=strextract(msgbuf,0,spos-2); // Truncate buffer msgbuf=strextract(msgbuf,spos,strlen(msgbuf)); // Return the message item return(item); } // User Language program end