C++ header implementation

Hello,
I've had this question before, but now I'm trying it from a new
approach. THe first time I tried to implement this headerfile in
LABVIEW 6.1 I tried a direct approach, but that didn't work out well.
My project is to implement the GetParmType stucture from this headerfile into a LABVIEW application.
The approach I'm trying at this moment is to build an array of 326 bytes, and fill this array with the data from my EEPROM.
The first 64Bytes is :        
char           
Version[VERSION_LEN];
the next 2 bytes are the:    unsigned short  DeviceId;
(this is the DeviceInfoType structure)
the next byte is:                unsigned char   NrChannels;
then 2 bytes for:               unsigned short  NrPixels;
and 1 byte for:           
      unsigned char   Sensor;
(this is the DeviceConfigType
the rest of the array should be filled with the ChannelParmType
structure. The maximum devices that can be connected is 8 pieces, so
this should be a loop that runs the 8 times.
Can somebody help me with this? I have no idea how this is done or how to fill an array this way.
The headerfile is attached.
Many thanx
Koert
Attachments:
avs_dll.h ‏61 KB

Lycangeek wrote:
The DeviceConfigType is a great example of what I mentioned before about the dangers of mapping C structures to LV...   typedef struct
    unsigned char   NrChannels;         // number of channels
unsigned short 
NrPixels;          
// number of pixels
    unsigned char  
Sensor;            
// Sensortype
} DeviceConfigType;
Typically in C/C++, you are going to have the compiler set to a 4-byte alignment (this is the default for 32-bit Windows).
I
think Visual C (at least in version 6) uses a default alignement of 8
byte. However variables are usually aligned to the lesser of the
default alignement or the variable size. So I would hazard that this
particular structure actually would take up 5 byte since Visual C will
add a fill byte between NrChannels and NrPixels.
However you are right that in my example I didn't account for padding
at all. Another problem is that there will be three additional fill
bytes after Sensor, to make the first float in the ChannelArray align
on a four byte boundary.
So this would probably mean that for the DeviceConfig we should copy
out at least 7 bytes and add a fill byte between channels and pixels
and the offset for the channel array should be 74 instead of 70. Also
the array intialization should then be 330 instead of 326.
There still are some uncertainities. Unless the #pragma pack(x)
statement is in the header file (in this case not) you still can't be
certain that the DLL was compiled with the default alignment, although
it is quite likely.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • [WAD] Multi-Header Implementation ??

    Hi... Experts...
    I should download  data of the table component from WAD.
    If The Standard Download Function of SAP is used that Additional Header can not download making the javascript.
    (It makes a new header on the top to merge two and above item of The Bex. )
    I wonder how can i download to the excel with Header.
    please, would you like to answer quickly for me?!., as soon as possible .
    Thanks
    Edited by: youn Jai Jun on Apr 28, 2008 11:07 AM

    Hi,
    If you could give us the source and target structure with occurrences, it could be easy for us to suggest.
    Best regards,
    raj.

  • In need of a volunteer or two to test a link for me

    Hi guys, I need a favour.
    I am getting close to releasing an alpha version of a browser framework for JFX that I've alluded to a couple of times on the forum.
    I have put together a showcase of it and, with some help from Jonathan, I've gotten through the initial setup hurdles. Jonathan's sent me some screen shots however of how it looks on his machine and the styles are not coming through. I'm hoping its just because he's using a development build so I'm looking for a couple of people to test out the application at the following link and, if possible, send me some screenshots:
    http://www.zenjava.com/demo/jfxflow/showcase/
    You can either email screenshots directly to me at danjz at hotmail.com or use something like TinyGrab (http://tinygrab.com/download.php).
    On my machine it looks like this:
    http://tardis1.tinygrab.com/grabs/b4dfc5e9614e014b82932d087d60f30b69057f719c.png
    http://tardis1.tinygrab.com/grabs/b4dfc5e961ac8c84cfb466cc59efb0c5f9645f84dd.png
    I'm also keenly aware of the fact that this showcase is only just styled enough not to be hideously ugly. Given its meant to be a framework to encourage slick GUIs this is something I'd like to address but there's only so much one man can do after hours. If there are any creative individuals out there interested in making the showcase more sexy (i.e. styling it up, adding more animations, putting in icons, logos and colours), please get in contact, any and all help welcome! There's no technical reason why we can't do stuff like this in JFX:
    http://www.webdesignerdepot.com/2010/10/showcase-funky-and-experimental-websites/
    http://www.delpadre.com/
    http://www.kincreative.com/blog/A-few-funky-Flash-sites/6800/
    Much appreciated!
    zonski

    Thanks for the feedback Michael, I definitely appreciate it!
    I've just made JFX Flow public and gotten a jar up onto the site (and into a public snapshot repository). I'll put up a separate forum post with the details straight after this.
    In the mean time, some comments to your helpful feedback inline below.
    To my opinion it is absolutely crucial for the success of
    JavaFX on the web to fully support a more App-like behaviourI agree 1 million percent (yea, that much) about the whole deployment thing. Even the slightest annoyance for the user in the Java/JFX installation and running is, in my opinion, the single biggest hurdle to JFX being taken up. Make this seamless then I genuinely believe that JFX will go as (or more) viral than Flash has, which is what I would love to see happen! This issue, plus the horrid default look and lack of styling is what stopped Swing being the king it should have been.
    I use chrome and when it wants to install a plugin it just says "this page needs a plugin to run do you want to install?", - one click and 30 seconds later and its all done. If Java+JFX installation was this easy we would have rapid uptake! Currently (or last time I did it anyway) I get a prompt to install Java, which takes me to a web page, where I have to agree to T&C, I agree, I install, I then have to manually go back to my website, I run my app (again), it prompts again but this time to install JFX, I say yes, then it does some more dialogs, I then get a loading a dialog, then a do you trust app dialog, and then finally, I might see my app (unless I'm a developer who has a couple of JVMs installed in which case it seems to be pot-luck which one JFX got installed to and which one the browser launches via webstart).
    Just this week I had to agree to make a traditional web-front end for one of our upcoming systems to avoid the JFX installation issues when it is used by casual, add-hoc users. Painful and sad. It would almost be worth having a plugin that bundled the JVM into JFX for now and it all installed magically, instantly, in one click, rather than wait for Java 8 or 9 or whatever when they finally bundle it into the same platform. I'm sure there's a creative solution to this problem there somewhere. Ideally we would be at least as good as Flash in this area (preferably better).
    Unfortunately my framework is at the mercy of the elements here. As far as I know FXML needs the signing still (or has this been sorted?). The showcase also uses Spring's annotation based config which does internal code generation. I could take this out and use something else (or role it by hand) but I think I also mess with a few class accessibility flags in a couple of areas of JFX Flow, which I think would also trigger the security manager to barf.
    I definitely could and should officially sign my jar with a real certificate and only ask for the permissions I need. At this stage, I'm kind of taking advantage of the fact that it is other developers using the showcase and you guys will be more forgiving (right?). I will definitely put this on the todo list for a final release though. If you have other ideas based on the source code of ways to achieve things, I'd love some help.
    Once inside your App (I have decided to trust you :-) )Brave man ;)
    I observed that there seems to be a problem with the transitions.
    When I click on a link or go back to a previous page, the page
    seems to be shifted back and forth by a few pixels before the
    transition takes place. This somehow ruins the otherwise
    very nice effect.Bummer. I was hoping this was only on my machine as I've had it before on another project but a guy at work didn't see it.
    It's not actually anything to do with transitions though, if you didn't go anywhere it would still do it when you just click on the link (I think). I don't think this is specifically anything I am doing. I think it is something to do with the styles of the hyperlink and/or button changing when they get armed or vsited or something and this changes their preferred size which causes the layout manager to readjust everything slightly. I spent a good few hours on it last time and just couldn't find the magic switch to make it work. I'll add it to the todo list though (again, help appreciated :) ).
    When navigating to other pages you can easily get lost and
    then you feel the need for something like a home button.Jonathan suggested the exact same thing. It is definitely part of the design that you can easily add a home button (and totally customise the browser if you want).
    I actually had a home button on by default in early versions but then checked major browsers and this doesn't seem so popular any more so I took it out. Thinking about it though, a home option probably makes more sense for an application though than a general browser where home is less relevant. I think I will add this to the todo list.
    Thinking about it, it would also be nice to have something like
    a breadcrumb bar And again Jonathan suggested the exact same thing. I'm seeing a pattern :)
    A breadcrumb bar would be pretty easy to implement. A simple one could just observe the NavigationManager.backList and create/remove buttons to match. I think this would be valuable to have in the framework as an optional control (and Jonathan mentioned he might provide some of his code that does something similar already, which would be nice).
    Breadcrumbs only really work however when you have an acyclic navigation path though (as far as I know anyway, people are always coming up with clever solutions to problems so maybe someone has an approach that is user friendly?). In the showcase this would work and would be great as you always drill down and then back up. If you have an application like a 'contact manager' where you could view a person and then link to an organisation from that person and then back to the person from that organisation, you would end up with a pretty weird and fairly meaningless breadcrumb trail and I don't think it would make sense to have it.
    The BrowserHeader is the class that provide this and Browser has a setHeader on it, the intention being that people could build their own headers (and footers) and easily attach it to the browser. The default one I have provided is deliberately simple. It might be worth having a couple of header implementations in the JFX Flow framework however, and people can just instantiate the one that best fits their needs (or still create their own). I'll think a bit more about it, but it has some merit. Probably not an urgent feature though, but definitely a cool one.
    or even bookmarks.Yea, these are possible too and I had thought about it in the early design. Every page is referenced by a 'Place' object and you can get the current place from the NavigationManager so you can just stick that in a list or something (or show it however you want). I'd sort of forgotten about this (it's more a value-add feature) and I probably need to think about making place immutable or place having a clone() method or something so you can snapshot it for your bookmarks (in case someone edits the current place, kind of like a URL rewrite - you don't want this messing up your bookmark).
    When you are hovering over a link there should always be
    a visual feedback. On the Navigation-Page there are images
    on which you can click but you don't see this in contrast
    to the title texts which get underlined when you hover over
    them.Yep, agree. I couldn't get styling working on those !@#$@ ImageViews. I don't know what's wrong with them. CSS selectors make me want to stab my eye out with a pencil and it was getting late at the time. I gave up before I could find a pencil. I will have to go and have another look down the road.
    Dialogs should be positioned relative to the stage. On
    the Using Dialogs page the simple dialog appears somewhere
    in the middle of the screen where I would not expect it.Agreed. Also when the main stage is sent to back or minimized, the dialog should go with it but it currently doesn't.
    Dialogs weren't actually part of the original feature set (I tend not to use them) but it seemed like a contentious issue for a lot of users and to build it on top of JFX Flow (which has a handy top level browser) seemed like an easy win. I need to put a little more love into them though. It's probably second on the todo list after docco at this stage.
    Some other feature came to my mind. I ran your demo on a high
    resolution laptop (1920x1200) and the text was a little bit
    too small for my old eyes :-) and thus I was immediately
    missing a featue of a browser to zoom the whole content via Ctrl-+Hmm, nice idea. I'm just a lowly consumer of the JFX API and I think the closest feature I'd have for this is 'scale', which I don't think would do the job (you really just want to add/subtract to the font size and scale only images). If there's a way to do this with stylesheets or something similar it could be added to JFX Flow? Otherwise I'm going to see if we can get the UI design guy looking at this stuff soon so we can get the JFX team at least thinking about features that would support this browser-style GUI out this for future releases. I know Richard is supportive of the browser idea and Jonathan has been real helpful and supportive so far in feedback and getting me through a few hurdles.
    I hope that my comments are a little bit useful for you
    and that you will continue your great work because it
    addresses areas where JavaFX itself is really falling short.Thanks for the comments, they are definitely helpful and I would very much like you to keep firing them through. I'm happy to continue them here, or if you rather there are a couple of things that come with the google hosting. I've not used either yet but there are issues (http://code.google.com/p/jfxflow/issues/list) where you can file bugs and (http://groups.google.com/group/jfxflow-discuss) where we can discuss enhancements and ideas etc. If you have any problems with either, give me a shout as I may not have set them up properly or something.
    Maybe when JFX Flow is big enough Atlassian will let me host all this stuff with them for free ;)
    I'm also very glad you can see potential for JFX Flow adding value to the JFX space :)

  • How to create a new place in iPhoto 11 without doing any harm?

    Yes, I know how to create a new place for a photo -- theoretically:
    Select the photo.
    Make sure the Info icon in the lower right portion of the iPhoto window is clicked and the too-tiny-for-any-but-the-youngest-eyes map is displaying.
    Click in "Assign a Place..." and begin typing a place that iPhoto will search for.  It searches in both "your places" (i.e., those that you have already defined) as well as in Google Maps.
    When you see a place in the search results list that you think might be close to the one you mean, select it.
    A pin appears on the itsy-bitsy map.  Move it to the exact place you mean.  You can make controls appear on the map by moving the mouse over the bottom of the map.  The controls allow you to zoom in and out, and to change views (Terrain, Satellite, Hybrid).  When the pin is where you want it, click it. The current name of the location appears.  Modify it to the name you want, then click the check mark.
    That's "all" there is to it ... except for a couple of "gotchas."
    There's a difference between what happens when you select a place that you've defined and when you select a place that Google found in the search results.  If it's a place that you've defined, and you then move the pin to a new location and/or change its name, this will affect all photos assigned to the custom place.  In effect, you are modifying the place.
    All places have a radius associated with them, thereby making them circles.  You can adjust the radius only in the Maintain My Places window.  In the itsy-bitsy map it doesn't even appear.  However, if the newly defined place overlaps existing ones, all the photos assigned to the overlapped places will be assigned to the new one.  Their pins will remain where they were.
    Now, before anybody suggests sending feedback to Apple, let me emphasize that I have been sending Apple feedback on the wrong-headed implementation of Places since iPhoto 9.0.  New versions have come and gone (the current one is 9.1.2), but these "features" have remained.  So my purpose in opening this thread is to consolidate work arounds to these "features" in one place.  My work around: 
    Whenever I define a new place, I select only a single photo.  I try to name my places so that I can distinguish them from those that Google finds.  In order to avoid Gotcha 1 I select a place that Google finds and try to place the pin close enough to where I want it, but far enough from any other places that I've defined.  I give it a name that I can easily find it Manage My Place.
    I immediately open Manage My Places and select the new place.  I first note the pins near it, then decrease its radius, move the pin to the desired location, note the nearby places, and give it its final name.
    I then view Places and navigate to the new place to view the photos assigned to it.  If I'm lucky, there's only one.  Otherwise, I have to reassign the other photos to their correct places.
    Richard

    So... in the hope it will not confuse folks more, let me be more specific of a procedure that works for me...
    Procedure to create a new My Places location.
    OK there is more you can do with a non-GPS Coord linked photo.
    Click Info and then click Assign a Place in the lower right of screen. (if your photo has a location linked to it already the Assign a Place will NOT show up.)
    Choose a location name near the actual location that Google Maps can find.
    Click that location in the Google Maps list that appears and your photo will be temporarily assigned to that location.
    Now  type over that  location name in order to make sure to give that location a unique name that will show up in your My Places list and click that name after you have typed it  to be sure it is accepted.
    Now in iPhoto click Window/Manage My Places and go the that newly named location in the large My Places map. There's no easy search. You have to run down through the alphabetical list.
    Drag the flag to the location you want this place to be and click Done.
    The location name is now in your My Places list at the location you dragged the flag to!
    It is important to note that only your unique named locations show up in your Places list, so if you want to modify the location coordinates you have to establish a unique name for it.
    This is much more complicated that previous iPhoto versions!
    But Yeah!!!!!!!!!!
    It really works!!!!!!!

  • Create CGRect from view's frame (iPhone OS 3.1)

    Another basic question, but how do I create a CGRect from a view's frame? I'm thinking of doing something like
    CGRect drawSurface = self.view.something
    but I'm not sure exactly what propert(ies) to invoke. Any help would be appreciated!

    RayNewbie wrote:
    musicwind95 wrote:
    I now get the error that PolygonView may not respond to the method. Any other suggestions?
    I put your code in a testbed and it ran as expected with no compiler warnings and no crash. Of course when building the testbed, I had to make some assumptions about some of the other files, so I think we can conclude that the solution to your problem will be found in one of the files you didn't post.
    Here are some of the things to look for:
    1) Your compiler warning seems to be telling us that pointsForPolygonInRect:: isn't declared correctly in PolygonView.h. Here's the PolygonView.h I assumed for my testbed (based on your PolygonView.m):
    // PolygonView.h
    #import <UIKit/UIKit.h>
    @class PolygonShape;
    @interface PolygonView : UIView {
    IBOutlet UILabel *shapeLabel;
    CGRect frameRect;
    PolygonShape *shape;
    @property (nonatomic, retain) UILabel *shapeLabel;
    @property CGRect frameRect;
    + (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides;
    @end
    If I had left out the declaration of the pointsForPolygonInRect:: class method, I would have gotten the compiler warning you reported. However, this would not have caused my testbed to crash. Even though the method wasn't declared it was implemented in your code, so it would have been found at runtime. This suggests that the compiler warning is unrelated to the crash (though I can't be sure of that without seeing the crash message printed in your Console; the first few lines of that message might be helpful).
    Does this mean that method declarations in the header file are not necessary in the sense that at runtime they'd be found anyway? Not that I would do this, but it's interesting, and something I didn't know before.
    2) Note that my PolygonView.h declares a 'shape' ivar of type PolygonShape*, but doesn't declare a @property for this ivar. Even though it would have made sense to declare that property, your PolygonView.m didn't include a @synthesize statement for 'shape' (nor any explicit setShape: method). Thus your code includes no indication of how the 'shape' var gets set, leading me to wonder if it was nil during your tests. In my testbed, lacking a way to set 'shape' from the controller, I initialized it like this:
    // PolygonView.m
    #import "PolygonView.h"
    #import "PolygonShape.h"
    // #define M_PI 3.1415926357 <-- already defined in an included SDK header
    @implementation PolygonView
    @synthesize shapeLabel, frameRect;
    - (void)awakeFromNib {
    shape = [[PolygonShape alloc] init];
    shape.numberOfSides = 6;
    - (void)drawRect:(CGRect)rect {
    // identical to your posted code ...
    + (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides {
    // identical to your posted code ...
    - (void)dealloc {
    [shape release];
    [shapeLabel release];
    [super dealloc];
    @end
    If 'shape' was in fact nil during your tests, that would account for the crash. 'shape.numberOfSides' would then evaluate to zero, so this line (or one soon after) would have crashed:
    float angle = (2.0 * M_PI) / numberOfSides; // <-- division by zero if 'shape' were nil
    The easiest way to see if 'shape' is your problem would be to temporarily replace 'shape.numberOfSides' with a constant in this line:
    NSArray *result = [PolygonView pointsForPolygonInRect:frameRect numberOfSides:6];
    If the above fixes the problem, I would recommend a @property declaration for shape so it can be set from your controller.
    That's the issue right there. However, in my case I'm initializing the PolygonShape object in Controller.m's awakeFromNib. It's probably just a simple matter and I'm overthinking it, but how would I access that instance of PolygonShape to use in my PolygonView class, rather than declaring a separate one?
    BTW, when my app crashes, I get a window saying that the error message will be sent to Apple immediately. What do they make of this?
    I don't think Apple will be interested so long as it's apparent the error occurred in an app under development.
    Way cool signature, btw.
    Thanks.
    I'm posting the rest of my code below, just for reference and for any future issues:
    Controller.h
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    @class PolygonShape;
    @interface Controller : NSObject {
    IBOutlet UIButton *decreaseButton;
    IBOutlet UIButton *increaseButton;
    IBOutlet UILabel *numberOfSidesLabel;
    IBOutlet UILabel *maxSides;
    IBOutlet UILabel *minSides;
    IBOutlet UILabel *typeOfPolygon;
    IBOutlet UISlider *inputSlider;
    IBOutlet UIView *PolygonView;
    IBOutlet PolygonShape *shape;
    - (IBAction)decrease:(id)sender;
    - (IBAction)increase:(id)sender;
    - (IBAction)sliderInput:(id) sender;
    - (void) updateInterface;
    @end
    Controller.m
    #import "Controller.h"
    #import "PolygonShape.h"
    @implementation Controller
    - (IBAction)decrease:(id)sender {
    NSLog (@"Decrease method called");
    NSLog (@"shape's number of sides: %d", shape.numberOfSides);
    shape.numberOfSides = shape.numberOfSides - 1;
    // numberOfSidesLabel.text = [NSString stringWithFormat: @"%d", shape.numberOfSides];
    [self updateInterface];
    - (IBAction)increase:(id)sender {
    NSLog (@"Increase method called");
    NSLog (@"shape's number of sides: %d", shape.numberOfSides);
    shape.numberOfSides = shape.numberOfSides + 1;
    // numberOfSidesLabel.text = [NSString stringWithFormat: @"%d", shape.numberOfSides];
    [self updateInterface];
    - (IBAction)sliderInput:(id)sender {
    shape.numberOfSides = inputSlider.value;
    [self updateInterface];
    -(void) awakeFromNib
    shape.numberOfSides = numberOfSidesLabel.text.integerValue;
    shape.minimumNumberOfSides = 3;
    shape.maximumNumberOfSides = 12;
    NSLog (@"My polygon: %@", shape);
    maxSides.text = [NSString stringWithFormat: @"%d", shape.maximumNumberOfSides];
    minSides.text = [NSString stringWithFormat: @"%d", shape.minimumNumberOfSides];
    typeOfPolygon.text = [NSString stringWithFormat: @"%@", shape.name];
    -(void) updateInterface
    numberOfSidesLabel.text = [NSString stringWithFormat: @"%d", shape.numberOfSides];
    if (shape.numberOfSides <= shape.minimumNumberOfSides)
    decreaseButton.enabled = NO;
    else
    decreaseButton.enabled = YES; // re-enable whenever numberOfSides is above the minimum
    if (shape.numberOfSides >= shape.maximumNumberOfSides)
    increaseButton.enabled = NO;
    else
    increaseButton.enabled = YES;
    typeOfPolygon.text = [NSString stringWithFormat: @"%@", shape.name];
    @end
    PolygonShape.h
    #import <Foundation/Foundation.h>
    @class PolygonShape;
    @interface PolygonShape : NSObject {
    int numberOfSides, minimumNumberOfSides, maximumNumberOfSides;
    // float angleInDegrees, angleInRadians;
    // NSString *name = [[NSString alloc] init];
    @property int numberOfSides;
    @property int minimumNumberOfSides;
    @property int maximumNumberOfSides;
    @property(readonly) float angleInDegrees;
    @property(readonly) float angleInRadians;
    @property(readonly, copy) NSString *name;
    -(id) initWithNumberOfSides: (int) sides minimumNumberOfSides: (int) min maximumNumberOfSides: (int) max;
    @end
    PolygonShape.m
    #import "PolygonShape.h"
    #import "Controller.h"
    // #define M_PI 3.1415926357
    @implementation PolygonShape
    @synthesize numberOfSides;
    @synthesize minimumNumberOfSides;
    @synthesize maximumNumberOfSides;
    /* @synthesize angleInDegrees;
    @synthesize angleInRadians;
    @synthesize name; */
    -(void) setMinimumNumberOfSides: (int) s
    if (s > 2)
    minimumNumberOfSides = s;
    else if (s ==2)
    NSLog (@"A polygon cannot have only two sides.");
    else {
    NSLog (@"A polygon cannot have only %d sides.", s);
    -(void) setMaximumNumberOfSides: (int) s
    if (s < 12 || s == 12)
    maximumNumberOfSides = s;
    else if (s < minimumNumberOfSides)
    NSLog (@"The minimum number of sides is %d. Please specify something greater.", minimumNumberOfSides);
    else {
    NSLog (@"Number too large. Please use a number between %d and 12.", minimumNumberOfSides);
    -(void) setNumberOfSides: (int) s
    if (s >= minimumNumberOfSides && s <= maximumNumberOfSides)
    numberOfSides = s;
    else {
    NSLog (@"Number of sides must be between %d and %d, inclusive.", minimumNumberOfSides, maximumNumberOfSides);
    -(id) initWithNumberOfSides: (int) sides minimumNumberOfSides: (int) min maximumNumberOfSides: (int) max
    [self setMinimumNumberOfSides: min];
    [self setMaximumNumberOfSides: max];
    [self setNumberOfSides: sides];
    return self;
    -(id) init
    if (self = [super init])
    [self initWithNumberOfSides: 5 minimumNumberOfSides: 3 maximumNumberOfSides: 10];
    return self;
    -(float) angleInDegrees
    return (180 * (numberOfSides - 2) / numberOfSides);
    -(float) angleInRadians
    return ([self angleInDegrees] * (180 / M_PI));
    -(NSString *) name
    if (numberOfSides == 3)
    return @"Triangle";
    else if (numberOfSides == 4)
    return @"Rectangle";
    else if (numberOfSides == 5)
    return @"Pentagon";
    else if (numberOfSides == 6)
    return @"Hexagon";
    else if (numberOfSides == 7)
    return @"Heptagon";
    else if (numberOfSides == 8)
    return @"Octagon";
    else if (numberOfSides == 9)
    return @"Nonagon";
    else if (numberOfSides == 10)
    return @"Decagon";
    else if (numberOfSides == 11)
    return @"Hendecagon";
    else if (numberOfSides == 12)
    return @"Dodecagon";
    else {
    return @"Out of bounds.";
    -(NSString *) description
    // NSString *description = [[NSString alloc] init];
    // [description stringByAppendingFormat: @"Hello, I am a %d sided figure (a %@) with angle measures of %.2f degrees (%.2f radians).", self.numberOfSides, [self name], [self angleInDegrees], [self angleInRadians]];
    // [description autorelease];
    return [NSString stringWithFormat: @"Hello, I am a %d sided figure (a %@) with angle measures of %.2f degrees (%.2f radians).", self.numberOfSides, [self name], [self angleInDegrees], [self angleInRadians]];
    -(void) dealloc
    NSLog (@"Deallocating now.");
    // [description dealloc];
    [super dealloc];
    -(void) awakeFromNib
    self.minimumNumberOfSides = 3;
    self.maximumNumberOfSides = 12;
    // self.numberOfSides = numberOfSidesLabel.text.integerValue;
    // NSLog (@"My polygon: %@", shape);
    @end
    I appreciate all the help!
    <a href="http://skitch.com/musicwind95/dnsyx/musicwind95-aqua">
    Message was edited by: musicwind95

  • How do you call the same parameters from function to function

    I need to create several functions to try and consolidate and clear up readability in my program and I need to call the same things in all the functions. How do I do that without writing everything I need to call in each function?

    Yeah . . that's pretty much right on base. Except this is how I did it and it doesn't quite work the way I thought.
    This first bit is what I wrote to replace the redundant code
    class Header   // this class is all the declaration stuff for the events
        { public void Header()
               {  SerialRead s;
               String serialString;
               int newline1,newline2;
               String line1,line2,line3,linetmp;
               String spindle,torque1,torque2,torque3,angle1,angle2,angle3;
                  int tval1 = Integer.parseInt(torque1);
                  int tval2 = Integer.parseInt(torque2);
                  int tval3 = Integer.parseInt(torque3);
                  int aval1 = Integer.parseInt(angle1);
                  int aval2 = Integer.parseInt(angle2);
                  int aval3 = Integer.parseInt(angle3);
        }This is how I thought it should be implemented
    class AcceptPass1 extends Header implements ActionListener{
      public void actionPerformed(ActionEvent e){
         s=new SerialRead();
         s.findPort();
         waitForSerial=true;
         s.openConnection();
         blank_l1.setText("Waiting for data from Pass #2");
         while(waitForSerial){
         blank_l1.setText("Data Received.  Please verify data!");
         s.closeConnection();
         serialString=serialBuffer.toString();
         line1=serialString.substring(0);
         linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
         line2=linetmp.substring(0);
         line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);

  • JPA -- Best way to refresh a List association?

    Hi,
    I need to refresh a OneToMany association.
    For example, I have two entities: Header & Detail.
    @Entity
    @Table(name="HEADERS")
    public class Header implements Serializable {
        @OneToMany(mappedBy="header")
        private List<Detail> details;
    @Entity
    @Table(name="DETAILS")
    public class Detail implements Serializable {
        @ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="HDR_ID", referencedColumnName="HDR_ID")
        private Header header;
    }So, I fetch the Header along with all its Details.
    At a later point of time, I know that some Detail rows in the database have been changed behind my back. I need to re-fetch the list of Details. What should I do?
    1. I could add a cascade parameter to the @OneToMany association. I could specify:
    @OneToMany(mappedBy="header", cascade={CascadeType.REFRESH})Then I could run:
    entityManager.refresh(header);The trouble is that, since all the Details are already in the cache, the cached entities will be returned, not the ones fetched from the database. So, I won't refresh a thing. A query will be sent to the database indeed, but I will get the cached (i.e. stale) entities. I don't know of a way to specify something like
    setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE)dynamically for associations, so that the values in the cache would be replaced with the ones fetched from the database.
    2. I could try to turn off the caching for the while Entity class. The trouble is that for some reason this doesn't work (see my other question here JPA -- How can I turn off the caching for an entity? Besides, even if it worked, I don't want to turn off the caching in general. I simply want to refresh the list sometimes.
    Could anyone tell me what's the best way to refresh the association?
    Best regards,
    Bisser

    Hi Chris,
    First, let me thank you that you take the time to answer my questions. I really appreciate that. I wish to apologize for my late reply but I wasn't around the PC for a while.
    TopLink doesn't refresh an entity based on a view. I will try to explain in more detail. I hope you'll have patience with me because this might be a bit longer even than my previous post. I will oversimplify my actual business case.
    Let's assume we have two tables and a view:
    create table MASTERS
      (id number(18) not null primary key,
       master_name varchar2(50));
    create table DETAILS
      (id number(18) not null primary key,
       master_id number(18) not null,   -- FK to MASTER.ID
       price number(7,2));
    create view DETAILS_VW as
      select id, master_id, price
      from details;Of course, in real life the view is useful and actually peforms complex aggregate calculations on the details. But at the moment I wish to keep things as simple as possible.
    So, I create Entities for the tables and the view. Here are the entities for MASTERS and DETAILS_VW, only the essential stuff (w/o getters, setters, sequence info, etc.):
    @Entity
    @Table(name="MASTERS")
    public class Master {
         @Id
         @Column(name="ID", nullable=false)
         private Long id;
         @Column(name="MASTER_NAME")
         private String masterName;
         @OneToMany(mappedBy="master", fetch=FetchType.LAZY, cascade=CascadeType.REFRESH)
         private List<DetailVw> detailsVw;
    @Entity
    @Table(name="DETAILS_VW")
    public class DetailVw {
         @Id
         @Column(name="ID")
         private Long id;
         @ManyToOne(fetch=FetchType.LAZY)
         @JoinColumn(name="MASTER_ID", referencedColumnName="ID")
         private Master master;
         @Column(name="PRICE")
         private Double price;
    }So, now we have the tables and the entities. Let's assume one master row and two detail rows exist:
    MASTER:  ID=1, MASTER_NAME='Master #1'
    DETAIL:  ID=1, MASTER_ID=1, PRICE=3
    DETAIL:  ID=2, MASTER_ID=1, PRICE=8And now let's run the following code:
    // List the initial state
    Master master = em.find(Master.class, 1L);
    List<DetailVw> detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    // Modify a detail
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    Detail d = em.find(Detail.class, 2L);
    d.setPrice(1);
    tx.commit();
    // Refresh
    System.out.println("----------------------------------------");
    em.refresh(master);
    // List the state AFTER the update
    detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    }And here are some excerpts from the console (only the essentials):
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8
    UPDATE DETAILS SET PRICE = ? WHERE (ID = ?)
         bind => [1, 2]
    SELECT ID, MASTER_NAME FROM MASTERS WHERE (ID = ?)
         bind => [1]
    SELECT ID, PRICE, MASTER_ID FROM DETAILS_VW WHERE (MASTER_ID = ?)
         bind => [1]
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8You see, the UPDATE statement changes the DETAILS row. The price was 8, but was changed to 1. I checked the database. It was indeed changed to 1.
    Furthermore, due to the refresh operation, a query was run on the view. But as you can see from the console output, the results of the query were completely ignored. The price was 8, and continued to be 8 even after the refresh. I assume it was because of the cache. If I run an explicit query on DETAILS_VW with the hint:
    q.setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE);then I see the real updated values. But if I only refresh with em.refresh(master), then the DetailVw entities do not get refreshed, even though a query against the database is run. I have tested this both in JavaSE and in OC4J. The results are the same.
    An explicit refresh on a particular DetailVw entity works, though:
    DetailVw dvw = em.find(DetailVw.class, 2L);
    em.refresh(dvw);
    System.out.println(dvw);Then the console says:
    DetailVw: id=2, price=1So, the price is indeed 1, not 8.
    If you can explain that to me, I will be really thankful!
    Best regards,
    Bisser

  • Passing a counter to classes/functions

    I have a passCounter that is initialized in class Passes. I need to have this passCounter keep track of what pass I am on so that it can evaluate the correct data and process it to the correct spots in the program. But the program isn't seeing the int passCounter. I was hoping someone could clue me in as to what is wrong with my implimentation. I have another function that does the same thing and doesn't cause me any errors.
    class Passes extends Header
         { public void Passes (int passCounter)
                { while (passCounter != 3)
                     { s=new SerialRead();
                    s.findPort();
                    waitForSerial=true;
                    s.openConnection(); // open the serial connection
                       while(waitForSerial)
                              torque1=line1.substring(32,37);
                           torque2=line2.substring(32,37);
                           torque3=line3.substring(32,37);
                              angle1=line1.substring(40,45);
                           angle2=line2.substring(40,45);
                           angle3=line3.substring(40,45);
                           torque1=line1.substring(1,6);
                           torque2=line2.substring(1,6);
                           torque3=line3.substring(1,6);
                           angle1=line1.substring(9,14);
                           angle2=line2.substring(9,14);
                           angle3=line3.substring(9,14);
                            serialBuffer.delete(0,((int) serialBuffer.length()));
                               if (passCounter == 1)
                                  { outputs[0].setText(torque1);
                                 outputs[1].setText(angle1);
                                 outputs[2].setText(torque2);
                                 outputs[3].setText(angle2);
                                 outputs[4].setText(torque3);
                                 outputs[5].setText(angle3);
                             else if (passCounter == 2)
                                     { outputs[6].setText(torque1);
                                    outputs[7].setText(angle1);
                                    outputs[8].setText(torque2);
                                    outputs[9].setText(angle2);
                                    outputs[10].setText(torque3);
                                    outputs[11].setText(angle3);
                             else if (passCounter == 3)
                                  { outputs[12].setText(torque1);
                                 outputs[13].setText(angle1);
                                 outputs[14].setText(torque2);
                                 outputs[15].setText(angle2);
                                 outputs[16].setText(torque3);
                                 outputs[17].setText(angle3);
                       if (passCounter == 2 || passCounter == 3)
                         { s.closeConnection(); // close the serial connection
                           line1=serialString.substring(0);
                        linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
                        line2=linetmp.substring(0);
                        line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
                         } else { System.out.println("Doing pass number 1");
                       ColorButtons(passCounter);
                     } // end of pass while loop
         } // end of class Passes()
    class AcceptButton1 extends Header implements ActionListener
        { public void actionPerformed(ActionEvent e)
               { blank_l1.setText("Waiting for Data from the Second Pass");
                 Passes(2); //for the second pass
                 blank_l1.setText("Data Recieved from the second pass");
    class AcceptButton2 extends Header implements ActionListener
          { public void actionPerformed(ActionEvent e)
                 { blank_l1.setText("Waiting for Data From the Third pass"); // This is always going to be one pass ahead
                   Passes(3); //class for the third pass         
                   blank_l1.setText("Data Recieved from the third pass");
          }

    I'm not sure what I want. But I went ahead and moved all the class stuff into the main class and it appears to work. I am getting:
    Exception in thread main java.lang.NumberFormatException :NULL error:
    Ton.java
    at Java.lang.Integer.parseInt(Unknown Source)
    at Ton.,init.(Ton.java:37)
    at Ton.main(Ton.java:347)
    public class Ton extends JFrame
            private JLabel title, ser_l,pass_1,pass_2,pass_3,blank_l1,blank_l2;
            private JLabel[] header;
            private JLabel[] outputs;
            private JButton accept_sno,accept_1,reject_1,accept_2,reject_2,accept_3,
                            reject_3,reject_a;
            private Ton frame;
            private String serial_no,tmpstr1,tmpstr2;
            private boolean waitForSerial;
            public JTextField serial_text;
            public StringBuffer serialBuffer = new StringBuffer();
            public int pass;
            public ActionListener a1,a2,a3,r1,r2,r3;
            final boolean shouldFill = true;
            final boolean shouldWeightX = true; // Some strange true false things
           public SerialRead s;
           public String serialString;
           public int newline1,newline2;
           public String line1,line2,line3,linetmp;
           public String spindle,torque1,torque2,torque3,angle1,angle2,angle3;
           public int tval1 = Integer.parseInt(torque1);
           public int tval2 = Integer.parseInt(torque2);
           public int tval3 = Integer.parseInt(torque3);
           public int aval1 = Integer.parseInt(angle1);
           public int aval2 = Integer.parseInt(angle2);
           public int aval3 = Integer.parseInt(angle3);
    // all the declarations, or rather, most of them
            public  Ton()
                    Container contentPane = getContentPane(); // Initialize the container
                    GridBagLayout gridbag = new GridBagLayout(); // Intitialize the GridBagLayout manager
                    contentPane.setLayout(gridbag);   // Put the gridbag inside the contentPane
                    GridBagConstraints c = new GridBagConstraints(); // Initialize the constriants
                    Font f3 = new Font("Times Roman", Font.BOLD, 12);
                    if(shouldFill)
                      { c.fill = GridBagConstraints.HORIZONTAL; // Fill the grid completely in the Horixontal plane only
                        c.insets = new Insets(6,6,6,6); // have a space of 6 pixels on all sides on the outside of the buttons
                    serial_no="";
                    outputs=new JLabel[18];
                    setSize(780, 500);
                    setTitle("Data Entry");
                    addWindowListener(new WindowAdapter() // Make sure the window
                       { public void windowClosing(WindowEvent e)  //closes and the
                             { System.exit(0);          // Program exits instead of
                             }                          // Just hiding
                    title = new JLabel(" Data Entry");
                    title.setForeground(Color.black);
                    Font myFont = new Font("Times Roman", Font.BOLD, 40);
                    title.setFont(myFont);
                    c.anchor = GridBagConstraints.NORTH;
                    c.gridwidth = 8; // span the full 8 columns
                    c.gridheight = 2; // Span 2 rows high
                    c.gridx = 2; // Start at the very left
                    c.gridy = 0; // Start at the very top
                    gridbag.setConstraints(title, c);
                    contentPane.add(title); // add the thing into the frame
                    blank_l1 = new JLabel("Enter number before running");
                    Font warnFont=new Font("Times Roman",Font.BOLD,20);
                    blank_l1.setFont(warnFont);
                    blank_l1.setForeground(Color.red);
                    c.anchor = GridBagConstraints.NORTH;
                    c.gridwidth = 6; //Span 6 columns if neccisary
                    c.gridheight = 1; //Span 1 row
                    c.gridx = 3;
                    c.gridy = 2;
                    gridbag.setConstraints(blank_l1, c);
                    contentPane.add(blank_l1); // add the thing into the frame
                    ser_l = new JLabel("Enter Number: ");
                    Font myFont2=new Font("Times Roman",Font.BOLD,15);
                    ser_l.setFont(myFont2);
                    c.gridwidth = 3;
                    c.gridheight = 1;
                    c.gridx = 3;
                    c.gridy = 3;
                    gridbag.setConstraints(ser_l, c);
                    contentPane.add(ser_l); // add the thing into the frame
                    serial_text=new JTextField("",10);
                    c.gridwidth = 1;
                    c.gridheight = 1;
                    c.gridx = 6;
                    c.gridy = 3;
                    gridbag.setConstraints(serial_text, c);
                    contentPane.add(serial_text); // add the thing into the frame
                    accept_sno=new JButton("Done"); // this has to be double clicked to work properly
                    c.gridwidth = 2;
                    c.gridheight = 1;
                    c.gridx = 8;
                    c.gridy = 3;
                    c.ipadx = 3;
                    c.ipady = 3;  // Pad the button on the inside by 3 pixels
                    gridbag.setConstraints(accept_sno, c);
                    contentPane.add(accept_sno); // add the thing into the frame
                    accept_sno.addActionListener(new DoneButton());
                    //accept_sno.addActionListener(new EnterSerial());
                    header = new JLabel[9];
                    header[0]=new JLabel("Pass No");
                    header[0].setFont(f3);
                    header[0].setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 4; // we want all the labels on the same ROW
                    gridbag.setConstraints(header[0], c);
                    contentPane.add(header[0]);
                   for (int grid_numx = 2; grid_numx <=7; grid_numx++)
                       { for(int i=0;i<=2;i++)
                           { tmpstr1="Torque S" + (char) ('1' + i);
                          tmpstr2="Angle S" + (char) ('1' + i);
                          header[i*2+1]=new JLabel(tmpstr1);
                             header[i*2+1].setFont(f3);
                             header[i*2+1].setForeground(Color.black);
                             c.gridheight = 1;
                             c.gridwidth =  1;
                             c.gridx = grid_numx;
                             c.gridy = 4;
                             gridbag.setConstraints(header[i*2+1], c);
                             contentPane.add(header[i*2+1]);
                             header[i*2+2]=new JLabel(tmpstr2);
                             header[i*2+2].setFont(f3);
                             header[i*2+2].setForeground(Color.black);
                             grid_numx++;
                             c.gridheight = 1;
                             c.gridwidth =  1;
                             c.gridx = grid_numx;
                             c.gridy = 4;
                             gridbag.setConstraints(header[i*2+2], c);
                             contentPane.add(header[i*2+2]);
                             grid_numx++;
                       } // end of while loop for header[]
                    header[7]=new JLabel("");  // A new label with a blank?
                    reject_a=new JButton("Reject Completely");  // the reject button
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 8;
                    c.gridy = 4;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(reject_a, c);
                    contentPane.add(reject_a);
                    reject_a.addActionListener(new RejectPart());
                    pass_1=new JLabel("1");
                    pass_1.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 6;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_1, c);
                    contentPane.add(pass_1);
                    pass_2=new JLabel("2");
                    pass_2.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 7;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_2, c);
                    contentPane.add(pass_2);
                    pass_3=new JLabel("3");
                    pass_3.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 8;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_3, c);
                    contentPane.add(pass_3);
                    outputs=new JLabel[18];
                    Font myFont3=new Font("Times Roman",Font.BOLD,16);
                    int grid_numy = 6;
                    int grid_numx = 2;
                    int i = 0;
    // this nested while loop should get all of the output and put it into the correct places
    // using GridBagLayout
                    while (i < 18) 
                         { while (grid_numy <=8)
                                { while (grid_numx <=7)
                                       { outputs[i] = new JLabel("N/A");
                                         outputs.setFont(myFont3);
    c.gridwidth = 1;
    c.gridheight=1;
    c.gridx = grid_numx;
    c.gridy = grid_numy;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(outputs[i], c);
    contentPane.add(outputs[i]);
    grid_numx++;
    i++;
    grid_numy++;
    for(int j = 1; j<3; j++)
    { grid_numx = 2;
    } // end of while loops
    accept_1=new JButton("Accept Pass 1");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 6;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_1, c);
    contentPane.add(accept_1);
    a1=(ActionListener) new AcceptButton1();
    accept_2=new JButton("Accept Pass 2");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 7;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_2, c);
    contentPane.add(accept_2);
    a2=(ActionListener) new AcceptButton2();
    accept_3=new JButton("Accept Pass 3");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 8;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_3, c);
    contentPane.add(accept_3);
    a3=(ActionListener) new AcceptButton3();
    reject_1=new JButton("Reject Pass 1");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 6;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_1, c);
    contentPane.add(reject_1);
    r1=(ActionListener) new RejectButton1();
    reject_2=new JButton("Reject Pass 2");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 7;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_2, c);
    contentPane.add(reject_2);
    r2=(ActionListener) new RejectButton2();
    reject_3=new JButton("Reject Pass 3");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 8;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_3, c);
    contentPane.add(reject_3);
    r3=(ActionListener) new RejectButton3();
    } // End of public Ton
    public static void main(String args[])
    Ton frame = new Ton();
    frame.show();
    public void SaveData()
    { String outputString,outputFileName;
    byte[] outputBytes;
    String year,month,hour,min,sec;
    Date myDate;
    int tmpval;
    myDate=new Date();
    tmpval=myDate.getYear() + 1900;
    year=new String("" + tmpval);
    tmpval=myDate.getMonth() + 1;
    if(tmpval < 10 )
    { month=new String("0" + tmpval);
    else
    { month=new String("" + tmpval);
    String directory = File.separatorChar + "data" + File.separatorChar +
              year + month;
    new File(directory).mkdirs();
    hour=new String("" + myDate.getHours());
    tmpval=myDate.getMinutes();
    if(tmpval < 10)
    { min=new String("0" + tmpval);
    else
    { min=new String("" + tmpval);
    tmpval=myDate.getSeconds();
    if(tmpval <10)
    { sec=new String("0" + tmpval);
    else
    { sec=new String("" + tmpval);
    outputFileName= directory + File.separatorChar +
              serial_no.trim() + "." + hour +
              min + sec + ".dat";
    try
    { FileOutputStream myOut=new FileOutputStream(outputFileName);
    for(int i=0;i<3;i++)
    { outputString="Pass " + (i+1) + "," + serial_no.trim() + "," + hour + min + sec +"," + outputs[i*6].getText() + "," +
    outputs[i*6+1].getText() + "," + outputs[i*6+2].getText() + "," +
    outputs[i*6+3].getText() + "," + outputs[i*6+4].getText() + "," +
    outputs[i*6+5].getText() + "\r\n";
         outputBytes=outputString.getBytes();
         myOut.write(outputBytes);
    myOut.close();
    catch(java.io.IOException ioe)
    { System.out.println("Cannot write to file");
    } // End of save data
    public void ClearPass(int passNo)
    { for(int i=0;i<6;i++)
    { outputs[(passNo-1)*6+i].setText("N/A");
    } // End of clear pass
    public void ColorButtons(int passCounter)
    {  // this thing needs to look at the pass data and evaluate whether it is good or not
    // and color the buttons occordingly
    while (passCounter == 1)
    { if (( tval1 <= 45.00) || (tval1 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if ((tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of first pass color loop
    while (passCounter == 2)
    { if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if (( tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of second pass while loop
    while (passCounter == 3)
    { if (( tval1 <= 45.00) || (tval1 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if (( tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of third pass while loop
    } // end of function
    public void Passes (int passCounter)
    while (passCounter != 3)
    { s=new SerialRead();
         s.findPort();
         waitForSerial=true;
         s.openConnection(); // open the serial connection
    while(waitForSerial)
    torque1=line1.substring(32,37);
         torque2=line2.substring(32,37);
         torque3=line3.substring(32,37);
    angle1=line1.substring(40,45);
         angle2=line2.substring(40,45);
         angle3=line3.substring(40,45);
         torque1=line1.substring(1,6);
         torque2=line2.substring(1,6);
         torque3=line3.substring(1,6);
         angle1=line1.substring(9,14);
         angle2=line2.substring(9,14);
         angle3=line3.substring(9,14);
         serialBuffer.delete(0,((int) serialBuffer.length()));
    if (passCounter == 1)
    { outputs[0].setText(torque1);
         outputs[1].setText(angle1);
         outputs[2].setText(torque2);
         outputs[3].setText(angle2);
         outputs[4].setText(torque3);
         outputs[5].setText(angle3);
    else if (passCounter == 2)
    { outputs[6].setText(torque1);
         outputs[7].setText(angle1);
         outputs[8].setText(torque2);
         outputs[9].setText(angle2);
         outputs[10].setText(torque3);
         outputs[11].setText(angle3);
    else if (passCounter == 3)
    { outputs[12].setText(torque1);
         outputs[13].setText(angle1);
         outputs[14].setText(torque2);
         outputs[15].setText(angle2);
         outputs[16].setText(torque3);
         outputs[17].setText(angle3);
    if (passCounter == 2 || passCounter == 3)
    { s.closeConnection(); // close the serial connection
    line1=serialString.substring(0);
         linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
         line2=linetmp.substring(0);
         line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
    } else { System.out.println("Doing pass number 1");
    ColorButtons(passCounter);
    } // end of pass while loop
    public void Rejects( int passCounter)
    while (passCounter <= 3)
    s=new SerialRead();
         s.findPort();
         waitForSerial=true;
         s.openConnection();
    while(waitForSerial)
         blank_l1.setText("Data Received. Please verify data!");
         s.closeConnection();
    serialString=serialBuffer.toString();
         line1=serialString.substring(0,(serialString.indexOf("ZZZ")));
         linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
         line2=linetmp.substring(0,(linetmp.indexOf("ZZZ")));
         line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
    /* torque1=line1.substring(32,37);
         torque2=line2.substring(32,37);
         torque3=line3.substring(32,37);
         angle1=line1.substring(40,44);
         angle2=line2.substring(40,44);
         angle3=line3.substring(40,44);
         torque1=line1.substring(1,6);
         torque2=line2.substring(1,6);
         torque3=line3.substring(1,6);
         angle1=line1.substring(9,13);
         angle2=line2.substring(9,13);
         angle3=line3.substring(9,13);
         serialBuffer.delete(0,((int) serialBuffer.length()));
    if (passCounter == 1)
    { outputs[0].setText(torque1);
         outputs[1].setText(angle1);
         outputs[2].setText(torque2);
         outputs[3].setText(angle2);
         outputs[4].setText(torque3);
         outputs[5].setText(angle3);
    else if (passCounter == 2)
    { outputs[6].setText(torque1);
         outputs[7].setText(angle1);
         outputs[8].setText(torque2);
         outputs[9].setText(angle2);
         outputs[10].setText(torque3);
         outputs[11].setText(angle3);
    else if (passCounter == 3)
    { outputs[12].setText(torque1);
         outputs[13].setText(angle1);
         outputs[14].setText(torque2);
         outputs[15].setText(angle2);
         outputs[16].setText(torque3);
         outputs[17].setText(angle3);
    } // end of while loop
    It compiles, but it does not run. I get the errors I mentioned above when I try to run the program.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

  • Managing big messy complex code

    So, I'm planning on doing some conversion of about 800K (compressed) of C source to C++.  It's already in a nice C-OO style of coding.  That is:
    struct xyz { ... };
    void xyz_move(struct xyz* pxyz, ...other args...)
    void xyz_add(struct xyz* pxyz, ...other args...)
    Yet it's also written K&R style which died in the 80s...
    void
    xyz_something(pxyz, a, b, c, d)
    struct xyz *pxyz,
    int a, b
    char *c
    int d
    ...body here
    So the conversion isn't that hard.  The problem is that it's totally and wickedly unorganized... i.e. one file has 3 C "classes" listed, as well as the prototypes for 2 of the function sets.  The other function set is in a different header, and all 3 are in their own implementation files, along with other random functions prototyped in a totally different header.
    Short story: it's a mess.  I'd like to convert it to a nice 1-to-1 header/implementation relationship, but there's alot of code.  I'm wondering if anyone knows of any tools (or even simple refactoring techniques) to aid me.  I can do it manually, it will just take me a long time.
    Note: during this conversion I will not be switching the stuff over to C++ types (i.e. std::list<xyz*> instead of struct xyz**).  That will be done later, so in all honesty I only need C refactoring tools....

    Hmmm, yeah I guess I could collect code and things, but what I'd like to do, is take a struct, along with related prototypes into one header file, and cram the implementations on the function in a related file.  Bascially I'm trying to save myself a few days of random... "ok this is a XYZ function, copy, paste in xyh.c and xyz.h, delete from original"
    There should be refactoring tools out there to do something similar... maybe I'll check the vim scripts...

  • Strategy for implementing drpdownlistbykey in header / detail relationship

    Quite often I have header details relationships that I want to display.  The volumes of data are typically small, so rather than make multiple trips to the database I choose to load all the data into context during the init routine.  Implementing an efficient way to dispay this data and keep the header details relationship syncronized on the screen is where I am looking for suggestions.
    A good example would be selecting a user from a list and displaying details of that user in a series of text views.
    Currently to implement this, I load all the user detail into separate elements within a node. Simultaniously I load a value set with key information which is then used by a drop down list.   A series of text views are bound to attributes in the context outside the detail node.  These attributes contain the currently selected user detail information.  When a user is selected from the drop down list, the select event fires, and a search is performed of all the detail node elements for that key.  Once found, the user detail information is copied from the appropriate element to the corresponding 'current value' attributes.
    This process seems a bit cumbersome to me.  I am wondering if there are more efficient ways to manage this routine scenario.  Possibly there is a way of binding the text views directly to the attributes in the detail node and switching the element that is currently displayed?  I am just not aware of any way to do that.
    Any suggestions would be greatly appreciated
    -Sheldon

    Say you have a context node "Users", cardinality 0:N, with attributes like "Name" etc.
    Use a DropDown<b>ByIndex</b> element, bind property "texts" to attribute "Name". Assign an empty action to the "onSelect" event.
    Create a form for the details, bind the contained InputField, TextView, whatever to the attributes inside node "Users".
    Then you can select a user from the dropdown list (which displays the user names) and the detail form automatically displays the data of the (lead-)selected context element.
    Armin

  • How to implement sorting on a group of records by clicking on the header?

    I am using Oracle Forms 6i. Now I have a table of records having a column header in a custom form. Now I want to sort that column data by clicking on the column header (showing an arrow mark of asc/desc while I press the button). How to implement this? A sample code will be very helpful.

    Hi
    We can't set value to system forms dbdatasource , only getvalue is allowed .
    For i = 1 To oMatrix.RowCount
           oEditText = matrix.GetCellSpecific("column name", i)
           oEditText .String="15"
    Next
    Regards
    Arun

  • Trouble implementing a header on Wordpress

    I installed the Edge Suite Plugin. I used the shortcode to successfully implement my animation I created for my about me page. I now want to implement a header I created for my site. I uploaded the animation witth the .oam file and chose it as my "default composition". It worked, except an image is visible when it is off my stage in Edge. The file is not showing just what is visible in the stage like it should. Does anyone know how to solve this problem?

    Great!!!
    Here goes...
    ///Frame 1///
    var amountLoaded:Number = _root.getBytesLoaded()/_root.getBytesTotal();
    loadText.text = Math.round(amountLoaded * 100) + "%";
    ///Frame 2///
    if(_root.getBytesLoaded() == _root.getBytesTotal()) {
    _root.gotoAndPlay(2);
    else {
    gotoAndPlay(1);

  • How to implement column header sort

    Hi all,
    Does anyone know how to configure Oracle 9i AS Portal Release 2 column header sort.
    In Portal, Oracle has setup the IDE to sort your columns using arrow keys in the
    column headers. I would like to do the same thing without using the Custom Form.
    TIA,
    Daniel N

    I would suggest using the built in Collections framework for sorting.
    have class A implement the Comparable interface then implement the compareTo method as follows:
    public int compareTo(Object o) {
        A a = (A)o;  // <-- may cause ClassCastException if (o instanceof A) != true, but that should not be a problem.
        int value = attr1.compareTo(a.attr1);
        if (value != 0) return value;
        value = attr2.compareTo(a.attr2);
        if (value != 0) return value;
        value = a.attr3.compareTo(attr3);  //Notice I switched a.attr3 and attr3 for desc
        return value;
    }That should do it for you.
    Now put everything into an instance of java.util.List and pass that to java.util.Collections.sort(java.util.List);
    If you didn't create class A, and therefore can't add a method to it, then implement a Comparator. The idea is the same, just look at the java.util.Comparator API and use java.util.Collection.sort(java.util.List, java.util.Comparator) method to sort;

  • Implementing C language TCP header using Java

    Hello,
    I am in need of implementing the following C language code under Java...
      short len;
      struct
        char trans_id[4];
        char trans_filler[46];
        char data_vector[2];
        char data_len[2];
      } tcp_hdr;
      len = 257;
      memcpy(&tcp_hdr.trans_id[0], "SURV", 4);
      memset(&tcp_hdr.trans_filler[0], NULL, sizeof(tcp_hdr.trans_filler);
      tcp_hdr.data_vector[0] = 0x00;
      tcp_hdr.data_vector[1] = 0x08;
      memcpy(&tcp.hdr.data_len[0], &len, 2);
    }The code is used to create a TCP header that is prefixed on all Socket messages sent to the host.
    I thought I would throw this out and see if anyone has any ideas on how to implement this...
    Thanks.
    -Jeff

    Hello,
    I am in need of implementing the following C language
    code under Java...
    short len;
    struct
    char trans_id[4];
    char trans_filler[46];
    char data_vector[2];
    char data_len[2];
    } tcp_hdr;
    len = 257;
    memcpy(&tcp_hdr.trans_id[0], "SURV", 4);
    memset(&tcp_hdr.trans_filler[0], NULL,
    sizeof(tcp_hdr.trans_filler);
    tcp_hdr.data_vector[0] = 0x00;
    tcp_hdr.data_vector[1] = 0x08;
    memcpy(&tcp.hdr.data_len[0], &len, 2);The code is used to create a TCP header that is
    prefixed on all Socket messages sent to the host.
    I thought I would throw this out and see if anyone
    has any ideas on how to implement this...
    Thanks.
    -JeffWhat is the problem? You can write an identical header in many different ways. One is to use DataOutputStream.
    Kaj

  • Where is LogOn Ticket implemented in WS consumption (header/envelope)???

    Hi
    Just a short technical question regarding sso:
    Does someone know where the SAP Logon Ticket is transmitted within the HTTP Protokol?
    I want to consume a 3rd party web service and now I am wondering if the LogOn Ticket is transmitted within the header or the Envelope of the communication?
    Can someone help me out?
    Thanks,
    Minima
    P.S:  It would really help if someone could send me a link to some proper documentation of that issue.

    Hi,
    SAP provides a Web Server filter that can be used for an authentication by means of http header varaible and a dynamic link library for verifying SSO tickets in 3rd party software which can be used to provide support for SAP Logon Tickets in Java applications.
    Please go through these links:
    Single Sign-On of Windows-based Web Service Clients using SAP Logon Tickets
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5bc7e899-0e01-0010-cca9-84f45118dd17
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ae399f0d-0301-0010-cebf-bb13f430af55
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/47d0cd90-0201-0010-4c86-f81b1c812e50
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4f209cf3-0201-0010-1db5-d2e33048b6c8
    Hope it helps.
    Regards,
    Mona
    Edited by: Mona Kapur on Jan 21, 2008 8:11 PM

Maybe you are looking for