• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView with NSArray and C-array question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView with NSArray and C-array question


  • Subject: Re: NSTableView with NSArray and C-array question
  • From: Gilles Celli <email@hidden>
  • Date: Wed, 25 Oct 2006 17:27:09 +0200

Sorry guys, I've found the error: since I'm using a pointer of 'struct tm *tm_utc' it will not work.

I've fixing it by simply copying the tm_utc structure in their resp. variables, like:
second = tm_utc->tm_sec;


or I will use a NSCalendarDate....


On Oct 25, 2006, at 4:24 PM, Gilles Celli wrote:

Hello,

Hope someone remembers my problem I had with NSTableView....
I've been quite busy these last days coding and I got finally a working NSTableView with acquired data from a Keithley Multimeter with 16 channels (via USB port).


For speed and memory efficiency I'm just using plain old C- structure instead of NSArray as you guys suggested here on the mailing-list.
This works great!!


However I have the following problem:

The timevalue of the acquisiton in the NSTableview gets updated but every row gets the same value... the channel values are correct.

Remember that the acquisition is every 5seconds....making an NSLog of the time structure correctly spits out the time.

E.g in NSTableView:

Time		|  Chan1  | Chan 2 | ...
14:51:05	|  0.912  	|  0.122	|
14:51:05	|  1.331	|  0.811	| <= time bug, should be +5 seconds :-(
14:51:05	|  1.331	|  0.811	| <= time bug, should be +10 seconds :-(


Here's my C-structure declared in my class:

struct keithley_struct {

		// Normal time structure
		struct tm *tm_utc;

		double channel[MAX_NBR_OF_CHANNELS];

} k2700_data[MAX_ACQ_DATA_PER_DAY];

And here from my Controller the tableView code:

- (int) numberOfRowsInTableView:(NSTableView *)tableView
{
	return [k2700 currentRow];
}


- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)Column row:(int)Row
{
int i=0;
NSString *identifier = [Column identifier];

struct keithley_struct *k2700_str;

k2700_str = [k2700 k2700_data];


	for (i=0 ; i <= NBR_OF_CHANNELS; i++)
	{
		if ( [identifier isEqualToString:@"time"])
	{
		return [NSNumber numberWithInt:k2700_str[Row].tm_utc->tm_sec ];
	}

if ( [identifier isEqualToString:[[NSNumber numberWithInt:(i+1)] stringValue]])
{
return [NSNumber numberWithDouble:k2700_str[Row].channel[i]];
}
}


}


Any ideas ?

Thanks

Gilles Celli





On Oct 13, 2006, at 6:15 PM, R. Matthew Emerson wrote:


On Oct 13, 2006, at 11:43 AM, Gilles Celli wrote:


On Oct 13, 2006, at 5:39 PM, Glenn Zelniker wrote:


On Oct 13, 2006, at 11:34 AM, Gilles Celli wrote:

I'm assuming that you're trying to display in your table the data for a number of sensors (indicated by a column) at different points in time (indicated by row position). Is this correct?
yes right! In fact voltage values for a 16 channel multimeter. The NSTableView columns have numerical identifiers (1-16) and with Date/Time (but not implemented yet...).

Until you implement the Date/Time and map it to a row index, you're not going to see anything meaningful in your table.


GZ

so you think I that I should return a NSCalendarDate in method - (int)numberOfRowsInTableView... ?

No, that wouldn't do anything useful.

(Warning, code typed in mail.)

Say that you place each sample acquired from the digital multimeter into a C struct. (I seem to recall that you were asking about putting data stored in a C array into a table view, so I'll use vanilla C rather than objects.)

#include <sys/time.h>

struct sample {
struct timeval tv; /* via gettimeofday(2), for example, or use NSDate */
double channels[15];
};


struct sample samples[20000];	/* or dynamically allocate */
int nsamples;

Then your table view data source methods might look something like this:

- (int) numberOfRowsInTableView:(NSTableView *)tableView
{
    return nsamples;
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)Column row:(int)Row
{
struct sample s = samples[Row];


    if ([[Column identifier] isEqualToString:@"1"])
        return [NSNumber numberWithDoublle:s.channels[0]];
    else if ([[Column identifier] isEqualToString:@"2"])
        return [NSNumber numberWithDoublle:s.channels[1]];
    etc.

}

You could also put the timestamps in the table view by adding another column with an identifier of "timestamp", and formatting the struct timeval appropriately.





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: "Mark Munz" <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: "R. Matthew Emerson" <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)

  • Prev by Date: Re: FSCopyAsync Example + Updating UI
  • Next by Date: Re: NSSplitView iTunes Like
  • Previous by thread: Re: NSTableView with NSArray and C-array question
  • Next by thread: NSTimer question: How to fire at second 00, 05, 10 etc ?
  • Index(es):
    • Date
    • Thread