I've been given some code that's been modified be several people. When this code is run, an error is displayed - (de_query_window_rep_type) operand integer value expected. The error occurs towards the bottom of this code. I'm a newbie with AEL and I could not find a reference to this de_query_window_rep_type function. Can some kind soul provide a pointer to help figure out what is going on here and what I need to do to correct the code/ Thanks.
//****************************************************************************
//
// File: my_draw_port.ael
// Description: Draws a port in the current layout window
// Author: Mats Fredriksson
// Created: May 30 2003
// Language: AEL
// Package: N/A
// Status: Experimental (No Official Support)
//
// (C) Copyright 2003, Agilent Technologies, all rights reserved.
//
// de_draw_port does not work outside an artwork macro. It does not really
// draw a Port in any case - it draws a pin.
//
// If you do want to draw a port from an AEL macro you will have to place
// a port instance instead. This function does that for you.
//
// Limitations: * Does NOT work within an artwork macro
// (use de_draw_port instead)
// * Only supports 0,90,180 or 270 deg orientations
// * Only works in Layout (can be changed easily by changing
// REP_LAY to REP_SCHEM
//
// Input parameters:
//
// x Real Required x coordinate [meters]
// y Real Required y coordinate [meters]
// orientation Int Optional Orientation 0,90,180 or 270 (Default value = 1)
// layer_number Int Optional Layer Number (Default value = 1)
// port_number Int Optinal Port Number (Default value = 1)
// port_name String Optional Port Name (Default value = "P[Port Number]")
//
// Example usage:
//
// my_draw_port(0,0,0,1,2,"P02"); // Places port #2 on layer 1
//
//
//****************************************************************************
//This should read the ports from the file extracted by the companion routines
//in allegro.
defun auto_port_add(FileName)
{
decl portFile,fline,flist;
portFile=fopen(FileName,"R");
my_setup_ports();
fline = fgets(portFile);
while ( fline != NULL)
{
if ( leftstr(fline,1) != "#")
{
flist = parse(fline);
my_draw_port(nth(0,flist), nth(1,flist),
nth(2,flist), nth(3,flist),
nth(4,flist), nth(5,flist));
//fprintf(stderr,"%s\n", fline);
} //if
fline = fgets(portFile);
} //while
fclose(portFile);
}
//This is a utility function to set some parameters
// initially sets port size only
defun my_setup_ports()
{
de_set_preference(PORT_SIZE_P,35);
de_set_preference(PORT_SIZE_UNITS_P,1);
}
defun my_draw_port(x, y, orientation, layer_number, port_number, port_name)
{
decl orient_str;
decl orient = orientation;
decl layer_nr = layer_number;
decl pnumber = port_number;
decl pname = port_name;
decl layer_name, repH, userUnits, itemInfoP;
// Default values for optional parameters
if ( orientation == NULL )
orient = 0;
if ( layer_number == NULL )
layer_nr = 1;
if ( port_number == NULL )
pnumber = 1;
if ( port_name == NULL )
pname = strcat("P",pnumber);
// Convert orientation in degrees to LEFT/RIGHT/UP/DOWN
switch (orient)
{
case 0:
orient_str = "RIGHT";
break;
case 90:
orient_str = "UP";
break;
case 180:
orient_str = "LEFT";
break;
case 270:
orient_str = "DOWN";
break;
default:
orient_str = "RIGHT";
fputs(stderr,"Warning: place_port() only supports 0,90,180,270 deg orientations!");
break;
}
// Name of the layer
layer_name = de_get_layer_name (layer_nr);
// Get conversion factor for coordinates
repH=db_get_rep(db_get_design(current_design_name()),REP_LAY);
userUnits = db_get_rep_unit_mks(repH)*1000;
// Finally place the port
itemInfoP = de_init_iteminfo( "Port", EDIT_ITEM_NEW );
de_set_item( itemInfoP ); <------------------- Error occurs here
de_set_item_parameters(itemInfoP, list(prm("SingleTextLinePortNum",strcat("\"",pnumber,"\"")),prm("layer_text_form",strcat("\"", layer_name , "\""))));
de_set_item_id(itemInfoP, pname);
de_place_item( itemInfoP, x/userUnits, y/userUnits );
itemInfoP = de_free_item(itemInfoP);
}
//****************************************************************************
//
// File: my_draw_port.ael
// Description: Draws a port in the current layout window
// Author: Mats Fredriksson
// Created: May 30 2003
// Language: AEL
// Package: N/A
// Status: Experimental (No Official Support)
//
// (C) Copyright 2003, Agilent Technologies, all rights reserved.
//
// de_draw_port does not work outside an artwork macro. It does not really
// draw a Port in any case - it draws a pin.
//
// If you do want to draw a port from an AEL macro you will have to place
// a port instance instead. This function does that for you.
//
// Limitations: * Does NOT work within an artwork macro
// (use de_draw_port instead)
// * Only supports 0,90,180 or 270 deg orientations
// * Only works in Layout (can be changed easily by changing
// REP_LAY to REP_SCHEM
//
// Input parameters:
//
// x Real Required x coordinate [meters]
// y Real Required y coordinate [meters]
// orientation Int Optional Orientation 0,90,180 or 270 (Default value = 1)
// layer_number Int Optional Layer Number (Default value = 1)
// port_number Int Optinal Port Number (Default value = 1)
// port_name String Optional Port Name (Default value = "P[Port Number]")
//
// Example usage:
//
// my_draw_port(0,0,0,1,2,"P02"); // Places port #2 on layer 1
//
//
//****************************************************************************
//This should read the ports from the file extracted by the companion routines
//in allegro.
defun auto_port_add(FileName)
{
decl portFile,fline,flist;
portFile=fopen(FileName,"R");
my_setup_ports();
fline = fgets(portFile);
while ( fline != NULL)
{
if ( leftstr(fline,1) != "#")
{
flist = parse(fline);
my_draw_port(nth(0,flist), nth(1,flist),
nth(2,flist), nth(3,flist),
nth(4,flist), nth(5,flist));
//fprintf(stderr,"%s\n", fline);
} //if
fline = fgets(portFile);
} //while
fclose(portFile);
}
//This is a utility function to set some parameters
// initially sets port size only
defun my_setup_ports()
{
de_set_preference(PORT_SIZE_P,35);
de_set_preference(PORT_SIZE_UNITS_P,1);
}
defun my_draw_port(x, y, orientation, layer_number, port_number, port_name)
{
decl orient_str;
decl orient = orientation;
decl layer_nr = layer_number;
decl pnumber = port_number;
decl pname = port_name;
decl layer_name, repH, userUnits, itemInfoP;
// Default values for optional parameters
if ( orientation == NULL )
orient = 0;
if ( layer_number == NULL )
layer_nr = 1;
if ( port_number == NULL )
pnumber = 1;
if ( port_name == NULL )
pname = strcat("P",pnumber);
// Convert orientation in degrees to LEFT/RIGHT/UP/DOWN
switch (orient)
{
case 0:
orient_str = "RIGHT";
break;
case 90:
orient_str = "UP";
break;
case 180:
orient_str = "LEFT";
break;
case 270:
orient_str = "DOWN";
break;
default:
orient_str = "RIGHT";
fputs(stderr,"Warning: place_port() only supports 0,90,180,270 deg orientations!");
break;
}
// Name of the layer
layer_name = de_get_layer_name (layer_nr);
// Get conversion factor for coordinates
repH=db_get_rep(db_get_design(current_design_name()),REP_LAY);
userUnits = db_get_rep_unit_mks(repH)*1000;
// Finally place the port
itemInfoP = de_init_iteminfo( "Port", EDIT_ITEM_NEW );
de_set_item( itemInfoP ); <------------------- Error occurs here
de_set_item_parameters(itemInfoP, list(prm("SingleTextLinePortNum",strcat("\"",pnumber,"\"")),prm("layer_text_form",strcat("\"", layer_name , "\""))));
de_set_item_id(itemInfoP, pname);
de_place_item( itemInfoP, x/userUnits, y/userUnits );
itemInfoP = de_free_item(itemInfoP);
}
I think this line:
Should be:
Anyway, I can't reproduce the problem by just running the my_draw_port() function.
my_draw_port(0,0,0,1,1,"P1");
It should draw a port on 0,0 with 0 deg rotation.