1-Wire API for .NET Version 4.00
Public Member Functions

MemoryCache Class Reference

Class to provide read/write cache services to a 1-Wire memory device. More...

List of all members.

Public Member Functions

 MemoryCache (OneWireContainer device)
 Construct a new memory cache for provided 1-wire container device.
 MemoryCache (OneWireContainer[] devices)
 Construct a new memory cache for provided 1-wire container device.
int getNumberPages ()
 Gets the number of pages in this cache.
int getNumberPagesInBank (int bankNum)
 Gets the number of pages in the specified bank number.
int getPageOffsetForDevice (int deviceNum)
 Gets the page number of the first page on the specified device.
int getMaxPacketDataLength ()
 Gets the maximum number of bytes for data in each page.
boolean isWriteOnce ()
 Check if this memory device is write-once.
int readPagePacket (int page, byte[] readBuf, int offset) throws OneWireIOException, OneWireException
 Read a page packet.
void writePagePacket (int page, byte[] writeBuf, int offset, int buflen) throws OneWireIOException, OneWireException
 Write a page packet into the cache.
void sync () throws OneWireIOException, OneWireException
 Flush the pages written back to the 1-Wire device.
void addOwner (Object tobj)
 Add an owner to this memory cache.
void removeOwner (Object tobj)
 Remove the specified owner of this memory cache.
boolean noOwners ()
 Check to see if there on no owners of this memory cache.
void removeWriteOpen (String filePath)
 Remove the provided filePath from the list of files currently opened to write.
boolean isOpenedToWrite (String filePath, boolean addToList)
 Check to see if the provided filePath is currently opened to write.
boolean handlePageBitmap ()
 Check to see if this memory cache should handle the page bitmap.
void markPageUsed (int page)
 Mark the specified page as used in the page bitmap.
boolean freePage (int page)
 free the specified page as being un-used in the page bitmap
int getFirstFreePage ()
 Get the first free page from the page bitmap.
int getNextFreePage ()
 Get the next free page from the page bitmap.
int getNumberFreePages () throws OneWireException
 Get the total number of free pages in this Filesystem.
int getBitMapPageNumber ()
 Gets the page number used in the remote page bitmap in an OTP device.
int getBitMapNumberOfPages ()
 Get the number of pages used for the remote page bitmap in an OTP device.
PagedMemoryBank getMemoryBankForPage (int page)
 Get's the memory bank object for the specified page.
int getLocalPage (int page)
 Get's the local page number on the memory bank object for the specified page.
void clearLastPageRead ()
 Clears the lastPageRead global so that a readPage will not try to continue where the last page left off.

Detailed Description

Class to provide read/write cache services to a 1-Wire memory device.

Writes are only performed when this classes sync() method is called. Provides page bitmap services for OTP devices.

Objectives:

Author:
DS
Version:
0.01, 1 June 2001
See also:
com.dalsemi.onewire.application.file.OWFile
com.dalsemi.onewire.application.file.OWFileDescriptor
com.dalsemi.onewire.application.file.OWFileInputStream
com.dalsemi.onewire.application.file.OWFileOutputStream

Constructor & Destructor Documentation

Construct a new memory cache for provided 1-wire container device.

Parameters:
device1-Wire container
MemoryCache ( OneWireContainer[]  devices)

Construct a new memory cache for provided 1-wire container device.

Parameters:
device1-Wire container

Member Function Documentation

void addOwner ( Object  tobj)

Add an owner to this memory cache.

This will be tracked for later cleanup.

Parameters:
tobjowner of instance
void clearLastPageRead ( )

Clears the lastPageRead global so that a readPage will not try to continue where the last page left off.

This should be called anytime exclusive access to the 1-Wire canot be guaranteed.

boolean freePage ( int  page)

free the specified page as being un-used in the page bitmap

Parameters:
pagenumber to mark as un-used
Returns:
true if the page as be been marked as un-used, false if the page is on an OTP device and cannot be freed
int getBitMapNumberOfPages ( )

Get the number of pages used for the remote page bitmap in an OTP device.

Returns:
number of pages used in page bitmap
int getBitMapPageNumber ( )

Gets the page number used in the remote page bitmap in an OTP device.

Returns:
page number used in the directory for the remote page bitmap
int getFirstFreePage ( )

Get the first free page from the page bitmap.

Returns:
first page number that is free to write
int getLocalPage ( int  page)

Get's the local page number on the memory bank object for the specified page.

This is significant if the Filesystem spans memory banks on the same or different devices.

int getMaxPacketDataLength ( )

Gets the maximum number of bytes for data in each page.

Returns:
max number of data bytes per page
PagedMemoryBank getMemoryBankForPage ( int  page)

Get's the memory bank object for the specified page.

This is significant if the Filesystem spans memory banks on the same or different devices.

int getNextFreePage ( )

Get the next free page from the page bitmap.

Returns:
next page number that is free to write
int getNumberFreePages ( ) throws OneWireException

Get the total number of free pages in this Filesystem.

Returns:
number of pages free
Exceptions:
OneWireExceptionwhen an IO exception occurs
int getNumberPages ( )

Gets the number of pages in this cache.

Returns:
number of pages in the cache
int getNumberPagesInBank ( int  bankNum)

Gets the number of pages in the specified bank number.

Parameters:
bankNumbank number to retrieve number of pages
Returns:
number of pages in the bank
int getPageOffsetForDevice ( int  deviceNum)

Gets the page number of the first page on the specified device.

If the device number is not valid then return 0.

Parameters:
deviceNumdevice number to retrieve page offset
Returns:
page number of first page on device
boolean handlePageBitmap ( )

Check to see if this memory cache should handle the page bitmap.

Returns:
true if this memory cache should handle the page bitmap
boolean isOpenedToWrite ( String  filePath,
boolean  addToList 
)

Check to see if the provided filePath is currently opened to write.

Optionally add it to the list if it not already there.

Parameters:
filePathfile to check to see if opened to write
addToListtrue to add file to list if not present
Returns:
true if file was not in the opened to write list
boolean isWriteOnce ( )

Check if this memory device is write-once.

If this is true then the page bitmap facilities in this class will be used.

Returns:
true if this device is write-once
void markPageUsed ( int  page)

Mark the specified page as used in the page bitmap.

Parameters:
pagenumber to mark as used
boolean noOwners ( )

Check to see if there on no owners of this memory cache.

Returns:
true if not owners of this memory cache
int readPagePacket ( int  page,
byte[]  readBuf,
int  offset 
) throws OneWireIOException, OneWireException

Read a page packet.

If the page is available in the cache then return that data.

Parameters:
pagepage to read
readBufbuffer to place the data in
offsetoffset into the read buffer
Returns:
the number byte in the packet
Exceptions:
OneWireExceptionwhen the adapter is not setup properly
OneWireIOExceptionwhen an 1-Wire IO error occures
void removeOwner ( Object  tobj)

Remove the specified owner of this memory cache.

Parameters:
tobjowner of instance
void removeWriteOpen ( String  filePath)

Remove the provided filePath from the list of files currently opened to write.

Parameters:
filePathfile to remove from write list
void sync ( ) throws OneWireIOException, OneWireException

Flush the pages written back to the 1-Wire device.

Exceptions:
OneWireExceptionwhen the adapter is not setup properly
OneWireIOExceptionwhen an 1-Wire IO error occures
void writePagePacket ( int  page,
byte[]  writeBuf,
int  offset,
int  buflen 
) throws OneWireIOException, OneWireException

Write a page packet into the cache.

Parameters:
pagepage to write
writeBufbuffer container the data to write
offsetoffset into write buffer
buflenlength of data to write

The documentation for this class was generated from the following file: