Java program for research team

Associate
Joined
13 Jan 2007
Posts
2,424
Location
Belfast,Northern Ireland
So i've basically asked for a little bit of extra work on my exchange as I have a little too much free time to drink myself into an early grave. A research group in the semi-conductor school want me to make them a program which they believe is a small enough project to do in 6weeks or so of spare time. Basically I have a text file I will use as input and from this produce a graphical representation from the data, basically the data gives enough information to draw a certain circuit from hand. I will be programming it in java and already im feeling a bit out of my depth. I can think of general stuff and possible solutions but im not sure its even possible to implement this properly.

He is a sample of the input data, this is merely one circuit, the real file contains a LOT of these

.subckt PM_RR_TXPATH%XSER16TO2/XI3/XSER4TO2_0/XI49/XI5/NET11 1 4 10
c0 36 0 0.0561078f
c1 34 0 0.0585514f
c2 33 0 0.028825f
c3 32 0 0.00656662f
c4 30 0 0.0100932f
c5 28 0 0.0108371f
c6 25 0 0.310483f
c7 23 0 0.0394633f
c8 19 0 0.0536726f
c9 10 0 0.0122062f
c10 9 0 0.0408209f
c11 4 0 0.0122284f
c12 1 0 0.0183903f
l13 44 32 9f
r14 44 33 0.0923171 $w=1.8e-07 $l=0.09 $layer=m1_par $X=25.575 $Y=-21.745
+ $X2=25.575 $Y2=-21.655
l15 30 43 12f
r16 36 43 0.1735 $w=1.2e-07 $l=0.12 $layer=m1_par $X=24.735 $Y=-21.865
+ $X2=24.735 $Y2=-21.745
l17 28 42 12f
r18 34 42 0.1735 $w=1.2e-07 $l=0.12 $layer=m1_par $X=23.895 $Y=-21.865
+ $X2=23.895 $Y2=-21.745
r19 25 33 0.925 $w=1.4e-07 $l=0 $layer=VIA1 $X=25.575 $Y=-21.655 $X2=25.575
+ $Y2=-21.655
l20 30 41 9f
r21 41 23 0.0923171 $w=1.8e-07 $l=0.09 $layer=m1_par $X=24.735 $Y=-21.745
+ $X2=24.735 $Y2=-21.655
r22 23 21 0.925 $w=1.4e-07 $l=0.16 $layer=VIA1 $X=24.735 $Y=-21.655
+ $X2=24.735 $Y2=-21.495
l23 21 40 84f
r24 40 25 0.153216 $w=5e-07 $l=0.855102 $layer=m2_par $X=24.735 $Y=-21.495
+ $X2=25.575 $Y2=-21.655
l25 28 39 9f
r26 39 19 0.0923171 $w=1.8e-07 $l=0.09 $layer=m1_par $X=23.895 $Y=-21.745
+ $X2=23.895 $Y2=-21.655
r27 19 17 0.925 $w=1.4e-07 $l=0.16 $layer=VIA1 $X=23.895 $Y=-21.655
+ $X2=23.895 $Y2=-21.495
l28 17 38 84f
r29 38 21 0.153216 $w=5e-07 $l=0.84 $layer=m2_par $X=23.895 $Y=-21.495
+ $X2=24.735 $Y2=-21.495
l30 32 37 12f
r31 9 37 0.1735 $w=1.2e-07 $l=0.12 $layer=m1_par $X=25.575 $Y=-21.865
+ $X2=25.575 $Y2=-21.745
r32 10 9 5 $w=1.2e-07 $l=0.2 $layer=CA_rx $X=25.415 $Y=-21.745 $X2=25.575
+ $Y2=-21.865
r33 36 4 5 $w=1.2e-07 $l=0.2 $layer=CA_rx $X=24.735 $Y=-21.865 $X2=24.895
+ $Y2=-21.745
r34 34 1 5 $w=1.2e-07 $l=0.2 $layer=CA_rx $X=23.895 $Y=-21.865 $X2=24.055
+ $Y2=-21.745
.ends

Basically the goal is to get one input working before i look at the bigger picture. I know how to read the input but as you can see the information is all over the place, would pulling all this info into an array be too messy? Worst part is some of the data isn't needed essentially. I can use a space as a common delimiter to pull out all that data into an array okay, right? Then its a case of switch statements and stuff to make sure the right data does the right job?

I essentially have no background in this topic and its making the whole thing more difficult. Can I make this work easy enough? Currently im just trying to blitz a big java bible to get ideas of how I will actually draw stuff.

Apologies for the wall of text
 
Perhaps my first post was a little frantic since im unsure what im dealing with. As a starting point im curious how I can extract this information, split up correctly.

.subckt PM_RR_TXPATH%XSER16TO2/XI3/XSER4TO2_0/XI49/XI5/NET11 1 4 10
c0 36 0 0.0561078f
c1 34 0 0.0585514f

The problem being the types differ obviously, a dynamic array of string could be used then I use cast on them?

More specifically the first line is the title, however I need to extract the numbers after NET11 individually, how can i do it?

Solutions arent necessary but a point in the right direction would be immensely appreciated
 
Tokenise the line as a string, using spaces (or tabs, if they are tabs) to separated.

When dealing with delimited files, I prefer to tokenise and not "split", at first it may seem a little trickier but once you get the hang of it, you'll have better control :)
 
You are essentially writing a parser so it may help to set out some rules for the various bits of data, for example what is c1 34 0 0.0585514f and what are the valid formats for this data? This will help you further down the line and can also help error detection should you get a badly formatted file (which would otherwise crash your program or cause undesirable results).

Not sure on your background but this was the sort of thing I covered when learning about programming language implementation for my degree. I may be of use to get some background knowledge on how parsers work and the various stages involved.
 
My first impression is eughhh!

Did they not give you some sort of file specification?

I'm afraid I don't really understand the file, but I would start by creating a class that has all the stuff you need for each 'line' of the circuit. Then as you read the file line by line, you create an object and stick this in some storage(my Java is a little rusty but is there an Object List? Or is there an equivalent generics of List<Type> ).

Then once you've read and processed the whole file you can iterate through the list and plot it to a canvas.
 
First off thanks for the advice, I thought this topic might slip away unnoticed. Im assuming tokenizing won't work in my case then and I must write a parser? This does not sound like fun!

c0 36 0 0.0561078f

For example this line essentially mean there is a node (number 36), as it begins with a c it is grounded, its simply c0 because its the first one. The horrible looking number at the end is the current flowing through it or something. Essentially that part just needs to be a label.

Sorry for the power explaination, I got a 15minute explaination in broken english so it was a little difficult to say the least!
 
Back
Top Bottom