Code Monkey home page Code Monkey logo

objcvcd's Introduction

objCVCD

A VCD parser aiming to support IEEE 1364-1995.

Usage

Opening a document

To load an VCD file from local storage use

[VCD loadWithPath:filePath callback:^(VCD *vcd) {
	if(vcd == nil) {
		NSLog(@"VCD Parsing Error!");
		return;
	}
	
	// ...
}];

To load a VCD file from a web based location, use

[VCD loadWithURL:[NSURL URLWithString:@"http://your.location/test.vcd"] callback:^(VCD *vcd) {
	if(vcd == nil) {
		NSLog(@"VCD Parsing Error!");
		return;
	}
	
	// ...
}];

To simplify prototyping, we support a list of sample VCD files which can be accessed by this piece of code:

NSDictionary *samples = [VCD loadAvailableSamples];

for(NSString title in [samples allKeys]) {
	NSURL *url = [samples objectForKey:title];
	
	NSLog(@"Title: %@; URL: %@", title, url);
}

Please keep in mind, that loadAvailableSamples uses blocking I/O.

Elements of VCD:

  • [VCD loadWithPath:path callback:^(VCD *vcd) { /* ... */}]: Loads VCD from NSString path and calls callback
  • [VCD loadWithURL:url callback:^(VCD *vcd) { /* ... */}]: Loads VCD from NSURL and calls callback
  • [VCD loadAvailableSamples]: Loads NSDictionary of samples of NSURLs and NSString as its key.
  • [vcd signals]: returns NSDictionary of signals, identified by signal name
  • [vcd timeScale]: returns int of timescale factor
  • [vcd timeScaleUnit]: returns NSString of timescale unit (e.g. ns)
  • [vcd date]: returns NSDate of creation
  • [vcd version]: returns NSString version
  • [vcd scope]: returns NSString scope

Accessing Signals

VCD *vcd = nil;

// Magically loading a VCD file
// ...

for(VCDSignal *signal in [[vcd signals] allValues]) {
	NSLog("Name of signal: %@", [signal name]);
}

Elements of VCDSignal:

  • [signal name]: returns NSString name of signal
  • [signal symbol]: returns NSString symbol of signal
  • [signal symbol]: returns NSString symbol of signal
  • [vcd valueAtTime:time]: returns value at specific time.

Accessing Signal Values

VCDSignal *signal = nil;

// Magically loads VCD Signal
// ...

// Access value at specific time.
// Please note, that valueAtTime does NOT respect the timescale!
VCDValue *v = [signal valueAtTime:500];

NSLog(@"First ValueChange at %d", [v time]);
// The VCDValue will be the very first value before the given time.
// Therefore, [v time] will be lesser equal 500.

// Iterate through values:
do {
	NSLog("ValueChange at: %d: newValue: %@", [v time], [v value]);
} while(v = [v next]);

// Or in short:
for(VCDValue *v = [signal valueAtTime:500]; v != nil; v = [v next]) {
	// ...
}

objcvcd's People

Contributors

gottox avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.