|
1-Wire API for .NET Version 4.00
|
Class to provide read/write cache services to a 1-Wire memory device. More...
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. | |
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:
| MemoryCache | ( | OneWireContainer | device | ) |
Construct a new memory cache for provided 1-wire container device.
| device | 1-Wire container |
| MemoryCache | ( | OneWireContainer[] | devices | ) |
Construct a new memory cache for provided 1-wire container device.
| device | 1-Wire container |
| void addOwner | ( | Object | tobj | ) |
Add an owner to this memory cache.
This will be tracked for later cleanup.
| tobj | owner 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
| page | number to mark as un-used |
| int getBitMapNumberOfPages | ( | ) |
Get the number of pages used for the remote page bitmap in an OTP device.
| int getBitMapPageNumber | ( | ) |
Gets the page number used in the remote page bitmap in an OTP device.
| int getFirstFreePage | ( | ) |
Get the first free page from the page bitmap.
| 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.
| 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.
| int getNumberFreePages | ( | ) | throws OneWireException |
Get the total number of free pages in this Filesystem.
| OneWireException | when an IO exception occurs |
| int getNumberPages | ( | ) |
Gets the number of pages in this cache.
| int getNumberPagesInBank | ( | int | bankNum | ) |
Gets the number of pages in the specified bank number.
| bankNum | bank number to retrieve number of pages |
| 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.
| deviceNum | device number to retrieve page offset |
| boolean handlePageBitmap | ( | ) |
Check to see 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.
| filePath | file to check to see if opened to write |
| addToList | true to add file to list if not present |
| 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.
| void markPageUsed | ( | int | page | ) |
Mark the specified page as used in the page bitmap.
| page | number to mark as used |
| boolean noOwners | ( | ) |
Check to see if there on no 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.
| page | page to read |
| readBuf | buffer to place the data in |
| offset | offset into the read buffer |
| OneWireException | when the adapter is not setup properly |
| OneWireIOException | when an 1-Wire IO error occures |
| void removeOwner | ( | Object | tobj | ) |
Remove the specified owner of this memory cache.
| tobj | owner of instance |
| void removeWriteOpen | ( | String | filePath | ) |
Remove the provided filePath from the list of files currently opened to write.
| filePath | file to remove from write list |
| void sync | ( | ) | throws OneWireIOException, OneWireException |
Flush the pages written back to the 1-Wire device.
| OneWireException | when the adapter is not setup properly |
| OneWireIOException | when 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.
| page | page to write |
| writeBuf | buffer container the data to write |
| offset | offset into write buffer |
| buflen | length of data to write |
1.7.3