mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Sort out a whole bunch of other things, including cleaning up the way the
verification source is handled.
This commit is contained in:
		| @@ -2,9 +2,10 @@ | ||||
| #define AESLANIER_H | ||||
|  | ||||
| #define AESLANIER_RECORD_SEPARATOR 0x55555122 | ||||
| #define AESLANIER_SECTOR_LENGTH    256 | ||||
| #define AESLANIER_RECORD_SIZE      (AESLANIER_SECTOR_LENGTH + 5) | ||||
| #define AESLANIER_SECTOR_LENGTH 256 | ||||
| #define AESLANIER_RECORD_SIZE (AESLANIER_SECTOR_LENGTH + 5) | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createAesLanierDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createAesLanierDecoder( | ||||
|     const DecoderProto& config); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -17,4 +17,3 @@ extern std::unique_ptr<Encoder> createAgatEncoder(const EncoderProto& config); | ||||
| extern uint8_t agatChecksum(const Bytes& bytes); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,16 +5,15 @@ | ||||
| #include "decoders/decoders.h" | ||||
| #include "encoders/encoders.h" | ||||
|  | ||||
| #define APPLE2_SECTOR_RECORD   0xd5aa96 | ||||
| #define APPLE2_DATA_RECORD     0xd5aaad | ||||
| #define APPLE2_SECTOR_RECORD 0xd5aa96 | ||||
| #define APPLE2_DATA_RECORD 0xd5aaad | ||||
|  | ||||
| #define APPLE2_SECTOR_LENGTH   256 | ||||
| #define APPLE2_SECTOR_LENGTH 256 | ||||
| #define APPLE2_ENCODED_SECTOR_LENGTH 342 | ||||
|  | ||||
| #define APPLE2_SECTORS         16 | ||||
| #define APPLE2_SECTORS 16 | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createApple2Decoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createApple2Encoder(const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -3,17 +3,19 @@ | ||||
|  | ||||
| /* Brother word processor format (or at least, one of them) */ | ||||
|  | ||||
| #define BROTHER_SECTOR_RECORD            0xFFFFFD57 | ||||
| #define BROTHER_DATA_RECORD              0xFFFFFDDB | ||||
| #define BROTHER_DATA_RECORD_PAYLOAD      256 | ||||
| #define BROTHER_DATA_RECORD_CHECKSUM     3 | ||||
| #define BROTHER_SECTOR_RECORD 0xFFFFFD57 | ||||
| #define BROTHER_DATA_RECORD 0xFFFFFDDB | ||||
| #define BROTHER_DATA_RECORD_PAYLOAD 256 | ||||
| #define BROTHER_DATA_RECORD_CHECKSUM 3 | ||||
| #define BROTHER_DATA_RECORD_ENCODED_SIZE 415 | ||||
|  | ||||
| #define BROTHER_TRACKS_PER_240KB_DISK    78 | ||||
| #define BROTHER_TRACKS_PER_120KB_DISK    39 | ||||
| #define BROTHER_SECTORS_PER_TRACK        12 | ||||
| #define BROTHER_TRACKS_PER_240KB_DISK 78 | ||||
| #define BROTHER_TRACKS_PER_120KB_DISK 39 | ||||
| #define BROTHER_SECTORS_PER_TRACK 12 | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createBrotherDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createBrotherEncoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createBrotherDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createBrotherEncoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
| GCR_ENTRY(0x55, 0) // 00000 | ||||
| GCR_ENTRY(0x57, 1) // 00001 | ||||
| GCR_ENTRY(0x5b, 2) // 00010 | ||||
| GCR_ENTRY(0x5d, 3) // 00011 | ||||
| GCR_ENTRY(0x5f, 4) // 00100  | ||||
| GCR_ENTRY(0x6b, 5) // 00101 | ||||
| GCR_ENTRY(0x6d, 6) // 00110 | ||||
| GCR_ENTRY(0x6f, 7) // 00111 | ||||
| GCR_ENTRY(0x75, 8) // 01000 | ||||
| GCR_ENTRY(0x77, 9) // 01001 | ||||
| GCR_ENTRY(0x55, 0)  // 00000 | ||||
| GCR_ENTRY(0x57, 1)  // 00001 | ||||
| GCR_ENTRY(0x5b, 2)  // 00010 | ||||
| GCR_ENTRY(0x5d, 3)  // 00011 | ||||
| GCR_ENTRY(0x5f, 4)  // 00100 | ||||
| GCR_ENTRY(0x6b, 5)  // 00101 | ||||
| GCR_ENTRY(0x6d, 6)  // 00110 | ||||
| GCR_ENTRY(0x6f, 7)  // 00111 | ||||
| GCR_ENTRY(0x75, 8)  // 01000 | ||||
| GCR_ENTRY(0x77, 9)  // 01001 | ||||
| GCR_ENTRY(0x7b, 10) // 01010 | ||||
| GCR_ENTRY(0x7d, 11) // 01011 | ||||
| GCR_ENTRY(0x7f, 12) // 01100 | ||||
| @@ -30,4 +30,3 @@ GCR_ENTRY(0xef, 28) // 11100 | ||||
| GCR_ENTRY(0xf5, 29) // 11101 | ||||
| GCR_ENTRY(0xf7, 30) // 11110 | ||||
| GCR_ENTRY(0xfb, 31) // 11111 | ||||
|  | ||||
|   | ||||
| @@ -76,4 +76,3 @@ GCR_ENTRY(0x6BAB, 74) | ||||
| GCR_ENTRY(0xAD5F, 75) | ||||
| GCR_ENTRY(0xDBED, 76) | ||||
| GCR_ENTRY(0x55BB, 77) | ||||
|  | ||||
|   | ||||
| @@ -4,11 +4,11 @@ | ||||
| #include "decoders/decoders.h" | ||||
| #include "encoders/encoders.h" | ||||
|  | ||||
| #define C64_SECTOR_RECORD    0xffd49 | ||||
| #define C64_DATA_RECORD      0xffd57 | ||||
| #define C64_SECTOR_LENGTH    256 | ||||
| #define C64_SECTOR_RECORD 0xffd49 | ||||
| #define C64_DATA_RECORD 0xffd57 | ||||
| #define C64_SECTOR_LENGTH 256 | ||||
|  | ||||
| /* Source: http://www.unusedino.de/ec64/technical/formats/g64.html  | ||||
| /* Source: http://www.unusedino.de/ec64/technical/formats/g64.html | ||||
|    1. Header sync       FF FF FF FF FF (40 'on' bits, not GCR) | ||||
|    2. Header info       52 54 B5 29 4B 7A 5E 95 55 55 (10 GCR bytes) | ||||
|    3. Header gap        55 55 55 55 55 55 55 55 55 (9 bytes, never read) | ||||
| @@ -17,18 +17,20 @@ | ||||
|    6. Inter-sector gap  55 55 55 55...55 55 (4 to 12 bytes, never read) | ||||
|    1. Header sync       (SYNC for the next sector) | ||||
| */ | ||||
| #define C64_HEADER_DATA_SYNC        0xFF | ||||
| #define C64_HEADER_BLOCK_ID         0x08 | ||||
| #define C64_DATA_BLOCK_ID           0x07 | ||||
| #define C64_HEADER_GAP              0x55 | ||||
| #define C64_INTER_SECTOR_GAP        0x55 | ||||
| #define C64_PADDING                 0x0F | ||||
| #define C64_HEADER_DATA_SYNC 0xFF | ||||
| #define C64_HEADER_BLOCK_ID 0x08 | ||||
| #define C64_DATA_BLOCK_ID 0x07 | ||||
| #define C64_HEADER_GAP 0x55 | ||||
| #define C64_INTER_SECTOR_GAP 0x55 | ||||
| #define C64_PADDING 0x0F | ||||
|  | ||||
| #define C64_TRACKS_PER_DISK         40 | ||||
| #define C64_BAM_TRACK               17 | ||||
| #define C64_TRACKS_PER_DISK 40 | ||||
| #define C64_BAM_TRACK 17 | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createCommodore64Decoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createCommodore64Encoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createCommodore64Decoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createCommodore64Encoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| extern nanoseconds_t clockPeriodForC64Track(unsigned track); | ||||
|  | ||||
|   | ||||
| @@ -2,9 +2,10 @@ | ||||
| #define F85_H | ||||
|  | ||||
| #define F85_SECTOR_RECORD 0xffffce /* 1111 1111 1111 1111 1100 1110 */ | ||||
| #define F85_DATA_RECORD 0xffffcb /* 1111 1111 1111 1111 1100 1101 */ | ||||
| #define F85_SECTOR_LENGTH    512 | ||||
| #define F85_DATA_RECORD 0xffffcb   /* 1111 1111 1111 1111 1100 1101 */ | ||||
| #define F85_SECTOR_LENGTH 512 | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createDurangoF85Decoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createDurangoF85Decoder( | ||||
|     const DecoderProto& config); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -8,4 +8,3 @@ | ||||
| extern std::unique_ptr<Decoder> createFb100Decoder(const DecoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -31,9 +31,7 @@ class Decoder; | ||||
| class DecoderProto; | ||||
| class EncoderProto; | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createIbmDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createIbmEncoder( | ||||
|     const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createIbmDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createIbmEncoder(const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| #ifndef MACINTOSH_H | ||||
| #define MACINTOSH_H | ||||
|  | ||||
| #define MAC_SECTOR_RECORD   0xd5aa96 /* 1101 0101 1010 1010 1001 0110 */ | ||||
| #define MAC_DATA_RECORD     0xd5aaad /* 1101 0101 1010 1010 1010 1101 */ | ||||
| #define MAC_SECTOR_RECORD 0xd5aa96 /* 1101 0101 1010 1010 1001 0110 */ | ||||
| #define MAC_DATA_RECORD 0xd5aaad   /* 1101 0101 1010 1010 1010 1101 */ | ||||
|  | ||||
| #define MAC_SECTOR_LENGTH   524 /* yes, really */ | ||||
| #define MAC_SECTOR_LENGTH 524 /* yes, really */ | ||||
| #define MAC_ENCODED_SECTOR_LENGTH 703 | ||||
| #define MAC_FORMAT_BYTE     0x22 | ||||
| #define MAC_FORMAT_BYTE 0x22 | ||||
|  | ||||
| #define MAC_TRACKS_PER_DISK 80 | ||||
|  | ||||
| @@ -15,8 +15,9 @@ class Decoder; | ||||
| class DecoderProto; | ||||
| class EncoderProto; | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createMacintoshDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createMacintoshEncoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createMacintoshDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createMacintoshEncoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,17 +1,20 @@ | ||||
| #ifndef MICROPOLIS_H | ||||
| #define MICROPOLIS_H | ||||
|  | ||||
| #define MICROPOLIS_PAYLOAD_SIZE         (256) | ||||
| #define MICROPOLIS_HEADER_SIZE          (1+2+10) | ||||
| #define MICROPOLIS_ENCODED_SECTOR_SIZE  (MICROPOLIS_HEADER_SIZE + MICROPOLIS_PAYLOAD_SIZE + 6) | ||||
| #define MICROPOLIS_PAYLOAD_SIZE (256) | ||||
| #define MICROPOLIS_HEADER_SIZE (1 + 2 + 10) | ||||
| #define MICROPOLIS_ENCODED_SECTOR_SIZE \ | ||||
|     (MICROPOLIS_HEADER_SIZE + MICROPOLIS_PAYLOAD_SIZE + 6) | ||||
|  | ||||
| class Decoder; | ||||
| class Encoder; | ||||
| class EncoderProto; | ||||
| class DecoderProto; | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createMicropolisDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createMicropolisEncoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createMicropolisDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createMicropolisEncoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| extern uint8_t micropolisChecksum(const Bytes& bytes); | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| #ifndef NORTHSTAR_H | ||||
| #define NORTHSTAR_H | ||||
|  | ||||
| /* Northstar floppies are 10-hard sectored disks with a sector format as follows: | ||||
| /* Northstar floppies are 10-hard sectored disks with a sector format as | ||||
|  * follows: | ||||
|  * | ||||
|  * |----------------------------------| | ||||
|  * | SYNC Byte  | Payload  | Checksum | | ||||
| @@ -12,15 +13,19 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #define NORTHSTAR_PREAMBLE_SIZE_SD		(16) | ||||
| #define NORTHSTAR_PREAMBLE_SIZE_DD		(32) | ||||
| #define NORTHSTAR_HEADER_SIZE_SD		(1) | ||||
| #define NORTHSTAR_HEADER_SIZE_DD		(2) | ||||
| #define NORTHSTAR_PAYLOAD_SIZE_SD		(256) | ||||
| #define NORTHSTAR_PAYLOAD_SIZE_DD		(512) | ||||
| #define NORTHSTAR_CHECKSUM_SIZE		(1) | ||||
| #define NORTHSTAR_ENCODED_SECTOR_SIZE_SD	(NORTHSTAR_HEADER_SIZE_SD + NORTHSTAR_PAYLOAD_SIZE_SD + NORTHSTAR_CHECKSUM_SIZE) | ||||
| #define NORTHSTAR_ENCODED_SECTOR_SIZE_DD	(NORTHSTAR_HEADER_SIZE_DD + NORTHSTAR_PAYLOAD_SIZE_DD + NORTHSTAR_CHECKSUM_SIZE) | ||||
| #define NORTHSTAR_PREAMBLE_SIZE_SD (16) | ||||
| #define NORTHSTAR_PREAMBLE_SIZE_DD (32) | ||||
| #define NORTHSTAR_HEADER_SIZE_SD (1) | ||||
| #define NORTHSTAR_HEADER_SIZE_DD (2) | ||||
| #define NORTHSTAR_PAYLOAD_SIZE_SD (256) | ||||
| #define NORTHSTAR_PAYLOAD_SIZE_DD (512) | ||||
| #define NORTHSTAR_CHECKSUM_SIZE (1) | ||||
| #define NORTHSTAR_ENCODED_SECTOR_SIZE_SD                    \ | ||||
|     (NORTHSTAR_HEADER_SIZE_SD + NORTHSTAR_PAYLOAD_SIZE_SD + \ | ||||
|         NORTHSTAR_CHECKSUM_SIZE) | ||||
| #define NORTHSTAR_ENCODED_SECTOR_SIZE_DD                    \ | ||||
|     (NORTHSTAR_HEADER_SIZE_DD + NORTHSTAR_PAYLOAD_SIZE_DD + \ | ||||
|         NORTHSTAR_CHECKSUM_SIZE) | ||||
|  | ||||
| class Decoder; | ||||
| class Encoder; | ||||
| @@ -29,7 +34,9 @@ class DecoderProto; | ||||
|  | ||||
| extern uint8_t northstarChecksum(const Bytes& bytes); | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createNorthstarDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createNorthstarEncoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createNorthstarDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createNorthstarEncoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| #endif /* NORTHSTAR */ | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #pragma once | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createRolandD20Decoder(const DecoderProto& config); | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createRolandD20Decoder( | ||||
|     const DecoderProto& config); | ||||
|   | ||||
| @@ -7,4 +7,3 @@ | ||||
| extern std::unique_ptr<Decoder> createSmaky6Decoder(const DecoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,18 +1,18 @@ | ||||
| #ifndef TIDS990_H | ||||
| #define TIDS990_H | ||||
|  | ||||
| #define TIDS990_PAYLOAD_SIZE       288 /* bytes */ | ||||
| #define TIDS990_SECTOR_RECORD_SIZE 10 /* bytes */ | ||||
| #define TIDS990_DATA_RECORD_SIZE   (TIDS990_PAYLOAD_SIZE + 4) /* bytes */ | ||||
| #define TIDS990_PAYLOAD_SIZE 288                            /* bytes */ | ||||
| #define TIDS990_SECTOR_RECORD_SIZE 10                       /* bytes */ | ||||
| #define TIDS990_DATA_RECORD_SIZE (TIDS990_PAYLOAD_SIZE + 4) /* bytes */ | ||||
|  | ||||
| class Encoder; | ||||
| class Decoder; | ||||
| class DecoderProto; | ||||
| class EncoderProto; | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createTids990Decoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createTids990Encoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createTids990Decoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createTids990Encoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -13,12 +13,14 @@ class DecoderProto; | ||||
|  | ||||
| /* ... 1101 0100 1001 | ||||
|  *       ^^ ^^^^ ^^^^ ten bit IO byte */ | ||||
| #define VICTOR9K_DATA_RECORD   0xfffffd49 | ||||
| #define VICTOR9K_DATA_RECORD 0xfffffd49 | ||||
| #define VICTOR9K_DATA_ID 0x8 | ||||
|  | ||||
| #define VICTOR9K_SECTOR_LENGTH 512 | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createVictor9kDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createVictor9kEncoder(const EncoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createVictor9kDecoder( | ||||
|     const DecoderProto& config); | ||||
| extern std::unique_ptr<Encoder> createVictor9kEncoder( | ||||
|     const EncoderProto& config); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -1,8 +1,7 @@ | ||||
| #ifndef ZILOGMCZ_H | ||||
| #define ZILOGMCZ_H | ||||
|  | ||||
| extern std::unique_ptr<Decoder> createZilogMczDecoder(const DecoderProto& config); | ||||
| extern std::unique_ptr<Decoder> createZilogMczDecoder( | ||||
|     const DecoderProto& config); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   | ||||
							
								
								
									
										13
									
								
								lib/a2r.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								lib/a2r.h
									
									
									
									
									
								
							| @@ -1,10 +1,11 @@ | ||||
| #ifndef A2R_H | ||||
| #define A2R_H | ||||
|  | ||||
| // The canonical reference for the A2R format is: https://applesaucefdc.com/a2r2-reference/ | ||||
| // All data is stored little-endian | ||||
| // The canonical reference for the A2R format is: | ||||
| // https://applesaucefdc.com/a2r2-reference/ All data is stored little-endian | ||||
|  | ||||
| // Note: The first chunk begins at byte offset 8, not 12 as given in a2r2 reference version 2.0.1 | ||||
| // Note: The first chunk begins at byte offset 8, not 12 as given in a2r2 | ||||
| // reference version 2.0.1 | ||||
|  | ||||
| #define A2R_CHUNK_INFO (0x4F464E49) | ||||
| #define A2R_CHUNK_STRM (0x4D525453) | ||||
| @@ -12,12 +13,14 @@ | ||||
|  | ||||
| #define A2R_INFO_CHUNK_VERSION (1) | ||||
|  | ||||
| enum A2RDiskType { | ||||
| enum A2RDiskType | ||||
| { | ||||
|     A2R_DISK_525 = 1, | ||||
|     A2R_DISK_35 = 2, | ||||
| }; | ||||
|  | ||||
| enum A2RCaptureType { | ||||
| enum A2RCaptureType | ||||
| { | ||||
|     A2R_TIMING = 1, | ||||
|     A2R_BITS = 2, | ||||
|     A2R_XTIMING = 3, | ||||
|   | ||||
| @@ -8,12 +8,13 @@ class Bitmap | ||||
| public: | ||||
|     Bitmap(const std::string filename, unsigned width, unsigned height); | ||||
|  | ||||
| 	Agg2D& painter(); | ||||
| 	void save(); | ||||
|     Agg2D& painter(); | ||||
|     void save(); | ||||
|  | ||||
| private: | ||||
| 	std::vector<uint8_t> _bitmap; | ||||
| 	std::unique_ptr<Agg2D> _painter; | ||||
|     std::vector<uint8_t> _bitmap; | ||||
|     std::unique_ptr<Agg2D> _painter; | ||||
|  | ||||
| public: | ||||
|     std::string filename; | ||||
|     unsigned width; | ||||
|   | ||||
							
								
								
									
										183
									
								
								lib/bytes.h
									
									
									
									
									
								
							
							
						
						
									
										183
									
								
								lib/bytes.h
									
									
									
									
									
								
							| @@ -16,36 +16,71 @@ public: | ||||
|     Bytes(const std::string& data); | ||||
|     Bytes(std::initializer_list<uint8_t> data); | ||||
|     Bytes(std::shared_ptr<std::vector<uint8_t>> data); | ||||
|     Bytes(std::shared_ptr<std::vector<uint8_t>> data, unsigned start, unsigned end); | ||||
|     Bytes(std::shared_ptr<std::vector<uint8_t>> data, | ||||
|         unsigned start, | ||||
|         unsigned end); | ||||
|  | ||||
|     Bytes* operator = (const Bytes& other); | ||||
|     Bytes* operator=(const Bytes& other); | ||||
|  | ||||
| public: | ||||
| 	static Bytes readFromFile(const std::string& filename); | ||||
|     static Bytes readFromFile(const std::string& filename); | ||||
|  | ||||
| public: | ||||
|     /* General purpose methods */ | ||||
|  | ||||
|     unsigned size() const        { return _high - _low; } | ||||
|     bool empty() const           { return _high == _low; } | ||||
|     unsigned size() const | ||||
|     { | ||||
|         return _high - _low; | ||||
|     } | ||||
|     bool empty() const | ||||
|     { | ||||
|         return _high == _low; | ||||
|     } | ||||
|  | ||||
|     bool operator == (const Bytes& other) const | ||||
|     { return std::equal(cbegin(), cend(), other.cbegin(), other.cend()); } | ||||
|     bool operator==(const Bytes& other) const | ||||
|     { | ||||
|         return std::equal(cbegin(), cend(), other.cbegin(), other.cend()); | ||||
|     } | ||||
|  | ||||
|     bool operator != (const Bytes& other) const | ||||
|     { return !(*this == other); } | ||||
|     bool operator!=(const Bytes& other) const | ||||
|     { | ||||
|         return !(*this == other); | ||||
|     } | ||||
|  | ||||
|     const uint8_t& operator [] (unsigned offset) const; | ||||
|     const uint8_t* cbegin() const { return _data->data() + _low; } | ||||
|     const uint8_t* cend() const   { return _data->data() + _high; } | ||||
|     const uint8_t* begin() const  { return _data->data() + _low; } | ||||
|     const uint8_t* end() const    { return _data->data() + _high; } | ||||
|     const uint8_t& operator[](unsigned offset) const; | ||||
|     const uint8_t* cbegin() const | ||||
|     { | ||||
|         return _data->data() + _low; | ||||
|     } | ||||
|     const uint8_t* cend() const | ||||
|     { | ||||
|         return _data->data() + _high; | ||||
|     } | ||||
|     const uint8_t* begin() const | ||||
|     { | ||||
|         return _data->data() + _low; | ||||
|     } | ||||
|     const uint8_t* end() const | ||||
|     { | ||||
|         return _data->data() + _high; | ||||
|     } | ||||
|  | ||||
|     uint8_t& operator [] (unsigned offset); | ||||
|     uint8_t* begin()              { checkWritable(); return _data->data() + _low; } | ||||
|     uint8_t* end()                { checkWritable(); return _data->data() + _high; } | ||||
|     uint8_t& operator[](unsigned offset); | ||||
|     uint8_t* begin() | ||||
|     { | ||||
|         checkWritable(); | ||||
|         return _data->data() + _low; | ||||
|     } | ||||
|     uint8_t* end() | ||||
|     { | ||||
|         checkWritable(); | ||||
|         return _data->data() + _high; | ||||
|     } | ||||
|  | ||||
| 	operator std::string () const { return std::string(cbegin(), cend()); } | ||||
|     operator std::string() const | ||||
|     { | ||||
|         return std::string(cbegin(), cend()); | ||||
|     } | ||||
|  | ||||
|     void boundsCheck(unsigned pos) const; | ||||
|     void checkWritable(); | ||||
| @@ -53,26 +88,29 @@ public: | ||||
|     Bytes& resize(unsigned size); | ||||
|  | ||||
|     Bytes& clear() | ||||
|     { resize(0); return *this; } | ||||
|     { | ||||
|         resize(0); | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
| 	std::vector<Bytes> split(uint8_t separator) const; | ||||
|     std::vector<Bytes> split(uint8_t separator) const; | ||||
|  | ||||
|     Bytes slice(unsigned start, unsigned len) const; | ||||
|     Bytes slice(unsigned start) const; | ||||
|     Bytes swab() const; | ||||
|     Bytes compress() const; | ||||
|     Bytes decompress() const; | ||||
| 	std::vector<bool> toBits() const; | ||||
| 	Bytes reverseBits() const; | ||||
|     std::vector<bool> toBits() const; | ||||
|     Bytes reverseBits() const; | ||||
|  | ||||
| 	Bytes operator + (const Bytes& other); | ||||
| 	Bytes operator * (size_t count); | ||||
|     Bytes operator+(const Bytes& other); | ||||
|     Bytes operator*(size_t count); | ||||
|  | ||||
|     ByteReader reader() const; | ||||
|     ByteWriter writer(); | ||||
|  | ||||
|     void writeToFile(const std::string& filename) const; | ||||
| 	void writeTo(std::ostream& stream) const; | ||||
|     void writeTo(std::ostream& stream) const; | ||||
|  | ||||
| private: | ||||
|     std::shared_ptr<std::vector<uint8_t>> _data; | ||||
| @@ -83,15 +121,15 @@ private: | ||||
| class ByteReader | ||||
| { | ||||
| public: | ||||
|     ByteReader(const Bytes& bytes): | ||||
|         _bytes(bytes) | ||||
|     {} | ||||
|     ByteReader(const Bytes& bytes): _bytes(bytes) {} | ||||
|  | ||||
|     ByteReader(const Bytes&&) = delete; | ||||
|  | ||||
|     unsigned pos = 0; | ||||
|     bool eof() const | ||||
|     { return pos >= _bytes.size(); } | ||||
|     { | ||||
|         return pos >= _bytes.size(); | ||||
|     } | ||||
|  | ||||
|     ByteReader& seek(unsigned pos) | ||||
|     { | ||||
| @@ -121,7 +159,7 @@ public: | ||||
|     { | ||||
|         uint8_t b1 = _bytes[pos++]; | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         return (b1<<8) | b2; | ||||
|         return (b1 << 8) | b2; | ||||
|     } | ||||
|  | ||||
|     uint32_t read_be24() | ||||
| @@ -129,7 +167,7 @@ public: | ||||
|         uint8_t b1 = _bytes[pos++]; | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         uint8_t b3 = _bytes[pos++]; | ||||
|         return (b1<<16) | (b2<<8) | b3; | ||||
|         return (b1 << 16) | (b2 << 8) | b3; | ||||
|     } | ||||
|  | ||||
|     uint32_t read_be32() | ||||
| @@ -138,7 +176,7 @@ public: | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         uint8_t b3 = _bytes[pos++]; | ||||
|         uint8_t b4 = _bytes[pos++]; | ||||
|         return (b1<<24) | (b2<<16) | (b3<<8) | b4; | ||||
|         return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; | ||||
|     } | ||||
|  | ||||
|     uint64_t read_be48(); | ||||
| @@ -148,7 +186,7 @@ public: | ||||
|     { | ||||
|         uint8_t b1 = _bytes[pos++]; | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         return (b2<<8) | b1; | ||||
|         return (b2 << 8) | b1; | ||||
|     } | ||||
|  | ||||
|     uint32_t read_le24() | ||||
| @@ -156,7 +194,7 @@ public: | ||||
|         uint8_t b1 = _bytes[pos++]; | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         uint8_t b3 = _bytes[pos++]; | ||||
|         return (b3<<16) | (b2<<8) | b1; | ||||
|         return (b3 << 16) | (b2 << 8) | b1; | ||||
|     } | ||||
|  | ||||
|     uint32_t read_le32() | ||||
| @@ -165,7 +203,7 @@ public: | ||||
|         uint8_t b2 = _bytes[pos++]; | ||||
|         uint8_t b3 = _bytes[pos++]; | ||||
|         uint8_t b4 = _bytes[pos++]; | ||||
|         return (b4<<24) | (b3<<16) | (b2<<8) | b1; | ||||
|         return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; | ||||
|     } | ||||
|  | ||||
| private: | ||||
| @@ -175,9 +213,7 @@ private: | ||||
| class ByteWriter | ||||
| { | ||||
| public: | ||||
|     ByteWriter(Bytes& bytes): | ||||
|         _bytes(bytes) | ||||
|     {} | ||||
|     ByteWriter(Bytes& bytes): _bytes(bytes) {} | ||||
|  | ||||
|     ByteWriter(const Bytes&&) = delete; | ||||
|  | ||||
| @@ -205,7 +241,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_be16(uint16_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+1); | ||||
|         _bytes.adjustBounds(pos + 1); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value >> 8; | ||||
|         p[pos++] = value; | ||||
| @@ -214,7 +250,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_be24(uint32_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+2); | ||||
|         _bytes.adjustBounds(pos + 2); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value >> 16; | ||||
|         p[pos++] = value >> 8; | ||||
| @@ -224,7 +260,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_be32(uint32_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+3); | ||||
|         _bytes.adjustBounds(pos + 3); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value >> 24; | ||||
|         p[pos++] = value >> 16; | ||||
| @@ -235,7 +271,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_le16(uint16_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+1); | ||||
|         _bytes.adjustBounds(pos + 1); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value; | ||||
|         p[pos++] = value >> 8; | ||||
| @@ -244,7 +280,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_le24(uint32_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+2); | ||||
|         _bytes.adjustBounds(pos + 2); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value; | ||||
|         p[pos++] = value >> 8; | ||||
| @@ -254,7 +290,7 @@ public: | ||||
|  | ||||
|     ByteWriter& write_le32(uint32_t value) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos+3); | ||||
|         _bytes.adjustBounds(pos + 3); | ||||
|         uint8_t* p = _bytes.begin(); | ||||
|         p[pos++] = value; | ||||
|         p[pos++] = value >> 8; | ||||
| @@ -263,7 +299,7 @@ public: | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
|     ByteWriter& operator += (std::initializer_list<uint8_t> data) | ||||
|     ByteWriter& operator+=(std::initializer_list<uint8_t> data) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos + data.size() - 1); | ||||
|         std::copy(data.begin(), data.end(), _bytes.begin() + pos); | ||||
| @@ -271,7 +307,7 @@ public: | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
|     ByteWriter& operator += (const std::vector<uint8_t>& data) | ||||
|     ByteWriter& operator+=(const std::vector<uint8_t>& data) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos + data.size() - 1); | ||||
|         std::copy(data.begin(), data.end(), _bytes.begin() + pos); | ||||
| @@ -279,7 +315,7 @@ public: | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
|     ByteWriter& operator += (const Bytes data) | ||||
|     ByteWriter& operator+=(const Bytes data) | ||||
|     { | ||||
|         _bytes.adjustBounds(pos + data.size() - 1); | ||||
|         std::copy(data.begin(), data.end(), _bytes.begin() + pos); | ||||
| @@ -287,17 +323,17 @@ public: | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
|     ByteWriter& operator += (std::istream& stream); | ||||
|     ByteWriter& operator+=(std::istream& stream); | ||||
|  | ||||
| 	ByteWriter& append(const char* data) | ||||
| 	{ | ||||
| 		return *this += Bytes((const uint8_t*)data, strlen(data)); | ||||
| 	} | ||||
|     ByteWriter& append(const char* data) | ||||
|     { | ||||
|         return *this += Bytes((const uint8_t*)data, strlen(data)); | ||||
|     } | ||||
|  | ||||
| 	ByteWriter& append(const std::string& data) | ||||
| 	{ | ||||
| 		return *this += Bytes(data); | ||||
| 	} | ||||
|     ByteWriter& append(const std::string& data) | ||||
|     { | ||||
|         return *this += Bytes(data); | ||||
|     } | ||||
|  | ||||
|     ByteWriter& append(const Bytes data) | ||||
|     { | ||||
| @@ -316,14 +352,15 @@ private: | ||||
| class BitWriter | ||||
| { | ||||
| public: | ||||
|     BitWriter(ByteWriter& bw): | ||||
|         _bw(bw) | ||||
|     {} | ||||
|     BitWriter(ByteWriter& bw): _bw(bw) {} | ||||
|  | ||||
|     BitWriter(ByteWriter&&) = delete; | ||||
|  | ||||
|     void push(uint32_t bits, size_t size); | ||||
| 	void push(bool bit) { push(bit, 1); } | ||||
|     void push(bool bit) | ||||
|     { | ||||
|         push(bit, 1); | ||||
|     } | ||||
|     void flush(); | ||||
|  | ||||
| private: | ||||
| @@ -335,19 +372,17 @@ private: | ||||
| class BitReader | ||||
| { | ||||
| public: | ||||
| 	BitReader(ByteReader& br): | ||||
| 		_br(br) | ||||
| 	{} | ||||
|     BitReader(ByteReader& br): _br(br) {} | ||||
|  | ||||
| 	BitReader(ByteReader&&) = delete; | ||||
|     BitReader(ByteReader&&) = delete; | ||||
|  | ||||
| 	bool get(); | ||||
| 	bool eof(); | ||||
|     bool get(); | ||||
|     bool eof(); | ||||
|  | ||||
| private: | ||||
| 	uint8_t _fifo = 0; | ||||
| 	size_t _bitcount = 0; | ||||
| 	ByteReader& _br; | ||||
|     uint8_t _fifo = 0; | ||||
|     size_t _bitcount = 0; | ||||
|     ByteReader& _br; | ||||
| }; | ||||
|  | ||||
| static inline uint8_t reverse_bits(uint8_t b) | ||||
| @@ -358,16 +393,16 @@ static inline uint8_t reverse_bits(uint8_t b) | ||||
|     return b; | ||||
| } | ||||
|  | ||||
| extern uint8_t toByte( | ||||
|     std::vector<bool>::const_iterator start, | ||||
| extern uint8_t toByte(std::vector<bool>::const_iterator start, | ||||
|     std::vector<bool>::const_iterator end); | ||||
|  | ||||
| extern Bytes toBytes( | ||||
|     std::vector<bool>::const_iterator start, | ||||
| extern Bytes toBytes(std::vector<bool>::const_iterator start, | ||||
|     std::vector<bool>::const_iterator end); | ||||
|  | ||||
| inline Bytes toBytes(const std::vector<bool>& bits) | ||||
| { return toBytes(bits.begin(), bits.end()); } | ||||
| { | ||||
|     return toBytes(bits.begin(), bits.end()); | ||||
| } | ||||
|  | ||||
| extern std::vector<bool> reverseBits(const std::vector<bool>& bits); | ||||
|  | ||||
|   | ||||
| @@ -104,7 +104,7 @@ const OptionProto& Config::findOption(const std::string& optionName) | ||||
|     throw OptionNotFoundException("option name not found"); | ||||
| } | ||||
|  | ||||
| bool Config::isOptionValid(const OptionProto& option) | ||||
| void Config::checkOptionValid(const OptionProto& option) | ||||
| { | ||||
|     for (const auto& req : option.requires()) | ||||
|     { | ||||
| @@ -121,10 +121,40 @@ bool Config::isOptionValid(const OptionProto& option) | ||||
|         } | ||||
|  | ||||
|         if (!matched) | ||||
|             return false; | ||||
|     } | ||||
|         { | ||||
|             std::stringstream ss; | ||||
|             ss << '['; | ||||
|             bool first = true; | ||||
|             for (auto requiredValue : req.value()) | ||||
|             { | ||||
|                 if (!first) | ||||
|                     ss << ", "; | ||||
|                 ss << quote(requiredValue); | ||||
|                 first = false; | ||||
|             } | ||||
|             ss << ']'; | ||||
|  | ||||
|     return true; | ||||
|             throw InapplicableOptionException( | ||||
|                 fmt::format("option '{}' is inapplicable to this configuration " | ||||
|                             "because {}={} could not be met", | ||||
|                     option.name(), | ||||
|                     req.key(), | ||||
|                     ss.str())); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| bool Config::isOptionValid(const OptionProto& option) | ||||
| { | ||||
|     try | ||||
|     { | ||||
|         checkOptionValid(option); | ||||
|         return true; | ||||
|     } | ||||
|     catch (const InapplicableOptionException& e) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Config::applyOption(const OptionProto& option) | ||||
| @@ -137,10 +167,7 @@ void Config::applyOption(const OptionProto& option) | ||||
|         throw InvalidOptionException(fmt::format( | ||||
|             "option '{}' has an option group inside it, which isn't allowed", | ||||
|             option.name())); | ||||
|     if (!isOptionValid(option)) | ||||
|         throw InapplicableOptionException( | ||||
|             fmt::format("option '{}' is inapplicable to this configuration", | ||||
|                 option.name())); | ||||
|     checkOptionValid(option); | ||||
|  | ||||
|     log("OPTION: {}", | ||||
|         option.has_message() ? option.message() : option.comment()); | ||||
| @@ -148,7 +175,7 @@ void Config::applyOption(const OptionProto& option) | ||||
|     (*this)->MergeFrom(option.config()); | ||||
| } | ||||
|  | ||||
| void Config::setFluxSource(std::string filename) | ||||
| static void setFluxSourceImpl(std::string filename, FluxSourceProto* proto) | ||||
| { | ||||
|     static const std::vector<std::pair<std::regex, | ||||
|         std::function<void(const std::string&, FluxSourceProto*)>>> | ||||
| @@ -212,7 +239,7 @@ void Config::setFluxSource(std::string filename) | ||||
|         std::smatch match; | ||||
|         if (std::regex_match(filename, match, it.first)) | ||||
|         { | ||||
|             it.second(match[1], (*this)->mutable_flux_source()); | ||||
|             it.second(match[1], proto); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
| @@ -220,6 +247,11 @@ void Config::setFluxSource(std::string filename) | ||||
|     error("unrecognised flux filename '{}'", filename); | ||||
| } | ||||
|  | ||||
| void Config::setFluxSource(std::string filename) | ||||
| { | ||||
|     setFluxSourceImpl(filename, (*this)->mutable_flux_source()); | ||||
| } | ||||
|  | ||||
| static void setFluxSinkImpl(std::string filename, FluxSinkProto* proto) | ||||
| { | ||||
|     static const std::vector<std::pair<std::regex, | ||||
| @@ -287,6 +319,11 @@ void Config::setCopyFluxTo(std::string filename) | ||||
|         filename, (*this)->mutable_decoder()->mutable_copy_flux_to()); | ||||
| } | ||||
|  | ||||
| void Config::setVerificationFluxSource(std::string filename) | ||||
| { | ||||
|     setFluxSourceImpl(filename, &_verificationFluxSourceProto); | ||||
| } | ||||
|  | ||||
| void Config::setImageReader(std::string filename) | ||||
| { | ||||
|     static const std::map<std::string, std::function<void(ImageReaderProto*)>> | ||||
| @@ -378,6 +415,24 @@ std::shared_ptr<FluxSource>& Config::getFluxSource() | ||||
|     return _fluxSource; | ||||
| } | ||||
|  | ||||
| bool Config::hasVerificationFluxSource() const | ||||
| { | ||||
|     return _verificationFluxSourceProto.type() != FluxSourceProto::NOT_SET; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<FluxSource>& Config::getVerificationFluxSource() | ||||
| { | ||||
|     if (!_verificationFluxSource) | ||||
|     { | ||||
|         if (!hasVerificationFluxSource()) | ||||
|             error("no verification flux source configured"); | ||||
|  | ||||
|         _verificationFluxSource = | ||||
|             std::shared_ptr(FluxSource::create(_verificationFluxSourceProto)); | ||||
|     } | ||||
|     return _verificationFluxSource; | ||||
| } | ||||
|  | ||||
| bool Config::hasImageReader() const | ||||
| { | ||||
|     return (*this)->image_reader().type() != ImageReaderProto::NOT_SET; | ||||
|   | ||||
							
								
								
									
										73
									
								
								lib/config.h
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								lib/config.h
									
									
									
									
									
								
							| @@ -2,6 +2,8 @@ | ||||
|  | ||||
| #ifdef __cplusplus | ||||
|  | ||||
| #include "lib/fluxsource/fluxsource.pb.h" | ||||
|  | ||||
| class ConfigProto; | ||||
| class OptionProto; | ||||
| class FluxSource; | ||||
| @@ -16,69 +18,82 @@ public: | ||||
| class OptionNotFoundException : public OptionException | ||||
| { | ||||
| public: | ||||
|     OptionNotFoundException(const std::string& message): OptionException(message) {} | ||||
|     OptionNotFoundException(const std::string& message): | ||||
|         OptionException(message) | ||||
|     { | ||||
|     } | ||||
| }; | ||||
|  | ||||
| class InvalidOptionException : public OptionException | ||||
| { | ||||
| public: | ||||
|     InvalidOptionException(const std::string& message): OptionException(message) {} | ||||
|     InvalidOptionException(const std::string& message): OptionException(message) | ||||
|     { | ||||
|     } | ||||
| }; | ||||
|  | ||||
| class InapplicableOptionException : public OptionException | ||||
| { | ||||
| public: | ||||
|     InapplicableOptionException(const std::string& message): OptionException(message) {} | ||||
|     InapplicableOptionException(const std::string& message): | ||||
|         OptionException(message) | ||||
|     { | ||||
|     } | ||||
| }; | ||||
|  | ||||
| class Config | ||||
| { | ||||
| public: | ||||
| 	ConfigProto* operator -> () const; | ||||
| 	operator ConfigProto* () const; | ||||
| 	operator ConfigProto& () const; | ||||
|     ConfigProto* operator->() const; | ||||
|     operator ConfigProto*() const; | ||||
|     operator ConfigProto&() const; | ||||
|  | ||||
| 	/* Set and get individual config keys. */ | ||||
|     /* Set and get individual config keys. */ | ||||
|  | ||||
| 	void set(std::string key, std::string value); | ||||
| 	std::string get(std::string key); | ||||
|     void set(std::string key, std::string value); | ||||
|     std::string get(std::string key); | ||||
|  | ||||
| 	/* Reset the entire configuration. */ | ||||
|     /* Reset the entire configuration. */ | ||||
|  | ||||
| 	void clear(); | ||||
|     void clear(); | ||||
|  | ||||
| 	/* Merge in one config file. */ | ||||
|     /* Merge in one config file. */ | ||||
|  | ||||
| 	void readConfigFile(std::string filename); | ||||
|     void readConfigFile(std::string filename); | ||||
|  | ||||
|     /* Option management: look up an option by name, determine whether an option | ||||
|      * is valid, and apply an option. */ | ||||
|  | ||||
| 	const OptionProto& findOption(const std::string& option); | ||||
| 	bool isOptionValid(const OptionProto& option); | ||||
|     const OptionProto& findOption(const std::string& option); | ||||
|     void checkOptionValid(const OptionProto& option); | ||||
|     bool isOptionValid(const OptionProto& option); | ||||
|     void applyOption(const OptionProto& option); | ||||
|  | ||||
| 	/* Adjust overall inputs and outputs. */ | ||||
|     /* Adjust overall inputs and outputs. */ | ||||
|  | ||||
| 	void setFluxSource(std::string value); | ||||
| 	void setFluxSink(std::string value); | ||||
| 	void setCopyFluxTo(std::string value); | ||||
| 	void setImageReader(std::string value); | ||||
| 	void setImageWriter(std::string value); | ||||
|     void setFluxSource(std::string value); | ||||
|     void setFluxSink(std::string value); | ||||
|     void setVerificationFluxSource(std::string value); | ||||
|     void setCopyFluxTo(std::string value); | ||||
|     void setImageReader(std::string value); | ||||
|     void setImageWriter(std::string value); | ||||
|  | ||||
| 	/* Fetch the sources, opening them if necessary. */ | ||||
|     /* Fetch the sources, opening them if necessary. */ | ||||
|  | ||||
| 	bool hasFluxSource() const; | ||||
| 	std::shared_ptr<FluxSource>& getFluxSource(); | ||||
| 	bool hasImageReader() const; | ||||
| 	std::shared_ptr<ImageReader>& getImageReader(); | ||||
|     bool hasFluxSource() const; | ||||
|     std::shared_ptr<FluxSource>& getFluxSource(); | ||||
|     bool hasImageReader() const; | ||||
|     std::shared_ptr<ImageReader>& getImageReader(); | ||||
|     bool hasVerificationFluxSource() const; | ||||
|     std::shared_ptr<FluxSource>& getVerificationFluxSource(); | ||||
|  | ||||
| private: | ||||
| 	std::shared_ptr<FluxSource> _fluxSource; | ||||
| 	std::shared_ptr<ImageReader> _imageReader; | ||||
|     std::shared_ptr<FluxSource> _fluxSource; | ||||
|     std::shared_ptr<ImageReader> _imageReader; | ||||
|     std::shared_ptr<FluxSource> _verificationFluxSource; | ||||
|     FluxSourceProto _verificationFluxSourceProto; | ||||
| }; | ||||
|  | ||||
| extern Config& globalConfig(); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
							
								
								
									
										15
									
								
								lib/crc.h
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								lib/crc.h
									
									
									
									
									
								
							| @@ -1,10 +1,10 @@ | ||||
| #ifndef CRC_H | ||||
| #define CRC_H | ||||
|  | ||||
| #define CCITT_POLY      0x1021 | ||||
| #define MODBUS_POLY     0x8005 | ||||
| #define CCITT_POLY 0x1021 | ||||
| #define MODBUS_POLY 0x8005 | ||||
| #define MODBUS_POLY_REF 0xa001 | ||||
| #define BROTHER_POLY    0x000201 | ||||
| #define BROTHER_POLY 0x000201 | ||||
|  | ||||
| struct crcspec | ||||
| { | ||||
| @@ -25,10 +25,13 @@ extern uint16_t crc16ref(uint16_t poly, uint16_t init, const Bytes& bytes); | ||||
| extern uint32_t crcbrother(const Bytes& bytes); | ||||
|  | ||||
| static inline uint16_t crc16(uint16_t poly, const Bytes& bytes) | ||||
| { return crc16(poly, 0xffff, bytes); } | ||||
| { | ||||
|     return crc16(poly, 0xffff, bytes); | ||||
| } | ||||
|  | ||||
| static inline uint16_t crc16ref(uint16_t poly, const Bytes& bytes) | ||||
| { return crc16ref(poly, 0xffff, bytes); } | ||||
| { | ||||
|     return crc16ref(poly, 0xffff, bytes); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -6,15 +6,12 @@ | ||||
| class CsvReader | ||||
| { | ||||
| public: | ||||
| 	CsvReader(std::istream& istream): | ||||
| 		_istream(istream) | ||||
| 	{} | ||||
|     CsvReader(std::istream& istream): _istream(istream) {} | ||||
|  | ||||
| 	std::vector<std::string> readLine(); | ||||
|     std::vector<std::string> readLine(); | ||||
|  | ||||
| private: | ||||
| 	std::istream& _istream; | ||||
|     std::istream& _istream; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -71,10 +71,10 @@ public: | ||||
|         return _fmr->tell(); | ||||
|     } | ||||
|  | ||||
| 	void rewind() | ||||
| 	{ | ||||
| 		_fmr->rewind(); | ||||
| 	} | ||||
|     void rewind() | ||||
|     { | ||||
|         _fmr->rewind(); | ||||
|     } | ||||
|  | ||||
|     void seek(const Fluxmap::Position& pos) | ||||
|     { | ||||
|   | ||||
| @@ -6,36 +6,36 @@ class FluxmapReader; | ||||
| class FluxDecoder | ||||
| { | ||||
| public: | ||||
| 	FluxDecoder(FluxmapReader* fmr, nanoseconds_t bitcell, | ||||
| 		const DecoderProto& config); | ||||
|     FluxDecoder( | ||||
|         FluxmapReader* fmr, nanoseconds_t bitcell, const DecoderProto& config); | ||||
|  | ||||
| 	bool readBit(); | ||||
|     bool readBit(); | ||||
|     std::vector<bool> readBits(unsigned count); | ||||
|     std::vector<bool> readBits(const Fluxmap::Position& until); | ||||
|  | ||||
|     std::vector<bool> readBits() | ||||
| 	{ | ||||
| 		return readBits(UINT_MAX); | ||||
| 	} | ||||
| private: | ||||
| 	nanoseconds_t nextFlux(); | ||||
|     { | ||||
|         return readBits(UINT_MAX); | ||||
|     } | ||||
|  | ||||
| private: | ||||
| 	FluxmapReader* _fmr; | ||||
| 	double _pll_phase; | ||||
| 	double _pll_adjust; | ||||
| 	double _flux_scale; | ||||
| 	nanoseconds_t _clock = 0; | ||||
| 	nanoseconds_t _clock_centre; | ||||
| 	nanoseconds_t _clock_min; | ||||
| 	nanoseconds_t _clock_max; | ||||
| 	nanoseconds_t _flux = 0; | ||||
| 	unsigned _clocked_zeroes = 0; | ||||
| 	unsigned _goodbits = 0; | ||||
| 	bool _index = false; | ||||
| 	bool _sync_lost = false; | ||||
| 	int _leading_zeroes; | ||||
|     nanoseconds_t nextFlux(); | ||||
|  | ||||
| private: | ||||
|     FluxmapReader* _fmr; | ||||
|     double _pll_phase; | ||||
|     double _pll_adjust; | ||||
|     double _flux_scale; | ||||
|     nanoseconds_t _clock = 0; | ||||
|     nanoseconds_t _clock_centre; | ||||
|     nanoseconds_t _clock_min; | ||||
|     nanoseconds_t _clock_max; | ||||
|     nanoseconds_t _flux = 0; | ||||
|     unsigned _clocked_zeroes = 0; | ||||
|     unsigned _goodbits = 0; | ||||
|     bool _index = false; | ||||
|     bool _sync_lost = false; | ||||
|     int _leading_zeroes; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -34,7 +34,9 @@ public: | ||||
|     bool matches(const unsigned* intervals, FluxMatch& match) const override; | ||||
|  | ||||
|     unsigned intervals() const override | ||||
|     { return _intervals.size(); } | ||||
|     { | ||||
|         return _intervals.size(); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::vector<unsigned> _intervals; | ||||
| @@ -56,7 +58,9 @@ public: | ||||
|     bool matches(const unsigned* intervals, FluxMatch& match) const override; | ||||
|  | ||||
|     unsigned intervals() const override | ||||
|     { return _intervals; } | ||||
|     { | ||||
|         return _intervals; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     unsigned _intervals; | ||||
| @@ -77,10 +81,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     bool eof() const | ||||
|     { return _pos.bytes == _size; } | ||||
|     { | ||||
|         return _pos.bytes == _size; | ||||
|     } | ||||
|  | ||||
|     Fluxmap::Position tell() const | ||||
|     { return _pos; } | ||||
|     { | ||||
|         return _pos; | ||||
|     } | ||||
|  | ||||
|     /* Important! You can only reliably seek to 1 bits. */ | ||||
|     void seek(const Fluxmap::Position& pos) | ||||
| @@ -94,24 +102,25 @@ public: | ||||
|     } | ||||
|  | ||||
|     void getNextEvent(int& event, unsigned& ticks); | ||||
| 	void skipToEvent(int event); | ||||
|     void skipToEvent(int event); | ||||
|     bool findEvent(int event, unsigned& ticks); | ||||
|     unsigned readInterval(nanoseconds_t clock); /* with debounce support */ | ||||
|  | ||||
|     /* Important! You can only reliably seek to 1 bits. */ | ||||
|     void seek(nanoseconds_t ns); | ||||
| 	void seekToByte(unsigned byte); | ||||
|     void seekToByte(unsigned byte); | ||||
|  | ||||
|     void seekToIndexMark(); | ||||
|     nanoseconds_t seekToPattern(const FluxMatcher& pattern); | ||||
|     nanoseconds_t seekToPattern(const FluxMatcher& pattern, const FluxMatcher*& matching); | ||||
|     nanoseconds_t seekToPattern( | ||||
|         const FluxMatcher& pattern, const FluxMatcher*& matching); | ||||
|  | ||||
| private: | ||||
|     const Fluxmap& _fluxmap; | ||||
|     const uint8_t* _bytes; | ||||
|     const size_t _size; | ||||
|     Fluxmap::Position _pos; | ||||
| 	const DecoderProto& _config; | ||||
|     const DecoderProto& _config; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -8,24 +8,35 @@ public: | ||||
|         std::unique_ptr<std::vector<size_t>> indices): | ||||
|         _bits(std::move(bits)), | ||||
|         _indices(std::move(indices)) | ||||
|     {} | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     typedef std::vector<bool>::const_iterator const_iterator; | ||||
|  | ||||
|     const_iterator begin() const | ||||
|     { return _bits->begin(); } | ||||
|     { | ||||
|         return _bits->begin(); | ||||
|     } | ||||
|  | ||||
|     const_iterator end() const | ||||
|     { return _bits->end(); } | ||||
|     { | ||||
|         return _bits->end(); | ||||
|     } | ||||
|  | ||||
|     size_t size() const | ||||
|     { return _bits->size(); } | ||||
|     { | ||||
|         return _bits->size(); | ||||
|     } | ||||
|  | ||||
|     const bool operator[] (size_t pos) const | ||||
|     { return _bits->at(pos); } | ||||
|     const bool operator[](size_t pos) const | ||||
|     { | ||||
|         return _bits->at(pos); | ||||
|     } | ||||
|  | ||||
|     const std::vector<size_t> indices() const | ||||
|     { return *_indices; } | ||||
|     { | ||||
|         return *_indices; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::unique_ptr<std::vector<bool>> _bits; | ||||
|   | ||||
| @@ -18,12 +18,15 @@ public: | ||||
|  | ||||
| public: | ||||
|     virtual std::shared_ptr<const Sector> getSector( | ||||
|         std::shared_ptr<const TrackInfo>&, const Image& image, unsigned sectorId); | ||||
|         std::shared_ptr<const TrackInfo>&, | ||||
|         const Image& image, | ||||
|         unsigned sectorId); | ||||
|  | ||||
|     virtual std::vector<std::shared_ptr<const Sector>> collectSectors( | ||||
|         std::shared_ptr<const TrackInfo>&, const Image& image); | ||||
|  | ||||
|     virtual std::unique_ptr<Fluxmap> encode(std::shared_ptr<const TrackInfo>& trackInfo, | ||||
|     virtual std::unique_ptr<Fluxmap> encode( | ||||
|         std::shared_ptr<const TrackInfo>& trackInfo, | ||||
|         const std::vector<std::shared_ptr<const Sector>>& sectors, | ||||
|         const Image& image) = 0; | ||||
|  | ||||
|   | ||||
| @@ -7,4 +7,3 @@ extern FluxFileProto loadFl2File(const std::string filename); | ||||
| extern void saveFl2File(const std::string filename, FluxFileProto& proto); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
							
								
								
									
										23
									
								
								lib/flags.cc
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								lib/flags.cc
									
									
									
									
									
								
							| @@ -1,8 +1,10 @@ | ||||
| #include "globals.h" | ||||
| #include "flags.h" | ||||
| #include "proto.h" | ||||
| #include "utils.h" | ||||
| #include "logger.h" | ||||
| #include "lib/globals.h" | ||||
| #include "lib/flags.h" | ||||
| #include "lib/proto.h" | ||||
| #include "lib/utils.h" | ||||
| #include "lib/logger.h" | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/imagereader/imagereader.h" | ||||
| #include <google/protobuf/text_format.h> | ||||
| #include <regex> | ||||
| #include <fstream> | ||||
| @@ -192,6 +194,17 @@ std::vector<std::string> FlagGroup::parseFlagsWithFilenames(int argc, | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /* Add any config contributed by the flux and image readers, plus overrides. | ||||
|      */ | ||||
|  | ||||
|     if (globalConfig().hasFluxSource()) | ||||
|         globalConfig()->MergeFrom( | ||||
|             globalConfig().getFluxSource()->getExtraConfig()); | ||||
|     if (globalConfig().hasImageReader()) | ||||
|         globalConfig()->MergeFrom( | ||||
|             globalConfig().getImageReader()->getExtraConfig()); | ||||
|     applyOverrides(); | ||||
|  | ||||
|     /* Then apply any default options in groups, likewise applying the | ||||
|      * overrides. */ | ||||
|  | ||||
|   | ||||
| @@ -18,28 +18,43 @@ class FluxSink | ||||
| public: | ||||
|     virtual ~FluxSink() {} | ||||
|  | ||||
|     static std::unique_ptr<FluxSink> createHardwareFluxSink(const HardwareFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createAuFluxSink(const AuFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createA2RFluxSink(const A2RFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createVcdFluxSink(const VcdFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createScpFluxSink(const ScpFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createFl2FluxSink(const Fl2FluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createHardwareFluxSink( | ||||
|         const HardwareFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createAuFluxSink( | ||||
|         const AuFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createA2RFluxSink( | ||||
|         const A2RFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createVcdFluxSink( | ||||
|         const VcdFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createScpFluxSink( | ||||
|         const ScpFluxSinkProto& config); | ||||
|     static std::unique_ptr<FluxSink> createFl2FluxSink( | ||||
|         const Fl2FluxSinkProto& config); | ||||
|  | ||||
|     static std::unique_ptr<FluxSink> createFl2FluxSink(const std::string& filename); | ||||
|     static std::unique_ptr<FluxSink> createFl2FluxSink( | ||||
|         const std::string& filename); | ||||
|  | ||||
|     static std::unique_ptr<FluxSink> create(const FluxSinkProto& config); | ||||
|  | ||||
| public: | ||||
|     /* Writes a fluxmap to a track and side. */ | ||||
|  | ||||
|     virtual void writeFlux(int track, int side, const Fluxmap& fluxmap) = 0; | ||||
|  | ||||
| 	virtual operator std::string () const = 0; | ||||
|     /* Returns whether this is writing to real hardware or not. */ | ||||
|  | ||||
|     virtual bool isHardware() const | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     virtual operator std::string() const = 0; | ||||
| }; | ||||
|  | ||||
| inline std::ostream& operator << (std::ostream& stream, FluxSink& flushSink) | ||||
| inline std::ostream& operator<<(std::ostream& stream, FluxSink& flushSink) | ||||
| { | ||||
| 	stream << (std::string)flushSink; | ||||
| 	return stream; | ||||
|     stream << (std::string)flushSink; | ||||
|     return stream; | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -39,7 +39,12 @@ public: | ||||
|         return usbWrite(side, fluxmap.rawBytes(), _hardSectorThreshold); | ||||
|     } | ||||
|  | ||||
|     operator std::string() const | ||||
|     bool isHardware() const override | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     operator std::string() const override | ||||
|     { | ||||
|         return fmt::format("drive {}", globalConfig()->drive().drive()); | ||||
|     } | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| #ifndef STREAM_H | ||||
| #define STREAM_H | ||||
|  | ||||
| extern std::unique_ptr<Fluxmap> readStream(const std::string& dir, unsigned track, unsigned side); | ||||
| extern std::unique_ptr<Fluxmap> readStream( | ||||
|     const std::string& dir, unsigned track, unsigned side); | ||||
| extern std::unique_ptr<Fluxmap> readStream(const std::string& path); | ||||
| extern std::unique_ptr<Fluxmap> readStream(const Bytes& bytes); | ||||
|  | ||||
|   | ||||
| @@ -24,7 +24,9 @@ | ||||
|  | ||||
| template <class T> | ||||
| static inline std::vector<T> vector_of(T item) | ||||
| { return std::vector<T> { item }; } | ||||
| { | ||||
|     return std::vector<T>{item}; | ||||
| } | ||||
|  | ||||
| typedef double nanoseconds_t; | ||||
| class Bytes; | ||||
| @@ -35,18 +37,17 @@ extern void hexdumpForSrp16(std::ostream& stream, const Bytes& bytes); | ||||
|  | ||||
| struct ErrorException | ||||
| { | ||||
| 	ErrorException(const std::string& message): message(message){} | ||||
|     ErrorException(const std::string& message): message(message) {} | ||||
|  | ||||
| 	const std::string message; | ||||
|     const std::string message; | ||||
|  | ||||
| 	void print() const; | ||||
|     void print() const; | ||||
| }; | ||||
|  | ||||
| template <typename... Args> | ||||
| [[ noreturn ]] | ||||
| inline void error(fmt::string_view fstr, const Args&... args) | ||||
| [[noreturn]] inline void error(fmt::string_view fstr, const Args&... args) | ||||
| { | ||||
| 	throw ErrorException { fmt::format(fstr, args...) }; | ||||
|     throw ErrorException{fmt::format(fstr, args...)}; | ||||
| } | ||||
|  | ||||
| extern void warning(const std::string msg); | ||||
| @@ -54,11 +55,16 @@ extern void warning(const std::string msg); | ||||
| template <typename... Args> | ||||
| inline void warning(fmt::string_view fstr, const Args&... args) | ||||
| { | ||||
| 	warning(fmt::format(fstr, args...)); | ||||
|     warning(fmt::format(fstr, args...)); | ||||
| } | ||||
|  | ||||
| template <class... Ts> struct overloaded : Ts...  { using Ts::operator()...; }; | ||||
| template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>; | ||||
| template <class... Ts> | ||||
| struct overloaded : Ts... | ||||
| { | ||||
|     using Ts::operator()...; | ||||
| }; | ||||
| template <class... Ts> | ||||
| overloaded(Ts...) -> overloaded<Ts...>; | ||||
|  | ||||
| #include "lib/config.h" | ||||
|  | ||||
|   | ||||
| @@ -44,7 +44,10 @@ public: | ||||
| public: | ||||
|     /* Returns any extra config the image might want to contribute. */ | ||||
|  | ||||
|     const ConfigProto& getContributedConfig() const; | ||||
|     const ConfigProto& getExtraConfig() const | ||||
|     { | ||||
|         return _extraConfig; | ||||
|     } | ||||
|  | ||||
|     /* Directly reads the image. */ | ||||
|  | ||||
|   | ||||
| @@ -7,8 +7,8 @@ class Bytes; | ||||
|  * http://www.seasip.info/Unix/LibDsk/ldbs.html | ||||
|  */ | ||||
|  | ||||
| #define LDBS_FILE_MAGIC 0x4C425301 /* "LBS\01" */ | ||||
| #define LDBS_FILE_TYPE 0x44534B02 /* "DSK\02" */ | ||||
| #define LDBS_FILE_MAGIC 0x4C425301  /* "LBS\01" */ | ||||
| #define LDBS_FILE_TYPE 0x44534B02   /* "DSK\02" */ | ||||
| #define LDBS_BLOCK_MAGIC 0x4C444201 /* "LDB\01" */ | ||||
| #define LDBS_TRACK_BLOCK 0x44495201 /* "DIR\01" */ | ||||
|  | ||||
| @@ -19,7 +19,9 @@ public: | ||||
|  | ||||
| public: | ||||
|     const Bytes& get(uint32_t address) const | ||||
|     { return blocks.at(address).data; } | ||||
|     { | ||||
|         return blocks.at(address).data; | ||||
|     } | ||||
|  | ||||
|     uint32_t put(const Bytes& data, uint32_t type); | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,10 @@ | ||||
| class ProtoPathNotFoundException : public ErrorException | ||||
| { | ||||
| public: | ||||
|     ProtoPathNotFoundException(const std::string& message): ErrorException(message) {} | ||||
|     ProtoPathNotFoundException(const std::string& message): | ||||
|         ErrorException(message) | ||||
|     { | ||||
|     } | ||||
| }; | ||||
|  | ||||
| extern void setRange(RangeProto* range, const std::string& data); | ||||
| @@ -26,8 +29,8 @@ extern std::string getProtoFieldValue(ProtoField& protoField); | ||||
| extern void setProtoByString(google::protobuf::Message* message, | ||||
|     const std::string& path, | ||||
|     const std::string& value); | ||||
| extern std::string getProtoByString(google::protobuf::Message* message, | ||||
| 	const std::string& path); | ||||
| extern std::string getProtoByString( | ||||
|     google::protobuf::Message* message, const std::string& path); | ||||
|  | ||||
| extern std::set<unsigned> iterate(const RangeProto& range); | ||||
| extern std::set<unsigned> iterate(unsigned start, unsigned count); | ||||
|   | ||||
							
								
								
									
										16
									
								
								lib/scp.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								lib/scp.h
									
									
									
									
									
								
							| @@ -19,18 +19,18 @@ struct ScpHeader | ||||
|  | ||||
| enum | ||||
| { | ||||
|     SCP_FLAG_INDEXED    = (1<<0), | ||||
|     SCP_FLAG_96TPI      = (1<<1), | ||||
|     SCP_FLAG_360RPM     = (1<<2), | ||||
|     SCP_FLAG_NORMALIZED = (1<<3), | ||||
|     SCP_FLAG_READWRITE  = (1<<4), | ||||
|     SCP_FLAG_FOOTER     = (1<<5) | ||||
|     SCP_FLAG_INDEXED = (1 << 0), | ||||
|     SCP_FLAG_96TPI = (1 << 1), | ||||
|     SCP_FLAG_360RPM = (1 << 2), | ||||
|     SCP_FLAG_NORMALIZED = (1 << 3), | ||||
|     SCP_FLAG_READWRITE = (1 << 4), | ||||
|     SCP_FLAG_FOOTER = (1 << 5) | ||||
| }; | ||||
|  | ||||
| struct ScpTrackHeader | ||||
| { | ||||
|     char track_id[3];      // 'TRK' | ||||
|     uint8_t strack;        // SCP track number | ||||
|     char track_id[3]; // 'TRK' | ||||
|     uint8_t strack;   // SCP track number | ||||
| }; | ||||
|  | ||||
| struct ScpTrackRevolution | ||||
|   | ||||
							
								
								
									
										14
									
								
								lib/sector.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								lib/sector.h
									
									
									
									
									
								
							| @@ -9,14 +9,13 @@ class TrackInfo; | ||||
|  | ||||
| struct LogicalLocation | ||||
| { | ||||
| 	unsigned logicalTrack; | ||||
| 	unsigned logicalSide; | ||||
| 	unsigned logicalSector; | ||||
|     unsigned logicalTrack; | ||||
|     unsigned logicalSide; | ||||
|     unsigned logicalSector; | ||||
|  | ||||
|     std::tuple<int, int, int> key() const | ||||
|     { | ||||
|         return std::make_tuple( | ||||
|             logicalTrack, logicalSide, logicalSector); | ||||
|         return std::make_tuple(logicalTrack, logicalSide, logicalSector); | ||||
|     } | ||||
|  | ||||
|     bool operator==(const LogicalLocation& rhs) const | ||||
| @@ -65,7 +64,7 @@ struct Sector : public LogicalLocation | ||||
|  | ||||
|     Sector() {} | ||||
|  | ||||
|     Sector(std::shared_ptr<const TrackInfo>& layout, unsigned sectorId=0); | ||||
|     Sector(std::shared_ptr<const TrackInfo>& layout, unsigned sectorId = 0); | ||||
|  | ||||
|     Sector(const LogicalLocation& location); | ||||
|  | ||||
| @@ -91,8 +90,7 @@ struct Sector : public LogicalLocation | ||||
|     } | ||||
| }; | ||||
|  | ||||
| extern bool sectorPointerSortPredicate( | ||||
| 	const std::shared_ptr<const Sector>& lhs, | ||||
| extern bool sectorPointerSortPredicate(const std::shared_ptr<const Sector>& lhs, | ||||
|     const std::shared_ptr<const Sector>& rhs); | ||||
| extern bool sectorPointerEqualsPredicate( | ||||
|     const std::shared_ptr<const Sector>& lhs, | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
| #define GREASEWEAZLE_VID 0x1209 | ||||
| #define GREASEWEAZLE_PID 0x4d69 | ||||
|  | ||||
| #define GREASEWEAZLE_ID ((GREASEWEAZLE_VID<<16) | GREASEWEAZLE_PID) | ||||
| #define GREASEWEAZLE_ID ((GREASEWEAZLE_VID << 16) | GREASEWEAZLE_PID) | ||||
|  | ||||
| #define EP_OUT 0x02 | ||||
| #define EP_IN 0x83 | ||||
| @@ -13,10 +13,12 @@ extern Bytes fluxEngineToGreaseWeazle(const Bytes& fldata, nanoseconds_t clock); | ||||
| extern Bytes greaseWeazleToFluxEngine(const Bytes& gwdata, nanoseconds_t clock); | ||||
| extern Bytes stripPartialRotation(const Bytes& fldata); | ||||
|  | ||||
| /* Copied from https://github.com/keirf/Greaseweazle/blob/master/inc/cdc_acm_protocol.h. | ||||
| /* Copied from | ||||
|  * https://github.com/keirf/Greaseweazle/blob/master/inc/cdc_acm_protocol.h. | ||||
|  * | ||||
|  * WANING: these headers were originally defined with 'packed', which is a gccism so it's | ||||
|  * been dummied out. Don't use them expecting wire protocol structures. */ | ||||
|  * WANING: these headers were originally defined with 'packed', which is a | ||||
|  * gccism so it's been dummied out. Don't use them expecting wire protocol | ||||
|  * structures. */ | ||||
|  | ||||
| #define packed /* */ | ||||
|  | ||||
| @@ -25,90 +27,87 @@ extern Bytes stripPartialRotation(const Bytes& fldata); | ||||
|  */ | ||||
|  | ||||
| /* CMD_GET_INFO, length=3, idx. Returns 32 bytes after ACK. */ | ||||
| #define CMD_GET_INFO        0 | ||||
| /* [BOOTLOADER] CMD_UPDATE, length=6, <update_len>.  | ||||
| #define CMD_GET_INFO 0 | ||||
| /* [BOOTLOADER] CMD_UPDATE, length=6, <update_len>. | ||||
|  * Host follows with <update_len> bytes. | ||||
|  * Bootloader finally returns a status byte, 0 on success. */ | ||||
| /* [MAIN FIRMWARE] CMD_UPDATE, length=10, <update_len>, 0xdeafbee3. | ||||
|  * Host follows with <update_len> bytes. | ||||
|  * Main firmware finally returns a status byte, 0 on success. */ | ||||
| #define CMD_UPDATE          1 | ||||
| #define CMD_UPDATE 1 | ||||
| /* CMD_SEEK, length=3, cyl#. Seek to cyl# on selected drive. */ | ||||
| #define CMD_SEEK            2 | ||||
| #define CMD_SEEK 2 | ||||
| /* CMD_HEAD, length=3, head# (0=bottom) */ | ||||
| #define CMD_HEAD            3 | ||||
| #define CMD_HEAD 3 | ||||
| /* CMD_SET_PARAMS, length=3+nr, idx, <nr bytes> */ | ||||
| #define CMD_SET_PARAMS      4 | ||||
| #define CMD_SET_PARAMS 4 | ||||
| /* CMD_GET_PARAMS, length=4, idx, nr_bytes. Returns nr_bytes after ACK. */ | ||||
| #define CMD_GET_PARAMS      5 | ||||
| #define CMD_GET_PARAMS 5 | ||||
| /* CMD_MOTOR, length=4, drive#, on/off. Turn on/off a drive motor. */ | ||||
| #define CMD_MOTOR           6 | ||||
| #define CMD_MOTOR 6 | ||||
| /* CMD_READ_FLUX, length=2-8. Argument is gw_read_flux. | ||||
|  * Returns flux readings until EOStream. */ | ||||
| #define CMD_READ_FLUX       7 | ||||
| #define CMD_READ_FLUX 7 | ||||
| /* CMD_WRITE_FLUX, length=2-4. Argument is gw_write_flux. | ||||
|  * Host follows with flux readings until EOStream. */ | ||||
| #define CMD_WRITE_FLUX      8 | ||||
| #define CMD_WRITE_FLUX 8 | ||||
| /* CMD_GET_FLUX_STATUS, length=2. Last read/write status returned in ACK. */ | ||||
| #define CMD_GET_FLUX_STATUS 9 | ||||
| /* CMD_SWITCH_FW_MODE, length=3, <mode> */ | ||||
| #define CMD_SWITCH_FW_MODE 11 | ||||
| /* CMD_SELECT, length=3, drive#. Select drive# as current unit. */ | ||||
| #define CMD_SELECT         12 | ||||
| #define CMD_SELECT 12 | ||||
| /* CMD_DESELECT, length=2. Deselect current unit (if any). */ | ||||
| #define CMD_DESELECT       13 | ||||
| #define CMD_DESELECT 13 | ||||
| /* CMD_SET_BUS_TYPE, length=3, bus_type. Set the bus type. */ | ||||
| #define CMD_SET_BUS_TYPE   14 | ||||
| #define CMD_SET_BUS_TYPE 14 | ||||
| /* CMD_SET_PIN, length=4, pin#, level. */ | ||||
| #define CMD_SET_PIN        15 | ||||
| #define CMD_SET_PIN 15 | ||||
| /* CMD_RESET, length=2. Reset all state to initial (power on) values. */ | ||||
| #define CMD_RESET          16 | ||||
| #define CMD_RESET 16 | ||||
| /* CMD_ERASE_FLUX, length=6. Argument is gw_erase_flux. */ | ||||
| #define CMD_ERASE_FLUX     17 | ||||
| #define CMD_ERASE_FLUX 17 | ||||
| /* CMD_SOURCE_BYTES, length=6. Argument is gw_sink_source_bytes. */ | ||||
| #define CMD_SOURCE_BYTES   18 | ||||
| #define CMD_SOURCE_BYTES 18 | ||||
| /* CMD_SINK_BYTES, length=6. Argument is gw_sink_source_bytes. */ | ||||
| #define CMD_SINK_BYTES     19 | ||||
| #define CMD_MAX            19 | ||||
|  | ||||
| #define CMD_SINK_BYTES 19 | ||||
| #define CMD_MAX 19 | ||||
|  | ||||
| /* | ||||
|  * CMD_SET_BUS CODES | ||||
|  */ | ||||
| #define BUS_NONE              0 | ||||
| #define BUS_IBMPC             1 | ||||
| #define BUS_SHUGART           2 | ||||
| #define BUS_APPLE2            3 | ||||
|  | ||||
| #define BUS_NONE 0 | ||||
| #define BUS_IBMPC 1 | ||||
| #define BUS_SHUGART 2 | ||||
| #define BUS_APPLE2 3 | ||||
|  | ||||
| /* | ||||
|  * ACK RETURN CODES | ||||
|  */ | ||||
| #define ACK_OKAY            0 | ||||
| #define ACK_BAD_COMMAND     1 | ||||
| #define ACK_NO_INDEX        2 | ||||
| #define ACK_NO_TRK0         3 | ||||
| #define ACK_FLUX_OVERFLOW   4 | ||||
| #define ACK_FLUX_UNDERFLOW  5 | ||||
| #define ACK_WRPROT          6 | ||||
| #define ACK_NO_UNIT         7 | ||||
| #define ACK_NO_BUS          8 | ||||
| #define ACK_BAD_UNIT        9 | ||||
| #define ACK_BAD_PIN        10 | ||||
| #define ACK_BAD_CYLINDER   11 | ||||
|  | ||||
| #define ACK_OKAY 0 | ||||
| #define ACK_BAD_COMMAND 1 | ||||
| #define ACK_NO_INDEX 2 | ||||
| #define ACK_NO_TRK0 3 | ||||
| #define ACK_FLUX_OVERFLOW 4 | ||||
| #define ACK_FLUX_UNDERFLOW 5 | ||||
| #define ACK_WRPROT 6 | ||||
| #define ACK_NO_UNIT 7 | ||||
| #define ACK_NO_BUS 8 | ||||
| #define ACK_BAD_UNIT 9 | ||||
| #define ACK_BAD_PIN 10 | ||||
| #define ACK_BAD_CYLINDER 11 | ||||
|  | ||||
| /* | ||||
|  * CONTROL-CHANNEL COMMAND SET: | ||||
|  * We abuse SET_LINE_CODING requests over endpoint 0, stashing a command | ||||
|  * in the baud-rate field. | ||||
|  */ | ||||
| #define BAUD_NORMAL        9600 | ||||
| #define BAUD_CLEAR_COMMS  10000 | ||||
| #define BAUD_NORMAL 9600 | ||||
| #define BAUD_CLEAR_COMMS 10000 | ||||
|  | ||||
| /* | ||||
|  * Flux stream opcodes. Preceded by 0xFF byte. | ||||
|  *  | ||||
|  * | ||||
|  * Argument types: | ||||
|  *  N28: 28-bit non-negative integer N, encoded as 4 bytes b0,b1,b2,b3: | ||||
|  *   b0 = (uint8_t)(1 | (N <<  1)) | ||||
| @@ -120,19 +119,18 @@ extern Bytes stripPartialRotation(const Bytes& fldata); | ||||
|  *  Args: | ||||
|  *   +4 [N28]: ticks to index, relative to sample cursor. | ||||
|  *  Signals an index pulse in the read stream. Sample cursor is unaffected. */ | ||||
| #define FLUXOP_INDEX      1 | ||||
| #define FLUXOP_INDEX 1 | ||||
| /* FLUXOP_SPACE [CMD_READ_FLUX, CMD_WRITE_FLUX] | ||||
|  *  Args: | ||||
|  *   +4 [N28]: ticks to increment the sample cursor. | ||||
|  *  Increments the sample cursor with no intervening flux transitions. */ | ||||
| #define FLUXOP_SPACE      2 | ||||
| #define FLUXOP_SPACE 2 | ||||
| /* FLUXOP_ASTABLE [CMD_WRITE_FLUX] | ||||
|  *  Args: | ||||
|  *   +4 [N28]: astable period. | ||||
|  *  Generate regular flux transitions at specified astable period.  | ||||
|  *  Generate regular flux transitions at specified astable period. | ||||
|  *  Duration is specified by immediately preceding FLUXOP_SPACE opcode(s). */ | ||||
| #define FLUXOP_ASTABLE    3 | ||||
|  | ||||
| #define FLUXOP_ASTABLE 3 | ||||
|  | ||||
| /* | ||||
|  * COMMAND PACKETS | ||||
| @@ -140,7 +138,8 @@ extern Bytes stripPartialRotation(const Bytes& fldata); | ||||
|  | ||||
| /* CMD_GET_INFO, index 0 */ | ||||
| #define GETINFO_FIRMWARE 0 | ||||
| struct packed gw_info { | ||||
| struct packed gw_info | ||||
| { | ||||
|     uint8_t fw_major; | ||||
|     uint8_t fw_minor; | ||||
|     uint8_t is_main_firmware; /* == 0 -> update bootloader */ | ||||
| @@ -153,15 +152,18 @@ extern struct gw_info gw_info; | ||||
|  | ||||
| /* CMD_GET_INFO, index 1 */ | ||||
| #define GETINFO_BW_STATS 1 | ||||
| struct packed gw_bw_stats { | ||||
|     struct packed { | ||||
| struct packed gw_bw_stats | ||||
| { | ||||
|     struct packed | ||||
|     { | ||||
|         uint32_t bytes; | ||||
|         uint32_t usecs; | ||||
|     } min_bw, max_bw; | ||||
| }; | ||||
|  | ||||
| /* CMD_READ_FLUX */ | ||||
| struct packed gw_read_flux { | ||||
| struct packed gw_read_flux | ||||
| { | ||||
|     /* Maximum ticks to read for (or 0, for no limit). */ | ||||
|     uint32_t ticks; | ||||
|     /* Maximum index pulses to read (or 0, for no limit). */ | ||||
| @@ -169,7 +171,8 @@ struct packed gw_read_flux { | ||||
| }; | ||||
|  | ||||
| /* CMD_WRITE_FLUX */ | ||||
| struct packed gw_write_flux { | ||||
| struct packed gw_write_flux | ||||
| { | ||||
|     /* If non-zero, start the write at the index pulse. */ | ||||
|     uint8_t cue_at_index; | ||||
|     /* If non-zero, terminate the write at the next index pulse. */ | ||||
| @@ -177,18 +180,21 @@ struct packed gw_write_flux { | ||||
| }; | ||||
|  | ||||
| /* CMD_ERASE_FLUX */ | ||||
| struct packed gw_erase_flux { | ||||
| struct packed gw_erase_flux | ||||
| { | ||||
|     uint32_t ticks; | ||||
| }; | ||||
|  | ||||
| /* CMD_SINK_SOURCE_BYTES */ | ||||
| struct packed gw_sink_source_bytes { | ||||
| struct packed gw_sink_source_bytes | ||||
| { | ||||
|     uint32_t nr_bytes; | ||||
| }; | ||||
|  | ||||
| /* CMD_{GET,SET}_PARAMS, index 0 */ | ||||
| #define PARAMS_DELAYS 0 | ||||
| struct packed gw_delay { | ||||
| struct packed gw_delay | ||||
| { | ||||
|     uint16_t select_delay; /* usec */ | ||||
|     uint16_t step_delay;   /* usec */ | ||||
|     uint16_t seek_settle;  /* msec */ | ||||
| @@ -198,7 +204,6 @@ struct packed gw_delay { | ||||
|  | ||||
| /* CMD_SWITCH_FW_MODE */ | ||||
| #define FW_MODE_BOOTLOADER 0 | ||||
| #define FW_MODE_NORMAL     1 | ||||
| #define FW_MODE_NORMAL 1 | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,18 +4,18 @@ | ||||
| class SerialPort | ||||
| { | ||||
| public: | ||||
| 	static std::unique_ptr<SerialPort> openSerialPort(const std::string& path); | ||||
|     static std::unique_ptr<SerialPort> openSerialPort(const std::string& path); | ||||
|  | ||||
| public: | ||||
| 	virtual ~SerialPort(); | ||||
| 	virtual ssize_t readImpl(uint8_t* buffer, size_t len) = 0; | ||||
| 	virtual ssize_t write(const uint8_t* buffer, size_t len) = 0; | ||||
|     virtual ~SerialPort(); | ||||
|     virtual ssize_t readImpl(uint8_t* buffer, size_t len) = 0; | ||||
|     virtual ssize_t write(const uint8_t* buffer, size_t len) = 0; | ||||
|  | ||||
| 	void read(uint8_t* buffer, size_t len); | ||||
| 	void read(Bytes& bytes); | ||||
| 	Bytes readBytes(size_t count); | ||||
| 	uint8_t readByte(); | ||||
| 	void write(const Bytes& bytes); | ||||
|     void read(uint8_t* buffer, size_t len); | ||||
|     void read(Bytes& bytes); | ||||
|     Bytes readBytes(size_t count); | ||||
|     uint8_t readByte(); | ||||
|     void write(const Bytes& bytes); | ||||
|  | ||||
| private: | ||||
|     uint8_t _readbuffer[4096]; | ||||
| @@ -24,4 +24,3 @@ private: | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -6,60 +6,95 @@ | ||||
|  | ||||
| class Fluxmap; | ||||
| class GreaseWeazleProto; | ||||
| namespace libusbp { class device; } | ||||
| namespace libusbp | ||||
| { | ||||
|     class device; | ||||
| } | ||||
|  | ||||
| class USB | ||||
| { | ||||
| public: | ||||
| 	virtual ~USB(); | ||||
|     virtual ~USB(); | ||||
|  | ||||
| 	virtual int getVersion() = 0; | ||||
| 	virtual void recalibrate() = 0; | ||||
| 	virtual void seek(int track) = 0; | ||||
| 	virtual nanoseconds_t getRotationalPeriod(int hardSectorCount) = 0; | ||||
| 	virtual void testBulkWrite() = 0; | ||||
| 	virtual void testBulkRead() = 0; | ||||
| 	virtual Bytes read(int side, bool synced, nanoseconds_t readTime, | ||||
| 	                   nanoseconds_t hardSectorThreshold) = 0; | ||||
| 	virtual void write(int side, const Bytes& bytes, | ||||
| 	                   nanoseconds_t hardSectorThreshold) = 0; | ||||
| 	virtual void erase(int side, nanoseconds_t hardSectorThreshold) = 0; | ||||
| 	virtual void setDrive(int drive, bool high_density, int index_mode) = 0; | ||||
| 	virtual void measureVoltages(struct voltages_frame* voltages) = 0; | ||||
|     virtual int getVersion() = 0; | ||||
|     virtual void recalibrate() = 0; | ||||
|     virtual void seek(int track) = 0; | ||||
|     virtual nanoseconds_t getRotationalPeriod(int hardSectorCount) = 0; | ||||
|     virtual void testBulkWrite() = 0; | ||||
|     virtual void testBulkRead() = 0; | ||||
|     virtual Bytes read(int side, | ||||
|         bool synced, | ||||
|         nanoseconds_t readTime, | ||||
|         nanoseconds_t hardSectorThreshold) = 0; | ||||
|     virtual void write( | ||||
|         int side, const Bytes& bytes, nanoseconds_t hardSectorThreshold) = 0; | ||||
|     virtual void erase(int side, nanoseconds_t hardSectorThreshold) = 0; | ||||
|     virtual void setDrive(int drive, bool high_density, int index_mode) = 0; | ||||
|     virtual void measureVoltages(struct voltages_frame* voltages) = 0; | ||||
|  | ||||
| protected: | ||||
| 	std::string usberror(int i); | ||||
|     std::string usberror(int i); | ||||
| }; | ||||
|  | ||||
| extern USB& getUsb(); | ||||
|  | ||||
| extern USB* createFluxengineUsb(libusbp::device& device); | ||||
| extern USB* createGreaseWeazleUsb(const std::string& serialPort, const GreaseWeazleProto& config); | ||||
| extern USB* createGreaseWeazleUsb( | ||||
|     const std::string& serialPort, const GreaseWeazleProto& config); | ||||
|  | ||||
| static inline int usbGetVersion()     { return getUsb().getVersion(); } | ||||
| static inline void usbRecalibrate()   { getUsb().recalibrate(); } | ||||
| static inline void usbSeek(int track) { getUsb().seek(track); } | ||||
| static inline void usbTestBulkWrite() { getUsb().testBulkWrite(); } | ||||
| static inline void usbTestBulkRead()  { getUsb().testBulkRead(); } | ||||
| static inline int usbGetVersion() | ||||
| { | ||||
|     return getUsb().getVersion(); | ||||
| } | ||||
| static inline void usbRecalibrate() | ||||
| { | ||||
|     getUsb().recalibrate(); | ||||
| } | ||||
| static inline void usbSeek(int track) | ||||
| { | ||||
|     getUsb().seek(track); | ||||
| } | ||||
| static inline void usbTestBulkWrite() | ||||
| { | ||||
|     getUsb().testBulkWrite(); | ||||
| } | ||||
| static inline void usbTestBulkRead() | ||||
| { | ||||
|     getUsb().testBulkRead(); | ||||
| } | ||||
|  | ||||
| static inline void usbErase(int side, nanoseconds_t hardSectorThreshold) | ||||
| { getUsb().erase(side, hardSectorThreshold); } | ||||
| { | ||||
|     getUsb().erase(side, hardSectorThreshold); | ||||
| } | ||||
|  | ||||
| static inline nanoseconds_t usbGetRotationalPeriod(int hardSectorCount) | ||||
| { return getUsb().getRotationalPeriod(hardSectorCount); } | ||||
| { | ||||
|     return getUsb().getRotationalPeriod(hardSectorCount); | ||||
| } | ||||
|  | ||||
| static inline Bytes usbRead(int side, bool synced, nanoseconds_t readTime, | ||||
|                             nanoseconds_t hardSectorThreshold) | ||||
| { return getUsb().read(side, synced, readTime, hardSectorThreshold); } | ||||
| static inline Bytes usbRead(int side, | ||||
|     bool synced, | ||||
|     nanoseconds_t readTime, | ||||
|     nanoseconds_t hardSectorThreshold) | ||||
| { | ||||
|     return getUsb().read(side, synced, readTime, hardSectorThreshold); | ||||
| } | ||||
|  | ||||
| static inline void usbWrite(int side, const Bytes& bytes, | ||||
|                             nanoseconds_t hardSectorThreshold) | ||||
| { getUsb().write(side, bytes, hardSectorThreshold); } | ||||
| static inline void usbWrite( | ||||
|     int side, const Bytes& bytes, nanoseconds_t hardSectorThreshold) | ||||
| { | ||||
|     getUsb().write(side, bytes, hardSectorThreshold); | ||||
| } | ||||
|  | ||||
| static inline void usbSetDrive(int drive, bool high_density, int index_mode) | ||||
| { getUsb().setDrive(drive, high_density, index_mode); } | ||||
| { | ||||
|     getUsb().setDrive(drive, high_density, index_mode); | ||||
| } | ||||
|  | ||||
| static inline void usbMeasureVoltages(struct voltages_frame* voltages) | ||||
| { getUsb().measureVoltages(voltages); } | ||||
| { | ||||
|     getUsb().measureVoltages(voltages); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -6,22 +6,21 @@ | ||||
|  | ||||
| enum DeviceType | ||||
| { | ||||
| 	DEVICE_FLUXENGINE, | ||||
| 	DEVICE_GREASEWEAZLE | ||||
|     DEVICE_FLUXENGINE, | ||||
|     DEVICE_GREASEWEAZLE | ||||
| }; | ||||
|  | ||||
| extern std::string getDeviceName(DeviceType type); | ||||
|  | ||||
| struct CandidateDevice | ||||
| { | ||||
| 	DeviceType type; | ||||
| 	libusbp::device device; | ||||
| 	uint32_t id; | ||||
| 	std::string serial; | ||||
| 	std::string serialPort; | ||||
|     DeviceType type; | ||||
|     libusbp::device device; | ||||
|     uint32_t id; | ||||
|     std::string serial; | ||||
|     std::string serialPort; | ||||
| }; | ||||
|  | ||||
| extern std::vector<std::shared_ptr<CandidateDevice>> findUsbDevices(); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -32,7 +32,7 @@ static StringFlag destFlux({"--dest", "-d"}, | ||||
|     [](const auto& value) | ||||
|     { | ||||
|         globalConfig().setFluxSink(value); | ||||
|         globalConfig().setFluxSource(value); | ||||
|         globalConfig().setVerificationFluxSource(value); | ||||
|     }); | ||||
|  | ||||
| static StringFlag destTracks({"--cylinders", "-c"}, | ||||
| @@ -62,9 +62,9 @@ int mainWrite(int argc, const char* argv[]) | ||||
| { | ||||
|     if (argc == 1) | ||||
|         showProfiles("write", formats); | ||||
|     globalConfig()->mutable_flux_sink()->set_type(FluxSinkProto::DRIVE); | ||||
|     if (verify) | ||||
|         globalConfig()->mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     globalConfig().setFluxSink("drive:0"); | ||||
|     globalConfig().setVerificationFluxSource("drive:0"); | ||||
|  | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
|     auto& reader = globalConfig().getImageReader(); | ||||
| @@ -76,16 +76,18 @@ int mainWrite(int argc, const char* argv[]) | ||||
|         FluxSink::create(globalConfig()->flux_sink())); | ||||
|  | ||||
|     std::unique_ptr<Decoder> decoder; | ||||
|     if (globalConfig()->has_decoder() && verify) | ||||
|     std::shared_ptr<FluxSource> verificationFluxSource; | ||||
|     if (globalConfig()->has_decoder() && fluxSink->isHardware() && verify) | ||||
|     { | ||||
|         decoder = Decoder::create(globalConfig()->decoder()); | ||||
|         verificationFluxSource = globalConfig().getVerificationFluxSource(); | ||||
|     } | ||||
|  | ||||
|     std::shared_ptr<FluxSource> fluxSource; | ||||
|     if (verify && | ||||
|         (globalConfig()->flux_source().type() == FluxSourceProto::DRIVE)) | ||||
|         fluxSource = globalConfig().getFluxSource(); | ||||
|  | ||||
|     writeDiskCommand( | ||||
|         *image, *encoder, *fluxSink, decoder.get(), fluxSource.get()); | ||||
|     writeDiskCommand(*image, | ||||
|         *encoder, | ||||
|         *fluxSink, | ||||
|         decoder.get(), | ||||
|         verificationFluxSource.get()); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -4,4 +4,3 @@ | ||||
| extern FlagGroup fileFlags; | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -48,7 +48,7 @@ private: | ||||
|     nanoseconds_t _scrollPosition = 0; | ||||
|     nanoseconds_t _totalDuration = 0; | ||||
|     double _nanosecondsPerPixel = 0; | ||||
| 	std::set<nanoseconds_t> _events; | ||||
|     std::set<nanoseconds_t> _events; | ||||
|     std::vector<float> _densityMap; | ||||
|     int _dragStartX = -1; | ||||
|     nanoseconds_t _dragStartPosition = -1; | ||||
|   | ||||
| @@ -83,7 +83,7 @@ public: | ||||
|     virtual void StartFormatting() = 0; | ||||
|     virtual void StartExploring() = 0; | ||||
|  | ||||
| 	virtual void SafeFit() = 0; | ||||
|     virtual void SafeFit() = 0; | ||||
|     virtual void SetPage(int page) = 0; | ||||
|     virtual void PrepareConfig() = 0; | ||||
|     virtual void ClearLog() = 0; | ||||
| @@ -112,17 +112,17 @@ public: | ||||
|         _mainWindow->ClearLog(); | ||||
|     } | ||||
|  | ||||
| 	void SafeFit() | ||||
| 	{ | ||||
| 		_mainWindow->SafeFit(); | ||||
| 	} | ||||
|     void SafeFit() | ||||
|     { | ||||
|         _mainWindow->SafeFit(); | ||||
|     } | ||||
|  | ||||
|     void StartIdle() | ||||
|     { | ||||
|         _mainWindow->StartIdle(); | ||||
|     } | ||||
|  | ||||
| 	void StartReading() | ||||
|     void StartReading() | ||||
|     { | ||||
|         _mainWindow->StartReading(); | ||||
|     } | ||||
| @@ -161,7 +161,7 @@ public: | ||||
|     virtual void Start() = 0; | ||||
|  | ||||
|     virtual void PrepareConfig() = 0; | ||||
| 	virtual const wxBitmap GetBitmap() = 0; | ||||
|     virtual const wxBitmap GetBitmap() = 0; | ||||
| }; | ||||
|  | ||||
| class ImagerPanel : public PanelComponent | ||||
|   | ||||
| @@ -14,21 +14,25 @@ public: | ||||
|     virtual ~HistogramViewer() {} | ||||
|  | ||||
| public: | ||||
|     void Redraw(const Fluxmap& fluxmap, nanoseconds_t clock=0); | ||||
|     void Redraw(const Fluxmap& fluxmap, nanoseconds_t clock = 0); | ||||
|  | ||||
|     void Redraw(const Fluxmap* fluxmap, nanoseconds_t clock=0) | ||||
| 	{ Redraw(*fluxmap, clock); } | ||||
|     void Redraw(const Fluxmap* fluxmap, nanoseconds_t clock = 0) | ||||
|     { | ||||
|         Redraw(*fluxmap, clock); | ||||
|     } | ||||
|  | ||||
| 	nanoseconds_t GetMedian() const { return _data.median; } | ||||
|     nanoseconds_t GetMedian() const | ||||
|     { | ||||
|         return _data.median; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     void OnPaint(wxPaintEvent&); | ||||
|  | ||||
| private: | ||||
| 	bool _blank = true; | ||||
| 	Fluxmap::ClockData _data; | ||||
| 	wxFont _font; | ||||
| 	nanoseconds_t _clock; | ||||
|     bool _blank = true; | ||||
|     Fluxmap::ClockData _data; | ||||
|     wxFont _font; | ||||
|     nanoseconds_t _clock; | ||||
|     wxDECLARE_EVENT_TABLE(); | ||||
| }; | ||||
|  | ||||
|   | ||||
							
								
								
									
										1063
									
								
								src/gui/icon.png.h
									
									
									
									
									
								
							
							
						
						
									
										1063
									
								
								src/gui/icon.png.h
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -245,6 +245,7 @@ public: | ||||
|                 std::string filename = _selectedDrive ? "drive:1" : "drive:0"; | ||||
|                 globalConfig().setFluxSink(filename); | ||||
|                 globalConfig().setFluxSource(filename); | ||||
|                 globalConfig().setVerificationFluxSource(filename); | ||||
|  | ||||
|                 break; | ||||
|             } | ||||
|   | ||||
| @@ -152,18 +152,19 @@ public: | ||||
|                         FluxSink::create(globalConfig()->flux_sink()); | ||||
|  | ||||
|                     std::unique_ptr<Decoder> decoder; | ||||
|                     std::shared_ptr<FluxSource> fluxSource; | ||||
|                     if (globalConfig()->has_decoder()) | ||||
|                     std::shared_ptr<FluxSource> verificationFluxSource; | ||||
|                     if (globalConfig()->has_decoder() && fluxSink->isHardware()) | ||||
|                     { | ||||
|                         decoder = Decoder::create(globalConfig()->decoder()); | ||||
|                         fluxSource = globalConfig().getFluxSource(); | ||||
|                         verificationFluxSource = | ||||
|                             globalConfig().getVerificationFluxSource(); | ||||
|                     } | ||||
|  | ||||
|                     writeDiskCommand(*image, | ||||
|                         *encoder, | ||||
|                         *fluxSink, | ||||
|                         decoder.get(), | ||||
|                         fluxSource.get()); | ||||
|                         verificationFluxSource.get()); | ||||
|                 }); | ||||
|         } | ||||
|         catch (const ErrorException& e) | ||||
|   | ||||
							
								
								
									
										844
									
								
								src/gui/layout.h
									
									
									
									
									
								
							
							
						
						
									
										844
									
								
								src/gui/layout.h
									
									
									
									
									
								
							| @@ -51,28 +51,45 @@ | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class MainWindowGen : public wxFrame | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxMenuBar* menuBar; | ||||
|     wxMenu* m_menu1; | ||||
|     wxMenu* m_menu2; | ||||
|     wxSimplebook* dataNotebook; | ||||
|  | ||||
| 	protected: | ||||
| 		wxMenuBar* menuBar; | ||||
| 		wxMenu* m_menu1; | ||||
| 		wxMenu* m_menu2; | ||||
| 		wxSimplebook* dataNotebook; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnClose(wxCloseEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnAboutMenuItem(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExit(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnShowLogWindow(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnShowConfigWindow(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnAboutMenuItem( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExit( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnShowLogWindow( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnShowConfigWindow( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		MainWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("FluxEngine"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 616,607 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); | ||||
|  | ||||
| 		~MainWindowGen(); | ||||
| public: | ||||
|     MainWindowGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("FluxEngine"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(616, 607), | ||||
|         long style = wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | | ||||
|                      wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL); | ||||
|  | ||||
|     ~MainWindowGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -80,24 +97,32 @@ class MainWindowGen : public wxFrame | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class TextViewerWindowGen : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxTextCtrl* textControl; | ||||
|     wxStdDialogButtonSizer* m_sdbSizer2; | ||||
|     wxButton* m_sdbSizer2OK; | ||||
|  | ||||
| 	protected: | ||||
| 		wxTextCtrl* textControl; | ||||
| 		wxStdDialogButtonSizer* m_sdbSizer2; | ||||
| 		wxButton* m_sdbSizer2OK; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnClose(wxCloseEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnClose(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		TextViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 208,143 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); | ||||
|  | ||||
| 		~TextViewerWindowGen(); | ||||
| public: | ||||
|     TextViewerWindowGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxEmptyString, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(208, 143), | ||||
|         long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | | ||||
|                      wxMINIMIZE_BOX | wxRESIZE_BORDER); | ||||
|  | ||||
|     ~TextViewerWindowGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -105,25 +130,33 @@ class TextViewerWindowGen : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FluxViewerWindowGen : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     FluxViewerControl* fluxviewer; | ||||
|     wxScrollBar* scrollbar; | ||||
|     wxStdDialogButtonSizer* m_sdbSizer2; | ||||
|     wxButton* m_sdbSizer2OK; | ||||
|  | ||||
| 	protected: | ||||
| 		FluxViewerControl* fluxviewer; | ||||
| 		wxScrollBar* scrollbar; | ||||
| 		wxStdDialogButtonSizer* m_sdbSizer2; | ||||
| 		wxButton* m_sdbSizer2OK; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnClose(wxCloseEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnClose(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		FluxViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,200 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); | ||||
|  | ||||
| 		~FluxViewerWindowGen(); | ||||
| public: | ||||
|     FluxViewerWindowGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxEmptyString, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(400, 200), | ||||
|         long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | | ||||
|                      wxMINIMIZE_BOX | wxRESIZE_BORDER); | ||||
|  | ||||
|     ~FluxViewerWindowGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -131,26 +164,37 @@ class FluxViewerWindowGen : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class TextEditorWindowGen : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxTextCtrl* textControl; | ||||
|     wxStdDialogButtonSizer* m_sdbSizer2; | ||||
|     wxButton* m_sdbSizer2Save; | ||||
|     wxButton* m_sdbSizer2Cancel; | ||||
|  | ||||
| 	protected: | ||||
| 		wxTextCtrl* textControl; | ||||
| 		wxStdDialogButtonSizer* m_sdbSizer2; | ||||
| 		wxButton* m_sdbSizer2Save; | ||||
| 		wxButton* m_sdbSizer2Cancel; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnClose(wxCloseEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnCancel(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnSave(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnSave( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		TextEditorWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); | ||||
|  | ||||
| 		~TextEditorWindowGen(); | ||||
| public: | ||||
|     TextEditorWindowGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxEmptyString, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | | ||||
|                      wxMINIMIZE_BOX | wxRESIZE_BORDER); | ||||
|  | ||||
|     ~TextEditorWindowGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -158,27 +202,32 @@ class TextEditorWindowGen : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FileViewerWindowGen : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxNotebook* m_notebook1; | ||||
|     wxPanel* m_panel8; | ||||
|     wxTextCtrl* textControl; | ||||
|     wxPanel* m_panel7; | ||||
|     wxTextCtrl* hexControl; | ||||
|     wxStdDialogButtonSizer* m_sdbSizer2; | ||||
|     wxButton* m_sdbSizer2OK; | ||||
|  | ||||
| 	protected: | ||||
| 		wxNotebook* m_notebook1; | ||||
| 		wxPanel* m_panel8; | ||||
| 		wxTextCtrl* textControl; | ||||
| 		wxPanel* m_panel7; | ||||
| 		wxTextCtrl* hexControl; | ||||
| 		wxStdDialogButtonSizer* m_sdbSizer2; | ||||
| 		wxButton* m_sdbSizer2OK; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnClose(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		FileViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 408,269 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); | ||||
|  | ||||
| 		~FileViewerWindowGen(); | ||||
| public: | ||||
|     FileViewerWindowGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxEmptyString, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(408, 269), | ||||
|         long style = wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | | ||||
|                      wxRESIZE_BORDER); | ||||
|  | ||||
|     ~FileViewerWindowGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -186,23 +235,26 @@ class FileViewerWindowGen : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class GetfileDialog : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText7; | ||||
|     wxStaticText* m_staticText9; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText7; | ||||
| 		wxStaticText* m_staticText9; | ||||
| public: | ||||
|     wxTextCtrl* filenameText; | ||||
|     wxFilePickerCtrl* targetFilePicker; | ||||
|     wxStdDialogButtonSizer* buttons_; | ||||
|     wxButton* buttons_OK; | ||||
|     wxButton* buttons_Cancel; | ||||
|  | ||||
| 	public: | ||||
| 		wxTextCtrl* filenameText; | ||||
| 		wxFilePickerCtrl* targetFilePicker; | ||||
| 		wxStdDialogButtonSizer* buttons_; | ||||
| 		wxButton* buttons_OK; | ||||
| 		wxButton* buttons_Cancel; | ||||
|  | ||||
| 		GetfileDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Copy file off disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); | ||||
|  | ||||
| 		~GetfileDialog(); | ||||
|     GetfileDialog(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("Copy file off disk"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxDEFAULT_DIALOG_STYLE); | ||||
|  | ||||
|     ~GetfileDialog(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -210,24 +262,27 @@ class GetfileDialog : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FileConflictDialog : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText91; | ||||
|     wxStaticText* m_staticText7; | ||||
|     wxStaticText* m_staticText9; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText91; | ||||
| 		wxStaticText* m_staticText7; | ||||
| 		wxStaticText* m_staticText9; | ||||
| public: | ||||
|     wxTextCtrl* newNameText; | ||||
|     wxTextCtrl* oldNameText; | ||||
|     wxStdDialogButtonSizer* buttons_; | ||||
|     wxButton* buttons_OK; | ||||
|     wxButton* buttons_Cancel; | ||||
|  | ||||
| 	public: | ||||
| 		wxTextCtrl* newNameText; | ||||
| 		wxTextCtrl* oldNameText; | ||||
| 		wxStdDialogButtonSizer* buttons_; | ||||
| 		wxButton* buttons_OK; | ||||
| 		wxButton* buttons_Cancel; | ||||
|  | ||||
| 		FileConflictDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Filename conflict"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); | ||||
|  | ||||
| 		~FileConflictDialog(); | ||||
|     FileConflictDialog(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("Filename conflict"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxDEFAULT_DIALOG_STYLE); | ||||
|  | ||||
|     ~FileConflictDialog(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -235,24 +290,27 @@ class FileConflictDialog : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FileRenameDialog : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText91; | ||||
|     wxStaticText* m_staticText7; | ||||
|     wxStaticText* m_staticText9; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText91; | ||||
| 		wxStaticText* m_staticText7; | ||||
| 		wxStaticText* m_staticText9; | ||||
| public: | ||||
|     wxTextCtrl* newNameText; | ||||
|     wxTextCtrl* oldNameText; | ||||
|     wxStdDialogButtonSizer* buttons_; | ||||
|     wxButton* buttons_OK; | ||||
|     wxButton* buttons_Cancel; | ||||
|  | ||||
| 	public: | ||||
| 		wxTextCtrl* newNameText; | ||||
| 		wxTextCtrl* oldNameText; | ||||
| 		wxStdDialogButtonSizer* buttons_; | ||||
| 		wxButton* buttons_OK; | ||||
| 		wxButton* buttons_Cancel; | ||||
|  | ||||
| 		FileRenameDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Rename or move file"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); | ||||
|  | ||||
| 		~FileRenameDialog(); | ||||
|     FileRenameDialog(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("Rename or move file"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxDEFAULT_DIALOG_STYLE); | ||||
|  | ||||
|     ~FileRenameDialog(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -260,22 +318,25 @@ class FileRenameDialog : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class CreateDirectoryDialog : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText91; | ||||
|     wxStaticText* m_staticText9; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText91; | ||||
| 		wxStaticText* m_staticText9; | ||||
| public: | ||||
|     wxTextCtrl* newNameText; | ||||
|     wxStdDialogButtonSizer* buttons_; | ||||
|     wxButton* buttons_OK; | ||||
|     wxButton* buttons_Cancel; | ||||
|  | ||||
| 	public: | ||||
| 		wxTextCtrl* newNameText; | ||||
| 		wxStdDialogButtonSizer* buttons_; | ||||
| 		wxButton* buttons_OK; | ||||
| 		wxButton* buttons_Cancel; | ||||
|  | ||||
| 		CreateDirectoryDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Create new directory"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); | ||||
|  | ||||
| 		~CreateDirectoryDialog(); | ||||
|     CreateDirectoryDialog(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("Create new directory"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxDEFAULT_DIALOG_STYLE); | ||||
|  | ||||
|     ~CreateDirectoryDialog(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -283,23 +344,26 @@ class CreateDirectoryDialog : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FormatDialog : public wxDialog | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText91; | ||||
|     wxStaticText* m_staticText7; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText91; | ||||
| 		wxStaticText* m_staticText7; | ||||
| public: | ||||
|     wxTextCtrl* volumeNameText; | ||||
|     wxCheckBox* quickFormatCheckBox; | ||||
|     wxStdDialogButtonSizer* buttons_; | ||||
|     wxButton* buttons_OK; | ||||
|     wxButton* buttons_Cancel; | ||||
|  | ||||
| 	public: | ||||
| 		wxTextCtrl* volumeNameText; | ||||
| 		wxCheckBox* quickFormatCheckBox; | ||||
| 		wxStdDialogButtonSizer* buttons_; | ||||
| 		wxButton* buttons_OK; | ||||
| 		wxButton* buttons_Cancel; | ||||
|  | ||||
| 		FormatDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Format disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); | ||||
|  | ||||
| 		~FormatDialog(); | ||||
|     FormatDialog(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxString& title = wxT("Format disk"), | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxDefaultSize, | ||||
|         long style = wxDEFAULT_DIALOG_STYLE); | ||||
|  | ||||
|     ~FormatDialog(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -307,37 +371,59 @@ class FormatDialog : public wxDialog | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class IdlePanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticBitmap* applicationBitmap; | ||||
|     wxPanel* sourceIconPanel; | ||||
|     wxSimplebook* sourceBook; | ||||
|     wxChoice* formatChoice; | ||||
|     wxButton* customConfigurationButton; | ||||
|     wxPanel* formatOptionsContainer; | ||||
|     wxButton* readButton; | ||||
|     wxButton* writeButton; | ||||
|     wxButton* browseButton; | ||||
|     wxButton* formatButton; | ||||
|     wxButton* exploreButton; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticBitmap* applicationBitmap; | ||||
| 		wxPanel* sourceIconPanel; | ||||
| 		wxSimplebook* sourceBook; | ||||
| 		wxChoice* formatChoice; | ||||
| 		wxButton* customConfigurationButton; | ||||
| 		wxPanel* formatOptionsContainer; | ||||
| 		wxButton* readButton; | ||||
| 		wxButton* writeButton; | ||||
| 		wxButton* browseButton; | ||||
| 		wxButton* formatButton; | ||||
| 		wxButton* exploreButton; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnControlsChanged(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnCustomConfigurationButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnReadButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnWriteButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowseButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnFormatButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExploreButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnControlsChanged( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnCustomConfigurationButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnReadButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnWriteButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowseButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnFormatButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExploreButton( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		IdlePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~IdlePanelGen(); | ||||
| public: | ||||
|     IdlePanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(-1, -1), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~IdlePanelGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -345,30 +431,43 @@ class IdlePanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class ImagerPanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxAuiToolBar* imagerToolbar; | ||||
|     wxAuiToolBarItem* imagerBackTool; | ||||
|     VisualisationControl* visualiser; | ||||
|     wxButton* imagerSaveImageButton; | ||||
|     wxButton* imagerSaveFluxButton; | ||||
|     HistogramViewer* histogram; | ||||
|     wxButton* imagerGoAgainButton; | ||||
|  | ||||
| 	protected: | ||||
| 		wxAuiToolBar* imagerToolbar; | ||||
| 		wxAuiToolBarItem* imagerBackTool; | ||||
| 		VisualisationControl* visualiser; | ||||
| 		wxButton* imagerSaveImageButton; | ||||
| 		wxButton* imagerSaveFluxButton; | ||||
| 		HistogramViewer* histogram; | ||||
| 		wxButton* imagerGoAgainButton; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnBackButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnSaveImageButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnSaveFluxButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnImagerGoAgainButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnSaveImageButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnSaveFluxButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnImagerGoAgainButton( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		ImagerPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~ImagerPanelGen(); | ||||
| public: | ||||
|     ImagerPanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(500, 300), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~ImagerPanelGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -376,69 +475,121 @@ class ImagerPanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class BrowserPanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxAuiToolBar* browserToolbar; | ||||
|     wxAuiToolBarItem* browserBackTool; | ||||
|     wxAuiToolBarItem* browserInfoTool; | ||||
|     wxAuiToolBarItem* browserViewTool; | ||||
|     wxAuiToolBarItem* browserSaveTool; | ||||
|     wxAuiToolBarItem* browserMoreMenuButton; | ||||
|     wxMenu* browserMoreMenu; | ||||
|     wxMenuItem* browserAddMenuItem; | ||||
|     wxMenuItem* browserNewDirectoryMenuItem; | ||||
|     wxMenuItem* browserRenameMenuItem; | ||||
|     wxMenuItem* browserDeleteMenuItem; | ||||
|     wxAuiToolBarItem* browserFormatTool; | ||||
|     wxDataViewCtrl* browserTree; | ||||
|     wxDataViewColumn* m_dataViewColumn1; | ||||
|     wxDataViewColumn* m_dataViewColumn2; | ||||
|     wxDataViewColumn* m_dataViewColumn3; | ||||
|     wxGauge* diskSpaceGauge; | ||||
|     wxButton* browserDiscardButton; | ||||
|     wxButton* browserCommitButton; | ||||
|     wxStaticText* m_staticText12; | ||||
|  | ||||
| 	protected: | ||||
| 		wxAuiToolBar* browserToolbar; | ||||
| 		wxAuiToolBarItem* browserBackTool; | ||||
| 		wxAuiToolBarItem* browserInfoTool; | ||||
| 		wxAuiToolBarItem* browserViewTool; | ||||
| 		wxAuiToolBarItem* browserSaveTool; | ||||
| 		wxAuiToolBarItem* browserMoreMenuButton; | ||||
| 		wxMenu* browserMoreMenu; | ||||
| 		wxMenuItem* browserAddMenuItem; | ||||
| 		wxMenuItem* browserNewDirectoryMenuItem; | ||||
| 		wxMenuItem* browserRenameMenuItem; | ||||
| 		wxMenuItem* browserDeleteMenuItem; | ||||
| 		wxAuiToolBarItem* browserFormatTool; | ||||
| 		wxDataViewCtrl* browserTree; | ||||
| 		wxDataViewColumn* m_dataViewColumn1; | ||||
| 		wxDataViewColumn* m_dataViewColumn2; | ||||
| 		wxDataViewColumn* m_dataViewColumn3; | ||||
| 		wxGauge* diskSpaceGauge; | ||||
| 		wxButton* browserDiscardButton; | ||||
| 		wxButton* browserCommitButton; | ||||
| 		wxStaticText* m_staticText12; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnBackButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserInfoButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserViewButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserSaveButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserAddMenuItem(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserNewDirectoryMenuItem(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserRenameMenuItem(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserDeleteMenuItem(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserFormatButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserBeginDrag(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserDrop(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserDropPossible(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserFilenameChanged(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserDirectoryExpanding(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserSelectionChanged(wxDataViewEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserDiscardButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnBrowserCommitButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserInfoButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserViewButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserSaveButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserAddMenuItem( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserNewDirectoryMenuItem( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserRenameMenuItem( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserDeleteMenuItem( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserFormatButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserBeginDrag( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserDrop( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserDropPossible( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserFilenameChanged( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserDirectoryExpanding( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserSelectionChanged( wxDataViewEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserDiscardButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnBrowserCommitButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| public: | ||||
|     BrowserPanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(500, 300), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~BrowserPanelGen(); | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		BrowserPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~BrowserPanelGen(); | ||||
|  | ||||
| 		void browserMoreMenuButtonOnDropDownMenu( wxAuiToolBarEvent &event ) | ||||
| 		{ | ||||
| 			if ( event.IsDropDownClicked() ) | ||||
| 			{ | ||||
| 				browserToolbar->SetToolSticky( event.GetId(), true ); | ||||
| 				wxRect rect = browserToolbar->GetToolRect( event.GetId() ); | ||||
| 				wxPoint pt = browserToolbar->ClientToScreen( rect.GetBottomLeft() ); | ||||
| 				pt = ScreenToClient( pt ); | ||||
| 				browserToolbar->PopupMenu( browserMoreMenu, pt ); | ||||
| 				browserToolbar->SetToolSticky( event.GetId(), false ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|     void browserMoreMenuButtonOnDropDownMenu(wxAuiToolBarEvent& event) | ||||
|     { | ||||
|         if (event.IsDropDownClicked()) | ||||
|         { | ||||
|             browserToolbar->SetToolSticky(event.GetId(), true); | ||||
|             wxRect rect = browserToolbar->GetToolRect(event.GetId()); | ||||
|             wxPoint pt = browserToolbar->ClientToScreen(rect.GetBottomLeft()); | ||||
|             pt = ScreenToClient(pt); | ||||
|             browserToolbar->PopupMenu(browserMoreMenu, pt); | ||||
|             browserToolbar->SetToolSticky(event.GetId(), false); | ||||
|         } | ||||
|     } | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -446,45 +597,64 @@ class BrowserPanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class ExplorerPanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxAuiToolBar* explorerToolbar; | ||||
|     wxAuiToolBarItem* explorerBackTool; | ||||
|     wxAuiToolBarItem* explorerRefreshTool; | ||||
|     wxStaticText* m_staticText22; | ||||
|     wxSpinCtrl* explorerTrackSpinCtrl; | ||||
|     wxStaticText* m_staticText26; | ||||
|     wxSpinCtrl* explorerSideSpinCtrl; | ||||
|     wxStaticText* m_staticText231; | ||||
|     wxSpinCtrlDouble* explorerStartTimeSpinCtrl; | ||||
|     wxStaticText* m_staticText24; | ||||
|     wxButton* guessButton; | ||||
|     wxSpinCtrlDouble* explorerClockSpinCtrl; | ||||
|     wxStaticText* m_staticText25; | ||||
|     wxSpinCtrl* explorerBitOffsetSpinCtrl; | ||||
|     wxStaticText* m_staticText27; | ||||
|     wxChoice* explorerDecodeChoice; | ||||
|     wxStaticText* m_staticText241; | ||||
|     wxCheckBox* explorerReverseCheckBox; | ||||
|     HistogramViewer* histogram; | ||||
|     wxTextCtrl* explorerText; | ||||
|  | ||||
| 	protected: | ||||
| 		wxAuiToolBar* explorerToolbar; | ||||
| 		wxAuiToolBarItem* explorerBackTool; | ||||
| 		wxAuiToolBarItem* explorerRefreshTool; | ||||
| 		wxStaticText* m_staticText22; | ||||
| 		wxSpinCtrl* explorerTrackSpinCtrl; | ||||
| 		wxStaticText* m_staticText26; | ||||
| 		wxSpinCtrl* explorerSideSpinCtrl; | ||||
| 		wxStaticText* m_staticText231; | ||||
| 		wxSpinCtrlDouble* explorerStartTimeSpinCtrl; | ||||
| 		wxStaticText* m_staticText24; | ||||
| 		wxButton* guessButton; | ||||
| 		wxSpinCtrlDouble* explorerClockSpinCtrl; | ||||
| 		wxStaticText* m_staticText25; | ||||
| 		wxSpinCtrl* explorerBitOffsetSpinCtrl; | ||||
| 		wxStaticText* m_staticText27; | ||||
| 		wxChoice* explorerDecodeChoice; | ||||
| 		wxStaticText* m_staticText241; | ||||
| 		wxCheckBox* explorerReverseCheckBox; | ||||
| 		HistogramViewer* histogram; | ||||
| 		wxTextCtrl* explorerText; | ||||
|     // Virtual event handlers, override them in your derived class | ||||
|     virtual void OnBackButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExplorerRefreshButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExplorerSettingChange(wxSpinEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExplorerSettingChange(wxSpinDoubleEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnGuessClockButton(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|     virtual void OnExplorerSettingChange(wxCommandEvent& event) | ||||
|     { | ||||
|         event.Skip(); | ||||
|     } | ||||
|  | ||||
| 		// Virtual event handlers, override them in your derived class | ||||
| 		virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExplorerRefreshButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExplorerSettingChange( wxSpinEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExplorerSettingChange( wxSpinDoubleEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnGuessClockButton( wxCommandEvent& event ) { event.Skip(); } | ||||
| 		virtual void OnExplorerSettingChange( wxCommandEvent& event ) { event.Skip(); } | ||||
|  | ||||
|  | ||||
| 	public: | ||||
|  | ||||
| 		ExplorerPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,426 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~ExplorerPanelGen(); | ||||
| public: | ||||
|     ExplorerPanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(620, 426), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~ExplorerPanelGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -492,21 +662,24 @@ class ExplorerPanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class HardwareSourcePanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText30; | ||||
|     wxStaticText* m_staticText29; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText30; | ||||
| 		wxStaticText* m_staticText29; | ||||
| public: | ||||
|     wxStaticText* label; | ||||
|     wxCheckBox* highDensityToggle; | ||||
|     wxChoice* driveTypeChoice; | ||||
|  | ||||
| 	public: | ||||
| 		wxStaticText* label; | ||||
| 		wxCheckBox* highDensityToggle; | ||||
| 		wxChoice* driveTypeChoice; | ||||
|  | ||||
| 		HardwareSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~HardwareSourcePanelGen(); | ||||
|     HardwareSourcePanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(-1, -1), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~HardwareSourcePanelGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -514,19 +687,22 @@ class HardwareSourcePanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class FluxfileSourcePanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText28; | ||||
|     wxStaticText* m_staticText27; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText28; | ||||
| 		wxStaticText* m_staticText27; | ||||
| public: | ||||
|     wxFilePickerCtrl* fluxImagePicker; | ||||
|  | ||||
| 	public: | ||||
| 		wxFilePickerCtrl* fluxImagePicker; | ||||
|  | ||||
| 		FluxfileSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~FluxfileSourcePanelGen(); | ||||
|     FluxfileSourcePanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(-1, -1), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~FluxfileSourcePanelGen(); | ||||
| }; | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -534,18 +710,20 @@ class FluxfileSourcePanelGen : public wxPanel | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| class ImagefileSourcePanelGen : public wxPanel | ||||
| { | ||||
| 	private: | ||||
| private: | ||||
| protected: | ||||
|     wxStaticText* m_staticText29; | ||||
|     wxStaticText* m_staticText28; | ||||
|  | ||||
| 	protected: | ||||
| 		wxStaticText* m_staticText29; | ||||
| 		wxStaticText* m_staticText28; | ||||
| public: | ||||
|     wxFilePickerCtrl* diskImagePicker; | ||||
|  | ||||
| 	public: | ||||
| 		wxFilePickerCtrl* diskImagePicker; | ||||
|  | ||||
| 		ImagefileSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); | ||||
|  | ||||
| 		~ImagefileSourcePanelGen(); | ||||
|     ImagefileSourcePanelGen(wxWindow* parent, | ||||
|         wxWindowID id = wxID_ANY, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|         const wxSize& size = wxSize(-1, -1), | ||||
|         long style = wxTAB_TRAVERSAL, | ||||
|         const wxString& name = wxEmptyString); | ||||
|  | ||||
|     ~ImagefileSourcePanelGen(); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -11,4 +11,3 @@ extern RangeFlag requiredSectors; | ||||
| extern int mainReadIBM(int argc, const char* argv[]); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -2,37 +2,39 @@ | ||||
| #define TESTS_H | ||||
|  | ||||
| class AssertionError | ||||
| {}; | ||||
| { | ||||
| }; | ||||
|  | ||||
| template <class T> | ||||
| class Subject | ||||
| { | ||||
| public: | ||||
| 	Subject(const std::string& filename, int lineno, T value): | ||||
| 		_filename(filename), | ||||
| 		_lineno(lineno), | ||||
| 		_value(value) {} | ||||
|     Subject(const std::string& filename, int lineno, T value): | ||||
|         _filename(filename), | ||||
|         _lineno(lineno), | ||||
|         _value(value) | ||||
|     { | ||||
|     } | ||||
|  | ||||
| public: | ||||
| 	void isEqualTo(T wanted) | ||||
| 	{ | ||||
| 		if (_value != wanted) | ||||
| 			fail(fmt::format("wanted {}, got {}", wanted, _value)); | ||||
| 	} | ||||
|     void isEqualTo(T wanted) | ||||
|     { | ||||
|         if (_value != wanted) | ||||
|             fail(fmt::format("wanted {}, got {}", wanted, _value)); | ||||
|     } | ||||
|  | ||||
| private: | ||||
| 	void fail(const std::string& message) | ||||
| 	{ | ||||
| 		error("assertion failed: {}: {}: {}", _filename, _lineno, message); | ||||
| 	} | ||||
|     void fail(const std::string& message) | ||||
|     { | ||||
|         error("assertion failed: {}: {}: {}", _filename, _lineno, message); | ||||
|     } | ||||
|  | ||||
| private: | ||||
| 	const std::string _filename; | ||||
| 	int _lineno; | ||||
| 	T _value; | ||||
|     const std::string _filename; | ||||
|     int _lineno; | ||||
|     T _value; | ||||
| }; | ||||
|  | ||||
| #define assertThat(value) Subject(__FILE__, __LINE__, value) | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user