SCANNING DEVICE FOR RECONSTRUCTING A COMPLETE CODE FROM SCANNED SEGMENTS

Abstract: This invention features both a device and method for reading machine readable code. The device includes a scanning apparatus (100), a signal processor (152) and a data processor (150). The scanning apparatus (100) scans the code and outputs a signal representative of at least a portion of the code. The signal processing means (152) processes each of the signals outputted by the scanning means and further provides signal identification data, including a width and position associated with each of the signals, for each successive scan of the code. The data processing means (150) reconstructs the code from the signal identification data for each successive scan of the code, provided by the signal processing means. The data processing means (150) includes a position aligning means for both selecting an element in a previous scan and calculating the position of that element in a successive scan based upon a calculated offset, and means for aligning the successive scan with the previous scan by means of the calculated offset.

Description: SCANNING DEVICE FOR RECONSTRUCTING A COMPLETE CODE FROM SCANNED SEGMENTS FIELD OF INVENTION This invention relates to devices for scanning bar codes and more particularly to omni-directional scanning devices which reconstruct a complete code by combining scanned code segments. BACKGROUND OF THE INVENTION Bar codes are used in a number of applications to uniquely identify an item or group of items. The bar code is typically a combination of black bars and white spaces representing the unique identification code and is affixed to the item in any of a number of ways (e.g., a label). The reading and decoding of a bar code can be used to yield additional information concerning the item, such as a description of the item and its price. The bar code has also been used for inventory control, manufacturing parts control, and employee identification. Failure to properly read the bar code usually requires manual intervention, such as manual entry of the data (e.g. , the identi ication number represented by the bar code) . Manual intervention, however, can cause problems because of human error as well as causing delays and increasing costs. Bar code scanners are the devices used to read the bar code affixed to an item so the desired information can be retrieved. In the case of a supermarket, one example of this would be the price associated with goods. The scanner reads the bar code by detecting the light reflected from the bar code and determining the light contrasts between the bars, typically the dark or black areas, and the spaces, typically the light or white areas. In most scanners the code is illuminated by a beam of coherent light (i.e., a laser) that moves or sweeps across the bar code. A rotating wheel with a number of mirror facets is typically used to sweep the coherent light across the bar code. There is shown in FIG. 1, a typical omni-directional overhead scanner 10 for detecting a bar code 22 affixed to package 12 traveling on a conveyer belt 14 in direction 20. The scanner 10 illuminates the package top surface, where the bar code 22 is located, with pattern 16 of coherent light. In this way, the scanner 10 can read a bar code 22 that approaches the scanner 10 in any orientation. In this illustration, the bar code 22 is read so the package 12 can be sorted and sent along different paths 18a-c. For one scanning technique, the bar code is read by sweeping a beam of coherent light across the entire bar code. In actual practice redundant passes or sweeps are made across the entire bar code to assure a good reading of the bar code, however, no reconstruction of the bar code is done. The redundant scanning is done to address possible localized width inaccuracies (e.g. , local void in bar) . This method is best suited for reading bar codes which have been pre-positioned so the bar code extends along the scan line of the sweeping coherent line. This bar code orientation has also been referred to as a "picket fence" or "ladder" orientation. However, it is not always possible to control the orientation of the bar code with respect to the scan line of the scanning device. There are two ways that the traditional method could be used to scan a bar code which is at an angle with respect to the coherent light scan line. The bar code may be scanned with many beams of coherent light at numerous angles with respect to the surface of the bar code. This approach, however, requires a great deal of expensive equipment to implement. Alternatively, the bar codes may be made very tall so practically speaking the scan line will see the entire bar code. This approach significantly increases the size of bar code (e.g. , the bar code label) . Another technique to read a bar code, which is at an angle with respect to a coherent light scan line, involves reconstructing the entire bar code from fragments of the bar code. This technique is based on the principle that, as the bar code moves under and through the coherent light scan line, the entire bar code will eventually be seen by the scanner. The scanner, however, only scans a portion or fragment of the bar code at a time, saving each of the scanned fragments. After the bar code has passed through the scan line, the complete bar code is reconstructed by reconnecting the saved scanned fragments. When reconstructing a bar code, there is an increased risk that the bar code will be mis-read because of the loss in redundancy. Redundancy is the repetitive measuring of the same bar code element (e.g., same bar) to assure that the correct element width is provided ' for decoding. For any given scan, it is possible for an incorrect width to be outputted because of printing problems (e.g., voids or blotches), errors in the scanning process, and/or from wear and tear on the bar code (e.g., bar code label). Since repetitive scanning of the entire bar code is not possible for the reconstruction technique, redundancy is obtained at the individual bar and space level by utilizing width data from overlapping regions of code fragments. When fragments are properly aligned, redundant information is available to refine and correct width data for the bars and spaces in the overlap regions. For reconstructive methods, therefore, redundancy is dependent upon getting a correct fragment alignment. One type of reconstructive technique involves aligning fragments by locating and matching a bar and space pattern, including the bar and space widths, that is common to the fragments. This specific technique will be referred to hereinafter has as "pattern matching." One common cause for fragment misalignment with the pattern matching technique is the presence of repetitive patterns of bar elements in a bar code. Because of repetitive patterns there can be a number of areas in the fragments which are common to each other. Thus, while the bar and space patterns of the fragments may match, the fragments may not be properly aligned because the wrong bar and space patterns are being used for alignment. Misalignment can occur for a number of other reasons. Human readable printing about the bar code can produce false bars at one or both ends. Printing errors as well as wear and tear on the bar code label can cause a particular bar to appear much smaller or larger in one scan than it does in another. If exact pattern matches are required, very few bar codes will be successfully rebuilt, and the read rate will be very low. Since an exact pattern match will not result most of the time, an arbitrary limit is typically established so that fragments are considered in alignment if at least some set number of bars and spaces match. However, if the limit is set too loose, while the number of matches will go up and the read rate will be high, the number of mis-reads will go up. In practice, a majority of the mis-reads can be filtered out by using fixed length bar codes and checksums. Therefore, determining accurate bar and space widths for proper decoding depends on a proper alignment of the bar code fragment overlapping regions. However, the proper alignment of the overlapping regions in known methods depends upon matching the patterns of the fragments. This method assumes that the bars and spaces have the correct widths. In sum, reconstructing bar codes by using known methods for pattern matching balances the need for accurate bar and space widths for decoding with the need for a reasonable read rate. Reconstructive bar code scanning devices and the associated methodology are disclosed in U.S. Patent Nos. 4,289,957, 4,488,678, 4,717,818, 4,973,829, 5,028,772, and 5,124,538. The differences between the above referenced patents is the specific manner in which the fragments are combined to reconstruct a complete bar code for decoding. In U.S. Patent Nos. 4,289,957, and 4,717,818 the bar code contains markers representing the ends and middle of the bar code. The scanning device reconstructs the complete bar code based on the presence or existence of markers in the scanned segments. In Patent No. 4,289,957, a bar fragment portion not located between two markers (e.g., end and middle) is ignored and the fragment portions that lie between the markers are combined. In U.S. Patent No. 4,488,678, the superfluous or duplicative data from the overlap between the bar code fragments is removed in one of two ways. If a bar code has separation bars, the data outside the separation bars is eliminated. If the bar code does not have separation bars, the number of bars indicated by the combined data is compared to the known number of bars for the particular bar code being scanned. If the number of bars for the combined data is greater than the known value, the superfluous or duplicative data is removed from either of the overlapping regions. In U.S. Patent Nos. 4,973,829, 5,028,772, and 5,124,538, a complete bar code is reconstructed by relatively shifting the stored data of two fragments until there is a pattern matching of the data (i.e., the bar/space patterns match). The data from the fragments is then combined based on this point of commonalty. The differences between these patents is the manner in which the width data is relatively shifted, the amount and type of matching required, and how the data is reconstructed. In U.S. Patent No. 4,973,829, the data from multiple passes is combined using a superimposition technique. In this method, the data in the master memory is shifted one address at a time until the master memory data fully coincides with the data from one of the passes stored in the transaction memory. The data from the transaction memory is then superimposed on the data in the master memory starting at the point of coincidence. In U.S. Patent No. 5,028,772, a bar code is scanned producing two incomplete bar code segments where one fragment provides the beginning of the code, the other fragment provides the end, and both provide an overlapping middle portion. The two bar code fragments are combined by relatively shifting the overlapping regions of the fragments until a registered or pattern matched middle portion results. Essentially, the device slides one fragment along the data previously acquired until a pattern of bars and spaces match up. U.S. Patent No. 5,124,538 (a continuation of "772) describes a methodology whereby a plurality of scanned fragments can be combined to reconstruct the entire bar code. In this technique, while taking data relating to bar and space widths, data is also accumulated concerning the position of certain data events with respect to the starting point of each scan. The transition (e.g., white to black) position count for a valid middle portion of the first fragment is recorded and a range (+/-) is calculated. The second fragment is then analyzed to see if at least a portion of that fragment falls within the calculated range of the valid middle region of the first fragment. If it does not lie within the valid range, a fragment from a following scan is analyzed. If the second fragment does fall within the calculated range, the valid middle region of the first fragment, the second fragment is shifted to each possible location within the calculated range. A pattern comparison is then made between the width data for each fragment at each possible location. Preferably, a bar/space pair is created by summing adjacent bars and spaces which are then used for pattern comparison purposes. If the pattern matches, then a registered middle portion of adjacent code fragments is identified or found. Therefore, it is object of the present invention to provide a scanning device that avoids uncertainties inherent in the pattern matching alignment technique. Another object of the present invention is to provide a scanning device that is more efficient and faster than prior art techniques. It is a further object of the present invention to provide a scanning device that aligns scanned segments so that redundant information for each bar element scanned can be used to determine bar and space widths for decoding. It is yet another object of the present invention to provide a scanning device that can reconstruct a complete bar code from scanned segments by calculating the positional change of a selected bar between scans. It is yet a further object of the present invention to provide a scanning device that can align overlapping scanned code segments using the positional information of the selected bar. It is still yet another object of the present invention to provide a scanning device that can be used for a number of applications including reading packages moving along high speed conveyers for data collection and/or sorting purposes. SUMMARY OF THE INVENTION This invention features both a device and method for reading machine readable code, having a plurality of code elements, on an object. The device includes a scanning means, a signal processing means and a data processing means. The scanning means successively scans the code and outputs a signal representative of at least a portion of the code, for each successive scan of the code. The signal processing means processes each of the signals outputted by the scanning means and further provides signal identification data, including a width and position associated with each of the signals, for each successive scan of the code. The data processing means reconstructs the code from the signal identification data for each successive scan of the code, provided by the signal processing means. The data processing means includes a position aligning means for both determining the position of a selected code element for a successive scan and for positionally aligning the selected code element with the corresponding element from a prior scan. In a preferred embodiment, the data processing means further includes combining and accumulating data means. The position aligning means of the data processing means further includes first and second position calculating means and offset averaging means. The first position calculating means calculates a positional difference between the position of a selected code element in the first scan and the position of the selected code element in the second scan to provide a calculated offset for use with the third scan. An alignment is subsequently performed for the first and second scans based upon the alignment of a leading edge or trailing edge of both the first and second scans. When there has been at least three scans of the bar code, the second position calculating means calculates a positional difference between the position of a selected code element from the combining and accumulating means and the position of the selected code element from a successive scan of a portion of the code. The offset averaging means averages previously calculated offsets with the positional difference calculated by the second position calculating means to provide a refined calculated offset for use with successive scans. The position aligning means also includes means for determining the expected position of the selected code element in the third and successive scans and means for locating a code element in the third and successive scans which most closely matches the expected position of the selected code element. The expected position is determined by applying the calculated offset from either the first position calculating means for the third scan or the offset averaging means for all other successive scans. Preferably, the code element selected is a bar which has been seen in at least two scans. The third and successive scans are subsequently aligned with the previous scans based upon the calculated offset or the refined calculated offset. An alignment verification is performed to ensure the alignment of the previous scan and the present scan. If, however, the alignment is not proper, additional alignments are attempted. The data processing means may include means for positionally aligning signal identification data in the combining and accumulating means with the signal identification data of a successive scan; means for identifying width mismatches between aligned signal identification data; and means for retaining the signal identification data which has been identified as having width mismatches. The signal identification data is aligned based on the position of the selected code element in the combining and accumulating means and the code element that most closely matches the position of the selected code element in the successive scan. Also, the combining and accumulating means cooperates with the mismatch identifying means such that mismatched signal identification data is not combined and accumulated. Mismatches are addressed by the mismatch resolving means which resolves the mismatches by comparing the width data from three scans of signal identification data. The first and third scans and the second and third scans of signal identification data are compared to determine which scan pair has consistent data. An indicating means is provided so that the signal identification data for the scans having consistent width data is combined in the combining and accumulating mean, and the data for the scan associated with the inconsistent data is ignored. In addition, the data processing means includes identifying means for identifying a first area where signal identification data is to be accumulated and a second area where such data is not to be accumulated. Signal identification data is compared by first and second comparing means to determine if the data overlaps the first or second areas respectively. The second area may be an area containing machine readable code that is not to be decoded. The scanning means may include at least one, or a plurality, of light source and sensing means. The light source and sensing means successively illuminates a machine readable code with a predetermined pattern of light and successively senses the light reflected from the code and may include a coherent light source. The scanning means may include a light directing means for directing the light from the coherent light source to create the predetermined pattern of light. BRIEF DESCRIPTION OF THE DRAWING FIG. 1 is an elevation view of an overhead omni-directional scanner as shown in the prior art; FIG. 2 is an elevation view of the scanner of the present invention in an overhead conveyer belt scanning application; FIG. 3 is a schematic perspective diagram of the interrelating parts of the light source and sensing means that may be used in one embodiment of the present invention; FIG. 4 is a schematic block diagram of the data processing an signal processing means that may be used in one embodiment of th present invention; FIG. 5 shows the data format used in one embodiment of th signal processor of the present invention; FIG. 6 is a plan diagram which shows successive scans acros a bar code; and FIGS. 7(a)- 7(g) are flow charts of the sequence of operation for the microprocessor of the present invention; DESCRIPTION OF THE PREFERRED EMBODIMENT There is shown in FIG 2, scanning device 100 illustrative o the present invention. One use of the scanning device is to sca for bar codes on boxes 102 traveling on a conveyer belt 104 movin in direction 106. The scanning device 100 includes an optics mean 108 and an electronics means 110. The optics means 108 illuminate the moving boxes 102 with coherent light, senses the reflecte light from the bar codes and provides an output signa representative of the reflected light along line 112 to th electronics package 110. Preferably, the output signal provide has been digitized using techniques well known in the art. Also illustrated in FIG. 2, is another embodiment of th optics means of the present invention which includes an additiona optic means 108 disposed to scan the side of a moving box 102. Th optical means may be positioned about the travel path of the movin 14 item to optimally detect a bar code affixed to any exposed surfa of the item. The electronics means 110 processes the optics means outp signals and outputs a signal representative of the informati encoded in each bar code scanned. Preferably, an electronics mea 110 is provided for each optics means 108. As shown in FIG. 3, an optics means 108, includes a cohere light source and sensing assembly 120 and a rotating mirror polygon 122. The mirrored polygon 122 preferably has eig reflective sides or facets and is rotated by a brushless DC mot (not shown) . The speed of the motor determines the scan or swe speed of the incident coherent light 128 illuminating the bar cod The optics means 108 preferably includes two or more cohere light source and sensing assemblies 120. By appropria positioning of the coherent light and source and sensing assembli 120 in the optics means 108, the polygon 122 can be used to swe the light from each source and sensing assembly 120. The number source and sensing assemblies 120 depends upon the resolution bar elements desired and the scan pattern to be used. For exampl if four source and sensing assemblies 120 are used, the opti means can scan 15 mil and larger bars whereas an optics means wi two source and sensing assemblies can scan 20 mil and larger bars The source and sensing assembly 120 includes a coherent lig source 124 such as a laser diode which emits light of 6 nanometers. The light from the source 124 is focused by a le assembly 126 so the incident light 128 is focused at a predetermined focal plane. In this way, a bar of a prespecified width is optimally illuminated at some distance above or below this plane. The distance that a bar is optimally illuminated, or is in focus, has been commonly referred to as the depth of field for a scanning device. The light exiting the lens assembly 126, is reflected by the bounce mirror 130 through an aperture 132 in the center of the return mirror 134 to the rotating polygon 122. For clarity, the incident light 128 is depicted as a solid line and the return light 142 (i.e., light reflected by the bar code) as a dashed line. The incident light 128 from the bounce mirror is reflected by one of the reflective sides of the rotating polygon 122 and redirected to the splitter mirror 136, having two mirrored faces 138a,b. The faces 138a,b form an obtuse angle facing the polygon 122. Rotation of the polygon 122 sweeps the coherent light across the peak of the splitter mirror 136 between the faces 138a,b, such that the light is reflected left or right from the splitter mirror. The light reflected from the splitter mirror 136 is then reflected by one of the alignment mirrors 140 depending upon which direction the light is reflected from the splitter mirror 136. Depending upon the direction taken by the light reflected by splitter mirror 136, one or more of the branches of an "X" scan pattern is produced on the bar code. The return light 142 is representative of the dark and light areas of the bar code illuminated by the sweeping incident light 128. The return light 142 from the bar code is reflected by th splitter mirror 136, the alignment mirrors 140 and the rotatin polygon 122, to return mirror 134. The return light 142 is the reflected by the return mirror 134 to a second lens assembly 14 which focuses the return light 142 onto a sensor 146. The senso 146 may be a photodiode, however, it may be any device known in th art which can sense light intensity and provide an output signa representative thereof. The output from the sensor 146 i amplified by a preamplifier (not shown) and a digitized by digitizer board (not shown) before it is transmitted over line 11 (shown in FIG 2) to the electronics means 110 (shown in FIG 2) fo processing and decoding. As shown in FIG. 4, electronics means 110 has two parts; data microprocessor 150 and an optical signal processor 152. Th signal processor 152 receives the digitized representation of th reflected light signal from the optics means sensor 146, FIG. 3 and processes it such that data representative of the light an dark is provided to the data microprocessor 150. The dat microprocessor 150 takes the data as it is received and processe it, as explained further below, to reconstruct the scanned ba code. Once the bar code is reconstructed, the microprocessor 15 decodes the bar code and outputs the decoded information to controller board (not shown) . The signal processor 152 includes a programmable array logi (PAL) 154, a transition counter 156, a position counter 158, system clock 160, a sweep counter 162, a position clock 164, an 17 two first-in/first-out (FIFO) buffers 166a,b. The optics mean output signal is provided over line 112 (FIG 3) to both the PAL 15 and the position counter 158. The position clock 164 is provided to the position counte 158. The position counter outputs position data on every bar an space in the scan to the FIFO buffer 166b. The position counte also outputs to the FIFO buffer 166b a flag which indicates whethe the data contained in the other buffer 166a, associated with th data from the position counter, is either a bar or a space (i.e. a black or white flag) . The polygon drive motor 123 provides encoder pulses and a ho pulse to the sweep counter 162. The sweep counter 162 outputs a end of sweep signal to PAL 154 and to counter 158 so new data fro another sweep can be accumulated. The home pulse is used t synchronize the sweep count with the beginning of the swee pattern. The transition counter 156, using input from the system cloc 160 and the PAL 154, outputs width data for each bar and space t the FIFO buffer 166a. The PAL 154 provides an output signal to th transition counter 156 to reset the transition counter 156 afte each transition. The FIFO buffers i66a,b store corresponding width and positio data until it can be sent to the microprocessor 150 for furthe evaluation and processing. When the microprocessor 150 wan another batch of data, the PAL 154 is directed to transfer dat from the FIFO buffers I66a,b to the microprocessor 150. In t present invention, data is transferred directly to the microprocessor memory 168 from the FIFO buffers 166a,b. The amount of information in the FIFO buffers at any time is dependent upon the processing speed of the microprocessor 150 and the number of bar codes being read by the optics means 108. The foregoing description of the signal processor 152 has been provided for illustrative purposes, as there are other techniques and equipment known in the art which can be used to output a signal representative of light and dark areas of a bar code and their respective positions to a microprocessor. FIG. 5 illustrates the data output 172 from the signal processor to the data microprocessor. The bits in the first fifteen fields, in the first region 174, reflect the count of bars or spaces (i.e., width data). The bit in the sixteenth field, in the second region 176, indicates whether the data in the first fifteen fields is for a bar or space. The remaining fields, the third region 178, contain bits representative of the position of the bar or space from the beginning of the sweep. As shown in FIG. 6, when a bar code 190 moves under a scanner at an angle to the scan line, the bar will be swept with a number of coherent light beams 192. Each beam 192 will intersect different regions of the bar code where each region represents a segment of the bar code. As can be seen from FIG. 6, the sweeps of the bar code segments overlap. In addition to intersecting different regions, the coherent light beams 192 also intersect the same bar code element at different points. The actual number of sweeps of a bar code is dependent upon the speed at which the bar moves under the scanner and the height 194 of the bar code. It is a reasonable assumption, particularly for conveyer belt applications, that each bar code 190, as it passes under the scanner, maintains a fixed angle relative to the scanner's scan line and the bar code velocity remains effectively constant. If the bar code maintains a fixed angle and a constant speed, data will appear to move along the scan line at a constant rate. Thus, the points at which the different sweeps of coherent light intersect a bar code element are spaced equidistant. The reconstruction methodology of the present invention takes advantage of the constant rate of movement to overlay the codes segments in their correct alignment. Whether a margin is leading or trailing depends on the sweep direction. Either margin is intersected by at least the first two sweeps of coherent light from the scanner. The code segments from the first two scans are aligned by using the margin. If the margins are not aligned with the use of the leading edges, then another attempt to align is performed with the use of the trailing edges. Next, a bar is selected and the distance that the bar appears to move along the scan line between the first two sweeps is determined. This distance information is used to calculate an offset to align the code segments of the subsequent sweeps. This calculated offset is further refined by using positional information from subsequent sweeps. The third and successive scans are subsequently aligned with the previous scans based upon the refined calculated offset. An alignment verification is performed to ensure the alignment the previous scan and the present scan. If, however, the alignme is not proper, additional alignments are attempted. Data width mismatches between the first two sweeps a identified by comparing the position aligned segments to see there is an inconsistency in the width values for the bars a spaces. These mismatches are resolved by comparing the data fr the third sweep with data from the first two sweeps. If there a two good data widths, the third is ignored as being bad data. On the bar code width data has been completely assembled, the bar co is normalized into the four possible widths and decoded just though the bar code had been scanned in the traditional meth (i.e., scanned in it's entirety). The benefits of this methodology include making full use all redundant bar and space information. This procedure avoids t uncertainties inherent in pattern matching techniques, and automatically eliminates human readable information. As indicat above, redundant bar and space information is required f reconstructive methodologies to assure the correct determination bar and space widths for decoding. Human readable informatio such as printed letters and numbers, are non-linear entities whi will not align correctly, and will remain unresolved mismatche As such, it is automatically excluded from the accumulated bar co data of the present invention. The methodology of the present invention does not requi checksums or fixed length checks of the decoded bar code. In th way, bar codes can be decoded faster and there is no dependency upon knowing in advance which bar codes are to be scanned. In addition, the scanning device of the present invention can reliably read bar codes which are smaller (i.e., have a smaller aspect ratio) than those used previously. There is shown in FIGS. 7(a)- 7(g), a flow chart of the sequence of operations for the data microprocessor 150 (FIG. 4) to positionally align the code segments for reconstruction, resolve width mismatches, combine sweep data, and to decode the bar code after it has been completely reconstructed. It should be recognized, when reading the following, that either end of the bar code may be seen first by the scanning device's sweeping coherent light. While the flow-chart is best explained by describing the sequence of operations as if a single bar code is being read and decoded at a time, the scanning device of the present invention can scan and read a plurality of bar codes at the same time. The scanning device also can decode one bar code while simultaneously accumulating data for other bar codes. At the start of the process, step 200, the counters and other parameters are initialized, step 202. Following the start an initializing of parameters, steps 200,202, the scanning device is in continuous operation. Thus, while the process may "end" as i pertains to an individual bar code, the device and its operations continue to operate automatically (i.e., there is no end to th flow chart) . After initializing, step 202, the video data DMA status is evaluated to determine if a scan or next scan is available, step 204. If a scan or next scan is not available (NO), step 204 is repeated until a scan is available. When a scan is available (YES) , step 204, the raw data is the evaluated to see if there is a possible bar code segment in the data. This process starts at the beginning of the scan or the en of the last identified segment, step 206. First, the raw data is evaluated to find the next group of transitions where eac transition in the group is less than a preset maximum bar/space an greater than a preset minimum bar/space. Next, the group of transitions found is checked for any adjacent pairs which have a ratio of greater than six to one or less than one to sixs (i.e. fo a true bar code margin typically white divided by black is greate than ten to one) . This helps to further segment the data and th first group of transitions found becomes the present segment. Before further processing, the code segment is reduced, i necessary, such that it always starts and ends with a bar. Durin all of the processing for finding bar code segments, the transitio group must have greater than a preset number of transitions t remain under consideration. The segment found will, hereinafter, be referred to as the present segment unless reference is bein made to particular sweeps. If a segment is found (YES), step 208, then it is evaluated t see if the segment position overlaps into an established ignor area, step 210. If a segment is not found (NO), step 208, then th process begins to cycle through the list of active areas, step 260. When reading multiple bar codes simultaneously, the segment foun will be associated with a known active acrea or will initiate a ne active area. Active areas are those regions of the item that pas under a scan line containing a bar code the user wants decoded. Ignore areas are those regions containing bar codes that the use does not want to decode. The present segment is next evaluated for overlap into a ignore area, step 210, by comparing the start and end positions o the segment with known areas that are ignored (see steps 246,248). If the present segment, or a portion thereof, is found to overla an ignore area, a match is found and the process returns back t step 206, to identify further possible bar code segments. If the present segment does not overlap an ignore area (NO) , step 210, the segment is then evaluated to see if it overlaps a established active area, step 212. This is done by comparing th segment start and end positions with the known active areas. I the position of the data for the present segment is found to b located completely or partially in an active area, the segmen overlaps the active area and a match is found. If an active area overlap match is not found (NO), step 212 then the active area list (i.e., active data files) is updated step 214. In this step a new active area structure, includin associated address pointers, is created by using information fro the present segment to identify a new active area. Once the activ area list is updated, the process returns to step 206, to identif further possible bar code fragments. If an active area overlap match is found (YES), step 212, present segment is evaluated to determine if it is the sec segment, step 216. If the present segment is the second segm (YES) , then the process continues by attempting to align leading and trailing edges of the first and second segments, s 238. If the present segment is not the second segment (NO), sweep direction from the active area structure is evaluated to if it is reversed, step 218. Since a bar code 190 can approach the scan line 192 at angle, and since there may be multiple bar codes being read o single item, it is quite likely that bar codes will be oriented that one is being scanned trailing edge first and another lead edge first. The first and second segments are compared with leading edge lined up and then with the trailing edge line up, s 238. The sweep direction (i.e., forward or reverse) is establis by determining which comparison, leading edge or trailing edge, the least amount of mismatches. The sweep direction is a retained, in the active area structure, so it can be used identify the sweep direction for future sweeps of the active ar The true barcode quiet-zone margins are verified by the mar verification test. The margins are not considered verified if segments do not compare to within a preset mismatch limit when edges are aligned. If the existence of margins cannot be verif (NO), step 240, then the process returns to step 206, to ident possible bar code segments. If margins are found (YES) , step 240, then the data segment are reviewed to determine if a valid start code or a valid sto code is next to the verified margin, step 244. If no valid start o stop code is found next to the margin (NO) , then the proces returns to step 206, to identify possible bar code segments. If a valid start or stop code is found (YES), step 244, the a determination is made whether the code is one of the symbologie the user is interested in having decoded, step 246. It is no unusual for an item to have a number of bar code labels affixed t its exposed surfaces. As such it is desirous to have the bar cod scanner automatically suppress extraneous bar codes so time an money is not wasted trying to accumulate unwanted information. If the bar code symbology is one of the ones the user is no interested in (NO) , step 246, the area is removed from the activ area listing and added to the ignore area list, step 248. In thi way, future scans containing the unwanted bar code will b automatically eliminated early in the process when a presen segment is evaluated for overlap into an ignore area, step 210. If the bar code symbology is one of the types the user i interested in (YES) step 246, then the already established swee direction for both the first and second sweeps is reviewed t determine if the sweep direction is reversed, step 250. If th sweep direction is reversed (YES) , then the data for the first an second segments is reversed, step 252. This orders the first an second data for future evaluation and processing. After reversing the data, step 252, or if the sweep directio is not reversed (NO) , step 250, the mismatches between the aligned first and second segments as identified in step 238 are stored in a mismatch array, step 254. Each bar and space of the aligned segments are compared to identify bars and spaces which have inconsistent widths (i.e., width mismatches). The mismatched bars and spaces are identified and the associated data, from both the first and second segments, is stored in a mismatch array. The mismatched bar elements are identified so the associated data is not accumulated until the mismatch has been resolved. Concurrently a review is made to determine how many sweeps a bar has been seen in. The number of sweeps seen, for each bar, is stored in the active area structure (i.e., the sweeps per bar array). This information is used later for alignment purposes. The positional difference between the position of the second bar in the first sweep and the position of the second bar in the second sweep is calculated, step 256. The calculated difference is used to determine the positional location of a bar in future sweeps, as explained below, and to calculate any further offset values for sweep alignment. The alignment of the first and second sweeps was determined by the margin verification, step 240. The data for each present segment is maintained in a sweep buffer until it is copied into the active buffer for accumulation of the bar code. After calculating the positional difference, the good width data for the first and second sweeps is added to the active buffer, step 258. In this respect, adding to the active buffer means combining the width data for overlapping bars and spaces to yield an average width value, and appending data no found in the first sweep, but found in the second sweep. Afte calculating the difference, step 256, and adding the coun information to the active buffer, step 258, the process returns t step 206, to identify possible bar code segments. By returning to step 206, more bar code segments, if presen in the current sweep of data, will be processed. However, thi active area will not process until the next sweep, at which time i will be the third sweep for this active area, and processing wil proceed to step 218. As indicated above (see step 250) , the sweep direction fo segments in a known active area is retained for future use. Thus for the third and subsequent segments of a known active area th sweep direction is determined by making reference to the retaine information. Therefore, after acquiring a third or subsequen segment (i.e., going through steps 206-216), the active are structure is reviewed to determine the sweep direction, step 218 If the sweep direction is reversed (YES) , the width data for th present segment is reversed or flipped for further evaluation an processing, step 220. . After reversing the data, step 220, or if the direction fo the present segment is not reversed (NO), step 218, an alignmen bar is selected from the active buffer and the previousl calculated position offset is applied, step 222. An alignment ba is selected by searching the active buffer, starting at the end o the buffer, until a bar (not a space) is found which has been se in at least 2 sweeps. Since mismatched data is not added to the active buffer, the selected bar is known to be a valid bar of the bar code. The previously calculated position offset is subtracted from the position of the alignment bar. The previously calculated offset is the difference calculated in step 256 when the present segment is the third segment for a given active area. Thereafter, the previously calculated offset is that determined from step 230 described below. Since the bar code is assumed to maintain a fixed angle relative to the scanner's scan line and a constant velocity through the scanner, the previously calculated offset represents the expected offset of the alignment bar along the scan line from the bar's position in the active buffer to the bar's position in the present segment. As a result, combining the offset with the alignment bar position yields the expected position of the alignment bar in the next sweep. The present segment is scanned for the expected position of the alignment bar, step 224. In this step the present segment is searched, beginning at the front end of the data, to find the position of the bar which most closely matches the expected position of the bar established by the calculation in step 222. After identifying the bar in the present segment, the difference between the bar's position in the present segment and the calculated position is determined. A window is set about the alignment bar to compare width data of the active buffer and the present segment to verify the positional alignment of the present segment with the active buffer, step 226. Beginning at the front edge of the window, five transitions (bars/spaces) are compared. The width values of the bars and spaces in the active buffer are compared with the width values of the corresponding bars and spaces in the present segment to determine if the width values are consistent. If the number of identified inconsistencies determined is less than a prespecified value, the positional alignment between the active buffer and the present segment is considered acceptable (i.e., verified) (YES), step 228. If an unacceptable number of inconsistencies is determined, alignment is not verified (NO) and the process continues to step 229(a). In a preferred embodiment, a maximum of four additional attempts are performed to place the present segment in alignment with the active buffer, steps 229(a) and 229(b). Specifically, the alignment bar of the present segment is compared with the bar to the left of the alignment bar in the active buffer, step 229(c). An alignment verification is performed, as described above, to ensure the alignment of the present segment and the adjacent transition in the active buffer, step 226. If the number of identified inconsistencies determined is less than a prespecified value, the positional alignment between the active buffer and the present segment is verified, step 228. If an unacceptable number of inconsistencies is determined, alignment is not verified (NO) and the process continues to step 229(a). If the alignment of the present segment and the active buffer is not verified, then a maximum of three additional attempts are performed to place the present segment in alignment with the active buffer. Specifically, the alignment bar of the present segment is compared with the bar to the right adjacent transition of the alignment bar in the active buffer. An alignment verification is performed, as described above, to ensure the alignment of the present segment and the active buffer. If the number of identified inconsistencies determined is less than a prespecified value, the positional alignment between the active buffer and the present segment is verified. If an unacceptable number of inconsistencies is determined, alignment is not verified (NO) and the process continues to step 229(a). If the alignment of the present segment and the active buffer is not verified, then a maximum of two additional attempts are performed to place the present segment in alignment with the active buffer. Specifically, the alignment bar of the present segment is compared with the second bar to the left of the alignment bar in the active buffer. An alignment verification is performed, as described above, to ensure the alignment of the present segment and the active buffer. If the number of identified inconsistencies determined is less than a prespecified value, the positional alignment between the active buffer and the present segment is verified. If an unacceptable number of inconsistencies is determined, alignment is not verified (NO) and the process continues to step 229(a). If the alignment of the present segment and the active buffer is not verified, then one additional attempt is performed to place the present segment in alignment with the active buffer. Specifically, the alignment bar of the present segment is compared with the second bar to the right of the alignment bar in the active buffer. An alignment verification is performed, as described above, to ensure the alignment of the present segment and the active buffer. If the number of identified inconsistencies determined is less than a prespecified value, the positional alignment between the active buffer and the present segment is verified. If an unacceptable number of inconsistencies is determined, alignment is not verified (NO) and the process continues to step 206, to identify possible new bar code segments. No further transitions are compared, and the present segment is eliminated from further processing. The number of alignment attempts made is matched to the system position accuracy and 'the apparent size of the smallest valid bar at the bottom of the depth-of-field. The system position accuracy is dependent on the position encoder, the drive motor, and the polygon's inaccuracies, and any corrections or calibrations for these inaccuracies. In a preferred embodiment, the cost of precise encoders, motors, and polygons is weighed against the need for reconstruction accuracy. The preferred embodiment's maximum of five total alignment attempts is based on the character size of most bar code symbologies (i.e. ten bars/spaces per Code 39 character) . However, alternative embodiments could use more precise system components and only allow one alignment attempt or use less precise system components and allow more alignment attempts as necessary. Increasing the number of alignment attempts allowed will increase the likelihood of bar code mis- reconstruction. In one embodiment, in order to enable a precise alignment on the first alignment attempt, an MRC, Inc. custom made, diamond machined, eight sided, scanner polygon is precisely mounted on a BEI, Inc. custom made motor. The motor has a BEI, Inc. standard one thousand pulse encoder mounted on it. This assembly is utilized to rotate the mirrored polygon 122 and to track the position of the polygon. The MRC, Inc. polygon is machined to a tolerance of less than 27 arc seconds and mounted to the motor shaft to a tolerance of less than 27 arc seconds. The motor enables the polygon to rotate at such speeds as 3600 rpm, with a minimum of precessional motion of the polygon. The motor's speed is controlled by an external circuit which maintains it to within 5% of 3600 rpm. These precision components stabilize the timing and therefore the perceived position of the return signal from the bar code to an accuracy of 250 nanoseconds. The return signal timing is further measured and compensated for by the digital processor 150. The encoder is attached to the motor to enable the signal processor 152 to report the position of the rotating polygon when a transition (bar/space) occurs. The encoder's pulse-to-pulse accuracy is approximately 600 nanoseconds. The encoder's home- pulse to home-pulse accuracy is approximately 300 nanoseconds. The encoder's pulse-to-pulse variance is further measured an compensated for by the digital processor 150. This is accomplishe by measurement of the end-of-sweep timing and the calculation of position correction factor. The final resulting inaccuracies ar less than 200 nanoseconds which is approximately 26 arc seconds o system position readout error. If the alignment performed above is verified (YES) , step 228 an average offset value is then calculated, step 230. The averag offset value is established by determining the positional variatio between the alignment bar in the present segment and the activ buffer. This difference is averaged into the previously calculate position offset to yield a current position variation or offset This current position offset is then used for subsequent sweeps i a similar manner as the previously calculated offset was used i step 222. Using the data from the third segment, data matches betwee the first and second segments are resolved by using the new data t out vote the bad data, step 232. Specifically, the width data fo the first and third segments and width data for the second an third segments, associated with the mismatched bars and spaces, i compared to identify which segment pair (e.g., first and thir segments) has consistent data. This data pair is then used t determine which data from the first and second segments shall b ignored (i.e., bad data is out voted by the matched segment pair) This evaluation is made for each of the identified mismatches. The active buffer and the present data segment are reviewed t determine if there are any new mismatches, step 234. The new and active data are compared to see if there are any width values for bar or spaces which appear inconsistent. After reviewing the data, any new mismatches are identified and stored in the mismatch array for future resolution. After updating the active data files to reflect the good information, the process returns to step 206, to identify possible bar code segments. The process between step 206 and step 236 is repeated for an active area until its bar code passes out from under the scan line of coherent light. While a minimum of three scans are needed to resolve mismatches, step 232, there should preferably be 4 scans of the bar code before it passes out from under the scan line. When a present segment is not found, step 208, the list of active areas is cycled through to perform a set or series of actions (i.e., steps 260-272). The list of ignore areas is also cycled through to perform another set or series of actions (i.e., steps 274-278) . Both are done to determine if an active or ignore area has passed out from under the scan line; so that the reconstructed bar code is decoded; and/or the active area list updated to remove unneeded data. After either or both sets of actions are completed, the process returns to step 204, to determine if another scan or sweep of data is available. The active areas are cycled through, step 260, to determine if a completed bar code has been formed, step 262, to normalize data if a complete code has been formed, step 264, decoding the bar code and outputting the decoded information, steps 266, 268, and removing data from the active area list after the active buffer has been decoded, steps 270-272. To decode the information the width data accumulated is processed to normalize the data into 1, 2, 3, and 4 wide bars and spaces, an industry standard practice, step 264. After cycling through the active areas, the ignore areas are then cycled through to determine if an ignore area has passed out from underneath the scan line, step 276, and if yes, the data associated with this ignore area is removed from the data structure, step 278. While a preferred embodiment of the invention has been described using specific terms, such description is for illustrative purposes only, and it is to be understood that changes and variations may be made without departing from the spirit or scope of the following claims. What is claimed is: file: SD GEN.H page: 1 date: Tue Jun 08 10:24:16 1993 line 0001 /* Header: sd_gen.h */ 0002 0003 /* version string defines */ 0004 #define SD GEN H NET "Net SModtime: 29 May 1993 15:35:48 $" 0005 ΛJefine SD GEN H LOC "Local $Id: sd gen.h 1.1893/05/29 15:35:48 dan Exp $" 0006 0007 /* operating modes */ 0008 -■define DECODE 1 /* decode mode */ 0009 #define STANDBY 2 /* standby mode */ 0010 #define DEBUG 3 /* debug mode */ 0011 #define PROGRAM 4 /* program mode */ 0012 #define DIAGA 5 /* diagnostic mode a, continuous scan dump */ 0013 #define DIAGB 6 /* diagnostic mode b, one-shot scan dump */ 0014 #define DIAGC 7 /* diagnostic mode c, continuous straight read */ 0015 #define DIAGD 8 /* diagnostic mode d, percent straight read */ 0016 #define DIAGE 9 /* diagnostic mode e, continuous tsd */ 0017 tfdefine DIAGF 10 /* diagnostic mode f, percent tsd read */ 0018 tfdefine DIAGG 11 /* diagnostic mode g, straight read with dump */ 0019 tfdefine I VISO0 12 /* invisible mode 0 */ 0020 #define INVIS01 13 /* invisible mode 1 */ 0021 #define INVIS02 14 /* invisible mode 2 */ 0022 #define INVIS03 15 /* invisible mode 3 */ 0023 #define INV1S04 16 /* invisible mode 4 */ 0024 #define INVIS05 17 /* invisible mode 5 */ 0025 #define INVIS06 18 /* invisible mode 6 */ 0026 #define I VIS07 19 /* invisible mode 7 */ 0027 #define LEARN 20 /* learn mode */ 0028 #define POLY CAL 21 /* one-time, one-barcode-position polygon calibration */ 0029 0030 /* code types */ 0031 #define C39 0x01 /* code 39 code type */ 0032 #define UPCA 0x02 /* UPC A code type */ 0033 -■define UPCE 0x03 /* UPC E code type */ 0034 #define 125 0x04 /* interleaved 2 of 5 code type */ 0035 #define C128 0x05 /* code 128 code type */ 0036 #define EAN13 0x06 /* EAN 13 code type */ 0037 #define EAN8 0x07 /* EAN 8 code type */ 0038 #def ne CODABAR 0x08 /* codabar code type */ 0039 #define C93 0x09 /* code 93 code type */ 0040 #define CODE OFF 0x10 /* if code is turned off */ 0041 0042 /* video data fields 0043 #define BLACK BAR 0x00000000 /* value of black bar in video data (bit 16 only) */ 0044 0045 /* direction */ 0046 #define F O 0x00 /* fouard */ 0047 #define REV 0x01 /* reverse */ 0048 0049 /* label format options */ 0050 #define SHORT .ABEL 1 0051 ødefine LONG .ABEL 2 0052 0053 /* mismatch detection options */ 0054 #define MMPCT 1 0055 #define MMLIM 2 0056 0057 /* hardcoded addresses */ 0058 #define CONTROLLER_ENABLE ((unsigned int *)0x0009ff04) /* controls decoder-to-controller messaging */ 0059 #define PROG SIZE ((unsigned int*)0xE007FFC4) /* size of prog saved in flash */ 0060 #define BEG_RAM ((unsigned int*,0x00020000) /* beginning of ram */ 0061 #define ROM START ((unsigned int*)0xE007FFD0) /* pointer to ro start */ 0062 #define DL NEEDED ((unsigned int*)0xE007FFC8) /* indicate download needed */ 0063 #define DL~WANTED ((unsigned int*)0xE007FFCC) /* indicate download wanted */ 0064 #define FLASH_12V_0N ((unsigned int*)0xD0080000, /* turn on 12v to flash */ 0065 #define FLASH 12V~0FF ((unsigned int*)0xD0000000. /* turn off 12v to flash */ 0066 0067 0068 /* BOOL yes/true/on */ 0069 /* BOOL no/false/off */ 0070 /* BOOL yes/true/on */ 0071 /* BOOL no/false/off */ 0072 /* BOOL yes/true/on */ file: SO GEN.H page: 2 date: Tue Jun 08 10:24:16 1993 line 0073 tfdefine OFF (0) /* BOOL no/false/off */ 0074 #define OK (1) 0075 #define EOF (-1) 0076 0077 /* ASCII I 0078 BKSPACE \x08' 0079 BELL '\x07' 0080 CLS 1 \x0c' 0081 SPACE • \x20' 0082 TAB ■ \x09' 0083 CTL A ■ \x01' 0084 CTL~B •\x02' 0085 CTL~C '\x03' 0086 CTL~D ■ \x04' 0087 CTL E '\x05' 0088 CTL F •\x06' 0089 CTL~G •\x07' 0090 CTL~H ■ \x08' 0091 CTL I •\x09' 0092 CTL~J •\x0A' 0093 CTL~K '\x0B' 0094 CTL~L '\x0C' 0095 CTL_M '\x0D' 0096 CTL N '\x0E' 0097 CTL " O ■ \x0F' 0098 CTL P '\x10' 0099 CTL~Q ■ \x11 ' 0100 CTLJ? '\x12' 0101 CTL S '\x13' 0102 CTL T '\x14- 0103 CTL~U •\x15' 0104 CTL~V '\x16' 0105 CTL~W ■ \x17' 0106 CTL~X •\x18' 0107 CTL~Y •\x19' 0108 CTL^Z '\x1A' 0109 NUL '\x00' 0110 SOH ■ \x01' 0111 STX •\x02' 0112 ETX '\x03' 0113 EOT '\x04' 0114 ENQ '\x05' 0115 ACK ■ \x06' 0116 BEL '\x07' 0117 BS '\x08' 0118 HT '\x09' 0119 LF ■ \x0A' 0120 VT 1 \x0B' 0121 FF 1 \x0C' 0122 CR '\x0D' 0123 SO ■ \x0E' 0124 SI '\x0F' 0125 DLE ■ \x10' 0126 DC1 '\x11' 0127 DC2 '\x12' 0128 DC3 '\x13' 0129 DC4 •\x14' 0130 NAK ■ \x15' 0131 SYN '\x16' 0132 ETB ■ \x17' 0133 CAN •\x18' 0134 EM ■ \x19' 0135 SUB '\x1A' 0136 ESC •\x1B' 0137 FS '\x1C 0138 GS •\x1D' 0139 RS •\X1E' 0140 US •\x1F' 0141 SP •\x20" 0142 0143 / ****************** STRUCTURES ** * * * **** * ********************************* / 0144 file: SD GEN.H page: 3 date: Tue Jun 0810:24:161993 line 0145 - #define ASCII ARRAY SIZE size of ascii array for label in bytes */ 0146 - #define CHECKSUM ARRAY SIZE size of checksum array for label in bytes */ 0147 - #define NBS SIZE size of normalized bar/space array in bytes */ 0148 - #define ACTΪVE SIZE size of active data buffer */ 0149 - #define MM_SIZE size of mismatch array */ 0150 - 0151 - typedef struct { 0152 - unsigned int num; /* number */ 0153 - char flag; /* flag indicating validity of number */ 0154 - } FLAGGED iUM; 0155 - 0156 - typedef struct { 0157 - unsigned int val[3.; 0158 - > DATA_ARRAY; 0159 - 0160 - typedef struct { 0161 - unsigned int *first_sweep_start; /* start of raw data in first sweep */ 0162 - unsigned int *first_sweep_end; I* end of raw data in first sweep */ 0163 - unsigned int sweep_count; /' sweeps for this active area */ 0164 - unsigned int spb_lock; /* sweeps per bar to lock value */ 0165 - unsigned int fragment_count; /" count of fragments for this area in current sweep 0166 - unsigned int reject_count; /* count of continuously rejected sweeps */ 0167 - unsigned int align_status; I- alignment status of this area for this sweep */ 0168 - int offset_posi ion; / ■ true position offset from sweep to sweep */ 0169 - int offset_pos_of_rej; / ■ sum of position offset from rejected sweeps */ 0170 - char code_direction; /" label scan direction */ 0171 - char sweep_direction; /" label cut direction */ 0172 - char bars_found; /" bars found in active area */ 0173 - unsigned int empty_sweeps; /' number of sweeps with no fragment */ 0174 - char code_type; /" type of start/stop code found */ 0175 - char ss found; /' start/stop code found in active area */ 0176 - unsigned int *ιmi_ptr[MM_SlZE]; ' mismatch pointers */ 0177 - DATA_ARRAY irni dataCMM SIZE]; I- mismatch data */ 0178 - unsi ned int πm_spb[MM_SIZE]; / ■ mismatch data sweeps per bar */ 0179 - unsigned short start_position; /' last fragment starting position */ 0180 - unsigned short end_position; /' last fragment ending position */ 0181 - unsigned short new_start_pos; /' new fragment starting position */ 0182 - unsigned short new_end_pos; /' new fragment ending position */ 0183 - unsigned int *active_start; /' start of active data in buffer */ 0184 - unsigned int *active_end; /' end of active data in buffer */ 0185 - unsigned int sweeps_per_bar[ACTIVE SIZE]; /* sweep count per bar buffer */ 0186 - unsigned int active buffer[ACTIVE SIZE]; /* active data buffer */ 0187 - } C_PARMS; 0188 - 0189 - typedef struct { 0190 - unsigned short start_position; /* barcode starting position */ 0191 - unsigned short end_position; /* barcode ending position */ 0192 - unsigned short new_start_pos; /* barcode starting position */ 0193 - unsigned short new_end_pos; /* barcode ending position */ 0194 - char bars found; /* bars found in ignore area */ 0195 - > I_PARMS; 0196 - 0197 - typedef struct < 0198 - unsigned int *active_ptr; /* alignment pointer for active data */ 0199 - unsigned int *new_ptr; /* alignment pointer for new data */ 0200 - ALIGNMENT; 0201 - 0202 - typedef struct C 0203 - char *nbs_start; /* start of 2 wide normalized data 0204 - char *nbs_end; /* end of normalized data */ 0205 - char nbs_array[NBS SIZE]; /* normalized data buffer */ 0206 - > NORMALIZE2; 0207 - 0208 - typedef struct { 0209 - char *nbs_start; /* start of 4 wide normalized data 0210 - char *nbs_end; /* end of normalized data */ 0211 - char nbs_array[NBS SIZE]; /* normalized data buffer */ 0212 - ) NORMALIZE4; 0213 - 0214 - typedef struct t 0215 - unsigned int buffer[ACTlVE_SIZE]; /* buffer for data */ 0216 - unsigned int *start; /* pointer to start of data */ file: SD_GEN.H page: 4 date: Tue Jun 0810:24:16 1993 line 0217 unsi ned int *end; /* pointer to end of data */ 0218 } POINTED_BUF; 0219 0220 typedef struct { 0221 unsigned int *scan_start; /* start of count data */ 0222 unsigned int *scan_end; /* end of count data */ 0223 unsigned int *data_start; /* start of barcode data */ 0224 unsigned int *data_end; //** end of barcode data */ 0225 unsigned int facet; //** facet number of sweep */ 0226 int pos_correction; /* relative position of this facet to last */ 0227 int empty_buffer; /* no data in sweep buffer */ 0228 int eos_glitch; /* end-of_sweep glitch detected */ 0229 unsigned int bad finaT_pos; /* bad final position detected */ 0230 COUNT DATA; 0231 0232 typedef struct { 0233 char position; /* 8MSB of label position (must be first for interboard msg) 0234 char code type; /* barcode type (must be second for interboard msg) */ 0235 char labeT_buf[ASCII_ARRAY_SIZE] /* ascii encoded label (must be third for interboard msg) */ 0236 char code_direction; /* code direction */ 0237 char sweep_direction; /* sweep direction */ 0238 char label valid; /* flag to signal a label was loaded */ 0239 unsigned short full_position; /* all 15 bits of label position */ 0240 > LA3EL_DATA; 0241 0242 - typedef struct { 0243 char checksum buf[CHECKSUM_ARRAY SIZE]; 0244 } CHECKSUM_ARRAY; 0245 0246 - typedef struct MSG_STRUCTt 0247 char msg_type; /* message type from controller */ 0248 char not_used; /* padding */ 0249 unsigned short msg_length; /* message length */ 0250 char message[1024]; /* message buffer */ 0251 >; 0252 0253 - /* general global variables */ 0254 0255 - /* general output buffer */ 0256 - extern char out_buf[]; 0257 0258 - /* label buffer */ 0259 - extern LABEL_DATA label_struct; 0260 0261 - /* checksum buffer */ 0262 - extern CHECKSUM_ARRAY checksum_struct; 0263 0264 - /* operating mode */ 0265 - extern char mode; 0266 0267 - /* main loop restart control */ 0268 - extern unsigned int restart; 0269 f i le: SD TSD .C page: 1 date: Sat Sep 11 13: 13:46 1993 0047 - /* active and ignore buffers */ 0048 - unsi gned int num_of_act_ptrs = NUM_OF_ACT_PTRS; 0049 - unsi gned int num_of igπ ptrs = NUM_OF IGN PTRS; 0050 - C_PARMS *active_ptrs [NUM OF ACT_PTRS]J 0051 - C_PARMS active structs [NUM_OF_ACT_PTRS] ; 0052 - I_PARMS "i gnore ptrs tNUMJDF IGN_PTRS] ; 0053 - I_PARMS ignore_structs [NUM_OF_IGN_PTRS] ; 0054 - 0055 - /* diagnostic counters */ 0056 - unsi gned int total_attempt_count = 0, total_success_count = 0, total_missed_sweeps = 0; 0057 - unsi gned int total_active_areas = 0, total_ignore_areas = 0, total_marg_al i gn_count = 0, total_ss_found_count 0058 - unsi gned int active_area_count = 0, i gnore_area_count = 0; 0059 - unsi gned int active_areas = 0, i gnore_areas = 0, marg_al ign_count = 0, ss_found_count = 0; 0060 - unsigned int sweeps_per_discard [10] , total_sweeps_per_discard[10] ; 0061 - 0062 - /* debug variables */ 0063 - POINTED_BUF save; 0064 - unsigned int active_area_number = Oxff; 0065 - unsigned int mismatch_count = 0; 0066 - unsigned int margin_align_status; 0067 - unsigned int align_attempt; 0068 - int new_offset; 0069 - unsigned int slice -ffset; 0070 - unsigned int active_align_key; 0071 - unsigned int new_align_key; 0072 - unsigned int align_key_size; file: SD TSD.C page: 2 date: Sat Sep 11 13:13:46 1993 line 0101 - restart = FALSE; 0102 - scan ;ount = 0; 0103 - 0104 - missed sweeps = total nissed sweeps = 0; 0105 - 0106 - if (diags flag) 0107 - { 0108 - attempt rount = total -ttempt ;ount = success -ount = total ;uccess :ount = 0; 0109 - total active areas = total_ignore -reas = total narg -ligπ ;ount = ϊotal ss_found ;ount = 0; 0110 - bs :ount .est abel = 0; 0111 - tot:al 3ad_f inaljsos = 0; 0112 - total ϊmpϊyjjuffer = 0; 0113 - total iome -esync = 0; 0114 - total -os jlitch = 0; 0115 - 0116 - for (i=0;i<10;i++) 0117 - sweeps jer -iscardli] = total >weeps -er -iscard[i] = 0; 0118 - ; rg -lign ;ount = ss_fouπd -ount = 0; t = 0; 0143 - for (i=0;i<NUM_OF_ACT_PTRS;i++) 0144 - activej-trs[i] = 0; f i le: SD TSD.C page: 3 date: Sat Sep 11 13: 13:46 1993 line 0145 - for (i=0;i<NUM_OF_IGN_PTRS;i++) 0146 - ignore ptrsCi = 0; 0147 - 0148 - 0149 - 0150 - */ 0151 - */ 0152 - TITLE - sd_find 3S, find bars and spaces */ 0153 - */ 0154 - INPUTS - cdjstr, pointer to raw data */ 0155 - */ 0156 - */ 0157 - OUTPUTS - true if bars and spaces found, false otherwise */ 0158 - also sets data jtart and data ϊnd in cd structure */ 0159 - */ 0160 - ABSTRACT - This procedure takes transition count data and */ 0161 - finds the beginning and ending of bar/space data. */ 0162 - */ 0163 - 0164 - char sd find bs(C0UNT DATA *cd_ptr) 0165 - C 0166 - unsigned int *intptr; 0167 - unsigned int six /al, six iext al; 0168 - unsigned short count, val, next al 0169 - char found; 0170 - 0171 - /* initialize count of acceptable bars/spaces */ 0172 - count = 0; 0173 - 0174 - /* begin looking at end of last barcode fragment */ 0175 - intptr = cd_ptr->data_end; 0176 - 0177 - /* while barcode not found and not end of scan */ 0178 - while ((count < find count || count > NBS SIZE) && intptr <= cdj_tr->scan end) 0179 - • 0180 - /* look for video transition within data limits */ 0181 - found = FALSE; 0182 - white ((intptr < cdj-tr->scan end) && (Ifound)) 0183 - { 0184 - /* extract transition */ 0185 - val = *intptr & OxOOOOffff; 0186 - 0187 - /* see if transition is within min/max data limits */ 0188 - if (val <= data max_threshold) 0189 - C 0190 - if (val >= data tiin threshold) 0191 - - 0192 - found = TRUE; 0193 - > 0194 - } 0195 - /* point to next transition */ 0196 - intptr++; 0197 - > /* end while Ifound */ 0198 - 0199 - /* if last test was successful */ 0200 - if (found) 0201 - - 0202 - /* set beginning of bars and spaces, reset bs count and found */ 0203 - cd 3tr->data 3tart = intptr - 1; 0204 - count = 1; 0205 - found = FALSE; 0206 - 0207 - /* look for video transi tion outside of data l imi ts */ 0208 - whi le ( ( intptr <= cdj-tr->scan >nd) && ( I found)) 0209 - { 0210 - /* extract transition */ 0211 - val = *intptr & OxOOOOffff; 0212 - 0213 - /* see if transition is outside min/max data limits */ 0214 - if (val > data_max_threshold) 0215 - i 0216 - found = TRUE; file: SD_TSD.C page: 4 date: Sat Sep 11 13:13:461993 line 0217 - > 0218 - else if (val < data min threshold) 0219 - i 0220 - found = TRUE; 0221 - 0222 - else 0223 - ( 0224 - /* transition is within limits so count it */ 0225 - count+=1; 0226 - > 0227 - /* point to next transition */ 0228 - intptr++; 0229 - > /* end while Ifound */ 0230 - > /* end if found */ 0231 - else 0232 - { 0233 - /* no bars and spaces found */ 0234 - return(FALSE); 0235 - } 0236 - 0237 - /* back up one transition to point at last transition within data limits */ 0238 - if (found) intptr--; 0239 - 0240 - /* check for 6 to 1 ratio within data if enough bars/spaces were found */ 0241 - if (count > find count && count < NBS SIZE) 0242 - ■ (. ~ 0243 - /* mark end of data found */ 0244 - cd atr->data ;nd = intptr - 1 ; 0245 - 0246 - /* point to beginning of data, reset bs count and found */ 0247 - intptr = cdj>tr->data >tart; 0248 - found = FALSE; 0249 - count = 0; 0250 - 0251 - /* look for 6 to 1 or 1 to 6 ratios */ 0252 - while ((intptr < cdj>tr->data end) && (ifound)) 0253 - 0254 - /* extract transition */ 0255 - val = *intptr & OxOOOOffff; 0256 - 0257 - /* six_val = 6 * (value) */ 0258 - six val = (val « 2) + (val « 1); 0259 - 0260 - /* extract next transition */ 0261 - next val = *(intptr + 1) & OxOOOOffff; 0262 - 0263 - /* six_next_val = 6 * (next value) */ 0264 - six next /at = (next val « 2) + (next val « 1); 0265 - 0266 - /* see if 6 to 1 or 1 to 6 is present */ 0267 - if (val >= six next val || next /al >= six val) 0268 - i 0269 - /* see if enough bars/spaces already checked out ok to call it a fragment */ 0270 - if (count >= find count && count <= NBS SIZE) 0271 - { 0272 - /* enough bs to call it a fragment */ 0273 - found = TRUE; 0274 - > 0275 - else 0276 - { 0277 - /* not enough bs for fragment so restart search */ 0278 - cd 3tr->data start = intptr + 1; 0279 - count = 0; 0280 - > 0281 - > 0282 - /* bump up count of transition checked */ 0283 - count++; 0284 - /* point to next transition */ 0285 - intptr++; 0286 - > /* end while Ifound */ 0287 - 0288 - /* if not found (i.e. end of fragment encountered) then include last transition as good */ file: SD TSD.C page: 5 date: Sat Sep 11 13:13:46 1993 line 0289 - if (Ifound) 0290 - { 0291 - intptr++; 0292 - count++; 0293 - > 0294 - 0295 - 0296 - /* set data end to last bar checked */ 0297 - cdjptr->dataj-nd = intptr - 1 ; 0298 - 0299 - /* make sure data begi ns and end wi th a bar */ 0300 - if (( (*cd_ptr->data_start & 0x00010000) ! = BLACKJ3AR) && 0301 - (cdj-tr->data 5tart < cd ptr->scanj-nd) ) 0302 - cdj tr->data start++; 0303 - i f (((*cdj-tr->data_end & 0x00010000) ! = BLACK_BAR) && 0304 - (cdj3tr->data _nd > cd_ptr->scan start)) 0305 - cdj-tr->data .nd-- ; 0306 - 0307 - /* recalculate good bs count */ 0308 - count = cdjDtr->data -nd - cd 3tr->data »tart + 1; 0309 - 0310 - > /* end of while count < findj-ount or > NBS_SIZE */ 0311 - 0312 - /* if enough bars and spaces found */ 0313 - if (count >= find count && count <= NBS SIZE) 0314 - C 0315 - return (TRUE); 0316 - > 0317 - else 0318 - C 0319 - /* not enough bars and spaces found */ 0320 - return (FALSE); 0321 - > 0322 - > 0323 0324 /* 0325 /* 0326 /* 0327 /* 0328 /* 0329 /* 0330 /* 0331 /* 0332 /* 0333 /* 0334 /* 0335 /* 0336 /* 0337 /* 0338 /* 0339 /* 0340 0341 /* local variables whi ch are too big for the stack */ 0342 C_PARMS *possible_ptr [NUM_OF_ACT_PTRS] ; 0343 unsi gned int possible -reajιum[NUM_OF \CT , TRS] ; 0344 0345 C PARMS *sd active area(COUNT DATA *cdj-tr) 0346 < 0347 unsigned short ne start, newj-nd; 0348 unsigned short correctedjiewjstart, corrected iew -nd; 0349 unsigned short activejstart, active end; 0350 C_PARMS "check j tr; 0351 unsigned int most sweeps; 0352 int i , j ; 0353 0354 /* setup for finding list of overlapping areas */ 0355 J = 0; 0356 0357 /* set position variables for fragment */ 0358 newjstart = (*cd jtr->datajstart) » 17; 0359 newj-nd = (*cd tr->data .nd) » 17; 0360 correctedjiewjstart = newjstart + cdj-tr->pos :orrection; file: SD TSD.C page: 6 date: Sat Sep 11 13:13:461993 line 0361 - corrected new end = new end + cdjtr->pos correction; 0362 - 0363 - /* scan list of active pointers and look for overlap */ 0364 - for (i = 0; i < num of actj-trs; i++) 0365 - 0366 - /* see if pointer is being used */ 0367 - checkj.tr = activej-trs[i]; 0368 - if (check jtr != 0) 0369 - { 0370 - /* set active area posi ti on vari ables */ 0371 - activejstart = checkj-tr->start 5osi ti on; 0372 - active end = check .tr->end posi ti on; 0373 - 0374 - /* look for overlap */ 0375 - if (active start >= correctedjiew start && activejstart <= corrected newjϊnd) 0376 { 0377 - /* store active area as a possible */ 0378 - possiblej3tr[j] = check .tr; 0379 - possible area num[j++] = i; 0380 - } 0381 - else if (active end >= corrected new start && active end <= correctedjiewj-πd) 0382 ■ i 0383 - /* store active area as a possible */ 0384 - possible itrlj] = checkjjtr; 0385 - possiblej.rea num[j++] = i; 0386 - } 0387 - else if (corrected new start >= activejstart && corrected newjstart <= active end) 0388 { 0389 - /* store active area as a possible */ 0390 - possiblej)tr[j] = check .tr; 0391 - possible area num[j++] = i; 0392 - } 0393 - > /* end if checkj.tr != 0 */ 0394 - > /* end of for active pointer list */ 0395 - 0396 - /* were any overlapping areas found? */ 0397 - if (j > 0) 0398 - { 0399 - /" find area with most sweeps */ 0400 - mostjsweeps = 0; 0401 - for (i = 0; i < j; i++) 0402 - { 0403 - i f (possiblejnr [i] ->sweep count > most sweeps) 0404 - { 0405 - checkj.tr = possible jtr li] ; 0406 - mostjsweeps = checkj.tr->sweepj:ount; 0407 - activejarea number = possible areajιum[i] ; 0408 > 0409 - > 0410 - 0411 - /* was selected area already overlapped with another fragment */ 0412 - if (check ptr->bars ?ound) 0413 - C 0414 - /* extend range of new positions to include both fragments */ 0415 - if (new start < check ptr->newjstart pos) 0416 - < 0417 - checkj tr->newjstart pos = newjstart; 0418 - > 0419 - if (new_end > check ptr->new end pos) 0420 - C 0421 - check ptr->new endjaos = new end; 0422 - > 0423 - > 0424 - else 0425 - - 0426 - /* set new posi ti ons to posi tion of fragment */ 0427 - check 3tr->newjstartj3os = newjstart; 0428 - check )tr->new end pos = new end; 0429 - . 0430 - 0431 - /* fragment chained to this active area so indicate such */ 0432 - checkj3tr->bars_ ound = TRUE; file: SD TSD.C page: 7 date: Sat Sep 11 13:13:46 1993 line 0433 - checkj3tr->emptyjsweeps = 0; 0434 - chec j it r - > f ragment j;ount++ ; 0435 - 0436 - /* return overlapped active area */ 0437 - retum(ch eck .tr); 0438 - > 0439 - 0440 - /* return 0 since no active area overlaps with this fragment */ 0441 - return (0); 0442 - > 0466 /* go to first empty entry in active pointer array */ 0467 i = 0; 0468 while (i < numjjf act jtrs && active jtrs[i] != 0) 0469 { 0470 0471 > 0472 0473 /* if empty entry found */ 0474 if (i < num of act jtrs) 0475 0476 if (active ptrsti] == 0) 0477 < 0478 /* designate storage for new active area */ 0479 active .tr = &activejstructs[i]; 0480 /* add to list (reserve the space) */ 0481 activej)trs[i] = activejatr; 0482 0483 /* set structure members */ 0484 activej-tr->startj3θsition = (*cd .tr->datajstart) » 17; 0485 active )tr->end 3θsition = (*cdjtr->data j .nd) » 17; 0486 activej-tr->newjstartj.os = actϊvej.tr->sϊartj-osition; 0487 activej-tr->newj-ndj3θs = active >i.r->end aosition; 0488 active >tr->bars found = TRUE; 0489 active )tr->fragmentj:ount = 0; 0490 activej3tr->emptyjsweeps = 0; 0491 active tr->activejstart = active jtr->activej.nd = active )tr->active -uffer; 0492 active areajiumber = i; 0493 0494 /* return pointer to newly allocated structure */ 0495 return (activej.tr); 0496 > /* end if */ 0497 0498 > /* end if */ 0499 0500 /* return 0 since no more structures available */ 0501 return (0); 0502 - > 0503 0504 ■ I*/ file: SD TSD.C page: 8 date: Sat Sep 11 13:13:46 1993 line 0505 - 0506 - TITLE remove .ctivej.rea, remove an active area 0507 - 0508 - INPUTS active .tr, active area pointer 0509 - 0510 - 0511 - OUTPUTS 0512 - 0513 - 0514 - ABSTRACT This procedure removes an active area by 0515 - deallocating its space and nulling out its entry 0516 - in the active pointer list. 0517 - 0518 - 0519 - 0520 - 0521 - void sd remove active area(C PARMS "activejstr) 0522 - 0523 - unsi ned int i; 0524 - 0525 - /* find entry number */ 0526 - i > 0; 0527 - whi le (active .trs [i] ! = active .tr && i < num of act strs) 0528 - < 0529 - i++; 0530 - 0531 - 0532 - /* if entry found */ 0533 - if (i < nu of actjatrs) 0534 - < 0535 - /* remove pointer from list */ 0536 - activejDtrsli] = 0; 0537 - > 0538 - 0563 /* no overlapping ignore area found yet */ 0564 areajfound = FALSE; 0565 0566 /* set position variables */ 0567 newjstart = (*cd jtr->datajstart) » 17; 0568 newjϊnd = (*cd .tr->datajsnd) » 17; 0569 correctedjiewjstart = newjstart + cdj.tr->posj,orrecti on; 0570 correctedjiewj-nd = new ϊnd + cdj.tr->posj:orrection; 0571 0572 /* scan l ist of ignore pointers and look for overlap */ 0573 for ( i = 0; i < num of i gn ptrs; i++) 0574 { 0575 /* see i f entry i s being used */ 0576 checkjjtr = ignore .trs [i] ; file: SD TSD.C page: 9 date: Sat Sep 11 13:13:46 1993 line 0577 if (checkj.tr != 0) 0578 t 0579 /* set ignore area's position variables */ 0580 ignorejstart = check .tr->start .osition; 0581 ignorejjnd = checkj-tr->endj3θsition; 0582 0583 /* check for overlap */ 0584 if (ignore start >= corrected newjstart && ignore start <= corrected new end) 0585 i ~ 0586 /* overlapping ignore area found */ 0587 area found = TRUE; 0588 0589 else if (ignore end >= corrected new start && ignore end <= correctedjiewjjnd) 0590 < 0591 /* overlapping ignore area found */ 0592 area found = TRUE; 0593 > 0594 else if (corrected new start >= ignore start && corrected new start <= ignore end) 0595 < 0596 /* overlapping ignore area found */ 0597 area found = TRUE; 0598 ) 0599 else 0600 0601 /* overlapping ignore area not found */ 0602 area found = FALSE; 0603 > 0604 0605 /* see if this ignore area overlaps with the input fragment */ 0606 if (area found) 0607 < 0608 /* was selected area already overlapped with another fragment */ 0609 if (check jtr->bars_found) 0610 • 0611 /* extend range of new positions to include both fragments */ 0612 if (new start < check ptr->new startjos) 0613 < 0614 check 3tr->new startjsos = new start; 0615 > 0616 if (new end > checkj3tr->new end jos) 0617 C 0618 checkj-tr->new endjjos = new end; 0619 > 0620 > 0621 else 0622 < 0623 /* set new positions to position of fragment */ 0624 check jtr->newjstartj3θs = newjstart; 0625 check -tr->new endjjos = new end; 0626 > 0627 0628 /* fragment chained to this ignore area so indicate such */ 0629 check jtr->bars found = TRUE; 0630 0631 /* indicate overlapping ignore area was found */ 0632 return(TRUE); 0633 > /* end if areajfound */ 0634 > /* end if checkjptr != 0 */ 0635 } /* end for list of ignore pointers */ 0636 0637 /* return FALSE since no ignore area overlaps with this fragment */ 0638 return (FALSE); 0639 - } file: SD TSD.C page: 10 date: Sat Sep 11 13:13:46 1993 0662 - /* go to first empty entry in ignore pointer array */ 0663 - i = 0; 0664 - while (i < num of ignjJtrs && ignore ptrs[i] != 0) 0665 - • 0666 - i++; 0667 - > 0668 - 0669 - /* if empty entry found */ 0670 - if (i < num of ignj-trs) 0671 - ( 0672 - if (ignore 3trs[i] == 0) 0673 - • 0674 - /* designate storage for new ignore area */ 0675 - ignorejstr = &ignorejstructs[i]; 0676 - /* add to list (reserve the space) */ 0677 - ignore -trs[i] = igπorejotr; 0678 - 0679 - /* set structure members */ 0680 - ignore .tr->startj_osition = active .tr->startj.osition; 0681 - ignore >tr->endj3θsition = activejtr->endj3θsition; 0682 - ignore 3tr->newjstartj3θs = ignorej-tr->startj3θsition; 0683 - ignorej-tr->newj»nd .os = ignorej.tr->endj5θsition; 0684 - ignorej3tr->bars found = TRUE; 0685 - > /* end if */ 0686 - > /* end if */ 0687 - . 0688 0689 - /* */ 0690 - /* */ 0691 - /* TITLE remove ignore srea, remove an ignore area */ 0692 - /* */ 0693 - /* INPUTS ignore .tr, ignore area pointer */ 0694 - /* */ 0695 - /* */ 0696 - /* OUTPUTS */ 0697 - /* */ 0698 - /* */ 0699 - /* ABSTRACT This procedure removes an ignore area by */ 0700 - /* deallocating its space and nulling out its entry */ 0701 - /* in the ignore pointer list. */ 0702 - /* */ 0703 - /* */ 0704 - /* */ 0705 - /* */ 0706 void sd remove ignore area(IJ-ΑRMS "ignore ptr) 0707 0708 int i; 0709 0710 /* find entry number */ 0711 i = 0; 0712 while (ignorej_trs[i] != ignorej.tr && i < num of actj-trs) 0713 a 0714 i++; 0715 > 0716 0717 /* if entry was found */ 0718 if (i < numjjf ignjJtrs) 0719 ( 0720 /* remove pointer from list */ file: SD_TSD.C page: 11 date: Sat Sep 11 13:13:461993 line 0721 i norej3trs[i] = 0; 0722 > 0723 - > 0724 0725 - /* */ 0726 - /* */ 0727 - /* TITLE - reverse -d, reverse the raw counts in the sweep buffer */ 0728 - /* */ 0729 - /* INPUTS - cd j tr, pointer to the raw count data structure */ 0730 - /* */ 0731 - /* OUTPUTS - modifies the count array by flipping it around */ 0732 - /* */ 0733 - /* ABSTRACT - This procedure takes count data and reverses it in memory */ 0734 - /* */ 0735 - /* 0736 - void sd reversej:d(COUNT DATA *cd .tr) 0737 - C 0738 unsigned int "intptr, "codeptr, temp; 0739 int count; 0740 0741 /* calculate number of fl ips needed and set pointers */ 0742 count = (cdjJtr->dataj.nd - cd -tr->datajstart + 1 ) » 1 ; 0743 codeptr = cd .tr->datajstart; 0744 intptr = cdj3tr->dataj.nd; 0745 0746 /* while flipping is needed */ 0747 while (count > 0) 0748 < 0749 /* "codeptr <-> "intptr */ 0750 temp = "codeptr; 0751 "codeptr = "intptr; 0752 "intptr = temp; 0753 0754 /* adjust pointers and decrement number of flips */ 0755 codeptr++; 0756 intptr--; 0757 count--; 0758 > 0759 - > 0778 /* calculate number of flips needed and set pointers */ 0779 count = (active >tr->f i rstjsweepj.nd - activej-tr->f i rstjsweepjstart + 1 ) » 1 ; 0780 codeptr = activejatr->f i rstjsweepjstart; 0781 i ntptr = active 3tr->f i rst jsweepjjnd; 0782 0783 /* whi le f lipping is needed */ 0784 whi le (count > 0) 0785 { 0786 /* "codeptr <-> "intptr */ 0787 temp = "codeptr; 0788 "codeptr = "intptr; 0789 "intptr = temp; 0790 0791 /* adjust pointers and decrement number of flips */ 0792 codeptr++; file: SD TSD.C page: 12 date: Sat Sep 11 13:13:46 1993 line 0793 - intptr--; 0794 - count--; 0795 - > 0796 - 0797 - 0798 - /* 0799 - /* 0800 - /* TITLE - sd_find_direction, determine direction 0801 - /* 0802 - /* INPUTS - active .tr, points to pointers to sweep 1 0803 - /* cdjJtr, points to pointers to sweep 2 0804 - /* 0805 - /* OUTPUTS - activejDtr->sweepj_irection = F D or REV 0806 - /* 0807 - /* 0808 - /* ABSTRACT - Sweeps are compared with the leading edge lined up and 0809 - /* then with the trailing edge lined up. The direction 0810 - /* is determined by the comparison that has the least 0811 - /* amount of mismatches within the match length. 0812 - /* 0813 - /* 0814 - unsigned int sd l find_direction(C_PARMS *active_ptr, COUNT_DATA *cd_ptr) 0815 - { 0816 - unsigned int "firstjstart, *first ;nd; 0817 - unsigned int "secondjstart, "secondjjnd; 0818 - unsigned int *f i rstj_ataj.tr, "second j_ata .tr; 0819 - unsigned int leadingj.dge_mismatch_12, trai lingj.dge_mismatch_12; 0820 - int mismatch , i; 0821 - 0822 - /* set pointers to beginning and ending of 1st and 2nd sweeps */ 0823 - firstjstart = activejtr->f irstjsweepjstart; 0824 - firstjϊnd = active jtr->f i rst jsweep ϊnd; 0825 - secondjstart = cdj.tr->datajstart; 0826 - secondjϊnd = cd .tr->data .nd; 0827 - 0828 - /* compare first sweep to second sweep with leading edges aligned */ 0829 - irst_data 3tr = firstjstart; 0830 - secondjdataj.tr = secondjstart; 0831 - mismatch = 0; 0832 - i = 0; 0833 - 0834 - /* check first match \imit pieces of count data */ 0835 - while (first data ptr <= first end && second data ptr <= second end && i < match limit) 0836 - ~ ~ 0837 - /* check for bad matchup */ 0838 - if (!sd bar match(first datajitr, second datajjtr)) 0839 - - 0840 - mismatch++; 0841 - ) 0842 - 0843 - /* increment pointers and count of comparisions */ 0844 - firstjJataj.tr++; 0845 - secondjataj-1r++; 0846 - i++; /* counter */ 0847 - > 0848 - 0849 - /* save result */ 0850 - leadingj.dgejnismatch_12 = mismatch; 0851 - 0852 - /* compare first sweep to second sweep with trailing edges aligned "/ 0853 - firstj-ataj.tr = firstj.nd; 0854 - secondj-ata jtr = secondjϊnd; 0855 - mismatch = 0; 0856 - i = 0; 0857 - 0858 - /* check last match imit pieces of count data */ 0859 - while (first data ptr >= first start && second data ptr >= second start && i < match ^imit) 0860 - 0861 - /* check for bad matchup */ 0862 - if (!sd bar match(first data ptr, second dataj.tr)) 0863 - { 0864 - mismatch++; file: SD_TSD.C page: 13 date: Sat Sep 11 13:13:46 1993 0867 /* decrement pointers and increment count of comparisions */ 0868 first -ata Jtr--; 0869 second iata j Dtr--; 0870 i++; 0871 > 0872 0873 /* save result */ 0874 trai lingj.dge_mismatch_12 = mismatch; 0875 0876 /* see if leading edge alignment is better than trailing edge alignment */ 0877 if (leading edge mismatch 12 < trailing edge mismatch 12) 0878 0879 /* leading edge is best, is it good enough to accept? */ 0880 if (leading edge mismatch 12 < mismatch limit) 0881 C 0882 /* leading edge looks good so sweep direction is foward */ 0883 active ,tr->sweepj_irection = FUD; 0884 return~(TRUE); 0885 > 0886 else 0887 - 0888 /* too many mismatches for this to be a barcode edge */ 0889 return(FALSE); 0890 > 0891 > 0892 else 0893 • 0894 /* trailing edge is best, is it good enough to accept? */ 0895 if (trailing edge mismatch 12 < mismatch \imit) 0896 - 0897 /* trailing edge looks good so sweep direction is reverse */ 0898 activej-tr->sweepj-irection = REV; 0899 return (TRUE); 0900 > 0901 else 0902 < 0903 /* too many mismatches for this to be a barcode edge */ 0904 return(FALSE); 0905 > 0906 > 0907 0908 0909 */ 0910 - /* */ 0911 - /* TITLE - sdjweragej.ffset, find average position offset */ 0912 - /* */ 0913 - /* INPUTS - active jtr, pointer to active structure */ 0914 - /* cd .tr, pointer to count data structure */ 0915 - /* */ 0916 - /* OUTPUTS - average offset position in active structure */ 0917 - /* */ 0918 - /* */ 0919 - /* ABSTRACT finds the average position offset of the second bar */ 0920 - /* from sweep 1 to sweep 2 */ 0921 - /* */ 0922 - /* 0923 - void sd average offset(CJ-ΑRMS "activej.tr, COUNT DATA "cdjatr) 0924 - t 0925 unsigned int "intptr; 0926 unsi gned int sweep1j:ount , sweep2j:ount; 0927 0928 /* get posi tion of 2nd bar in sweep 1 */ 0929 intptr = (activejJtr->f i rstjsweepjstart + 2); 0930 sweep1j;ount = ( ( ("intptr) ) » 17); 0931 0932 /* get posi tion of 2nd bar in sweep 2 usi ng posi tion correction */ 0933 intptr = (cdj3tr->datajstart + 2) ; 0934 sweep2j:ount = ( (("intptr)) » 17) + cd str->pos_correction; 0935 0936 /* calculate offset from sweep 1 to sweep 2, posi tion correcti on yields */ file: SD TSD.C page: 14 date: Sat Sep 11 13:13:46 1993 line 0937 - /* true geometric offset */ 0938 - active 3tr->offsetjjosition sweep2j:ount - sweep1j:ount; 0939 - 0940 - 0941 - 0942 - 0943 - TITLE - sdjjar natch, compare bars or spaces to see if the same 0944 - 0945 - INPUTS - oldj.tr, pointer to old data 0946 - newj.tr, pointer to new data 0947 - 0948 - OUTPUTS - TRUE if match FALSE if mismatch 0949 - 0950 - ABSTRACT - compares two transitions for data match or mismatch 0951 - within the mismatch factor 0952 - 0953 - 0954 - unsigned int sd bar match(unsigned int "old ptr, unsigned int *newjjtr) 0955 - •C 0956 - unsigned int mmjfactor; 0957 - int lower mit; 0958 - int upper mit; 0959 - unsigned short oldjdata; 0960 - unsigned short newjiata; 0961 - unsigned int oldjidth_1, old ιidth_2; 0962 - unsigned int newjwidth_1, new jidth .; 0963 - 0964 - i f ( !mmj.dge to edge) 0965 - { 0966 - old_data = "oldj.tr & OxOOOOffff ; 0967 - newjiata = *new_ptr & OxOOOOffff; 0968 - 0969 - i f (mmjnethod == MMPCT) 0970 - C 0971 - /* f ind smal ler transi tion size and scale to mm .ercent .ower */ 0972 - i f (new data <; old data) 0973 - < C 0974 - irm factor = new data » mm percent power; 0975 - " > 0976 - else 0977 - • 0978 - mm factor = old data » mmj.ercentj.ower; 0979 - ~ > 0980 - > 0981 - else 0982 - C 0983 - mm factor = mm i it; 0984 - > ~ 0985 - 0986 - upper \imit = otdjdata + mmjfactor; 0987 - lowestimit = old_data - mmjfactor; 0988 - if (tower_limit < 0) lower imit = 0; 0989 - 0990 - /* compare lower 16 bits of data, +/- generates limits for compare */ 0991 - if ((upper limit >= newjiata) && (lower \imit <= new data)) 0992 - < 0993 - /* transition within limits */ 0994 - return(TRUE); 0995 - > 0996 - 0997 - /* transition not within limits */ 0998 - return(FALSE); 0999 - > 1000 - else 1001 - • 1002 - /* do mismatching on bar space pairs */ 1003 - old_width 1 = (*(old_ptr - 1) & OxOOOOffff) ("oldjjtr & OxOOOOffff) 1004 - old_widttT2 = (*(old_ptr + 1) & OxOOOOffff) ("oldjjtr & OxOOOOffff) 1005 - new_width~1 = (*(new_ptr - 1) & OxOOOOffff) (*new_ptr & OxOOOOffff) 1006 - new 4idth_2 = (*(new~ptr + 1) & OxOOOOffff) + (*new_ptr & OxOOOOffff) 1007 - 1008 - if (mm method == MMPCT) file: SD_TSD.C page: 15 date: Sat Sep 11 13:13:461993 line 1009 - { 1010 - /* find smaller edge to edge size and scale to mm jercentj-ower */ 1011 - if (new width 1 < old width 1) 1012 - i 1013 - mη factor = new -iidth 1 » mmj.ercentj.ower; 1014 - " > 1015 - else 1016 - { 1017 - mm factor = oldjwidth 1 » mmj.ercentj.ower; 1018 - " > 1019 - > 1020 - else 1021 - { 1022 - mm factor = mm limit; 1023 - } " 1024 - 1025 - upρer \imit = old_width_1 + mmjfactor; 1026 - lower limit = oldjwidth_1 - mmjfactor; 1027 - if (lower \imit < 0) lower ^imit = 0; 1028 - 1029 - /* compare lower 16 bits of width, +/- generates limits for compare */ 1030 - if ((upper imit >= new width 1) && (lower \imit <= new width 1)) 1031 - - 1032 - if (mm method == MMPCT) 1033 - ~ - 1034 - /* find smaller edge to edge size and scale to mjjercentj-Ower */ 1035 - if (new <idth_2 < oldjjidth .) 1036 - t 1037 - mmjfactor = newjwidth_2 >> mmj.ercentj.ower; 1038 - > 1039 - else 1040 - i 1041 - mm factor = old width 2 » mmjjercentjjower; 1042 - 1043 - > 1044 - else 1045 - i 1046 - mm factor = mm limit; 1047 - - ~ 1048 - 1049 - upper_limit = oldjidth_2 + mmjfactor; 1050 - lower \imit = oldjwidth_2 - mmjfactor; 1051 - if (lower_limit < 0) lower_limit = 0; 1052 - 1053 - /* compare lower 16 bits of width, +/- generates limits for compare */ 1054 - if ((upper limit >= new width 2) && ( lower ^imit <= new width_2)) 1055 - < 1056 - /* edge to edge comparision is within limits */ 1057 - return(TRUE); 1058 - > 1059 - > 1060 - 1061 - /* edge to edge comparision not within limits */ 1062 - returnCFALSE); 1063 - > 1064 - > 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 file: SD TSD.C page: 16 date: Sat Sep 11 13:13:461993 1099 - /* set mismatch index */ 1100 - j = 0; 1101 - 1102 - /* compare 1st and 2nd sweep, init sweeps per bar and mismatch array */ 1103 - first iataj.tr = firstjstartjjtr; 1104 - second data ptr = secondjstaft itr; 1105 - 1106 - /* while within overlapping region of sweep 1 and sweep 2 */ 1107 - while (first data jtr <= first end ptr && second data .tr <= second end ptr) 1108 < " " ~ " 1109 - /* initialize sweeps per bar variable */ 1110 - counter = 2; 1111 - 1112 - /* compare 1st sweep to 2nd sweep */ 1113 - if (!sd bar natch(first data ptr, second data ptr)) 1114 - { " ~ 1115 - /* mismatch detected, put in mismatch l ist if any room is left */ 1116 - i f ( j < mm size) 1117 - -C 1118 - /* save data from sweep 1 */ 1119 - active_ptr->mm_data [j] .val [0] = *(f i rst_dataj.tr - 1 ); /* front of data value */ 1120 - active j_tr->mmj-ata [j] . al [1] = *(f i rst~data .tr) ; /* center of data value */ 1121 " act ive ptr->mm data [j] .val [2] = *(f i rst~data~ptr + 1 ); /* back of data value */ 1122 - " " 1123 - /* point mismatch into sweep 2 */ 1124 - active ptr->mm ptr[j] = second data ptr; 1125 - ~ ~ 1126 - /* mismatch data was seen in only one sweep */ 1127 - active ptr->mm spb[j] = 1; 1128 - 1129 - /* increment mismatch index */ 1130 - j++; 1131 - 1132 - /* second sweep data was seen in only one sweep */ 1133 - counter = 1; 1134 - • > 1135 - > 1136 - 1137 - /* save sweeps per bar for this data item */ 1138 - "count .tr = counter; 1139 - 1140 - /* increment pointers */ 1141 - countjjtr++; 1142 - first iataj_tr++; 1143 - secondj_ataj.tr++; 1144 - > /* end of while within overlap */ 1145 - 1146 - /* finish initializing sweeps per bar if not at end of 2nd sweep already */ 1147 - while (second data ptr <= second end ptr) 1148 - { " ~ ~ 1149 - /* set sweeps per bar */ 1150 - "count ptr = 1; 1151 - 1152 - /* increment pointers */ file: SD_TSD.C page: 17 date: Sat Sep 11 13:13:46 1993 line 1153 count j .tr++; 1154 second dataj_tr++; 1155 } 1156 1157 /* save mismatch count 1158 mismatchjjount = j; 1159 1178 /" set pointers to second sweep fragment */ 1179 secondj3tartj.tr = cdj.tr->dataj tart; 1180 second snd str = cdjjtr->data_end; 1181 1182 /* set start of active buffer */ 1183 activej)tr->activejstart = activej.ataj.tr = activej3tr->activejjuffer; 1184 1185 /* whi le wi thin 2nd sweep fragment and no overf low of active buffer */ 1186 i = 0; 1187 while (secondjstart ptr <= second end ptr && i++ < ACTIVE SIZE) 1188 C 1189 /* copy from sweep 2 to active buffer */ 1190 *activejJata )tr++ = "second startj.tr++; 1191 > 1192 1193 /* set end of active buffer */ 1194 activej_tr->active j ;πd = activej-ataj-tr - 1; 1195 1196 /* adjust mismatch pointers since data was moved */ 1197 for (i = 0; i < mm size; i++) 1198 1199 /* if mismatch is set */ 1200 i f (activej-tr->mm ptr [i] ! = 0) 1201 ( 1202 /* move pointer from sweep 2 to same relative locati on in activejjuffer */ 1203 activejJtr->mmj.tr [i] = activej3tr->activejstart + 1204 (acti ej3tr-->mπtj-tr [i] - cd ptr->datajstart); 1205 } 1206 > 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 file: SD TSD.C page: 18 date: Sat Sep 11 13:13:46 1993 line 1225 - /.|=================== = ====== -- ===== . ■ |v 1226 - void sd adjustjspb(CJ>ARMS *active >tr) 1227 - - 1228 - unsigned int maxjspb, "spbj.tr, "activej_ataj.tr; 1229 - 1230 - /* set up pointers and maximum */ 1231 - maxjspb = 0; 1232 - activej_ata .tr = activej.tr->activejstart; 1233 - spbj.tr = activej.tr->sweepsj.erj_ar + (activej-ataj.tr - active jtr->active )uffer); 1234 - 1235 - /* begin scanning bars looking for maximum sweeps per bar */ 1236 - while (active dataj.tr <= active ptr->active end) 1237 - { 1238 - /* new max found? */ 1239 - if ("spbjjtr > max spb) 1240 - • 1241 - /* save new max */ 1242 - max spb = "spbj.tr; 1243 - > 1244 - 1245 - /* bump up to the next bar */ 1246 - activej.ata .tr += 2; 1247 - spbjjtr += 2; 1248 - ) 1249 - 1250 - /* divide max to get new lock value */ 1251 - maxjspb = maxjspb / 3; 1252 - 1253 - /* check lower limit of spb lock */ 1254 - if (max spb < spb lock) 1255 - 1256 - max spb = spb lock; 1257 - > 1288 - /* initialize intptr to end of active buffer */ 1289 - intptr = activejj.tr->activej;nd; 1290 - 1291 - /* initialize sweeps per bar pointer to end of buffer */ 1292 - sweep .tr = activej.tr->sweepsj3er .ar + (intptr - activej9tr->active_buffer); 1293 - 1294 - /* scan while in active data and < reqjjood iits above spb ^ock - 1 */ 1295 - goodjiits = 0; 1296 - while ((goodjiits < reqjjoodju ' ts) && (intptr >= activej3tr->activejstart)) file: SD TSD.C page: 19 date: Sat Sep 11 13:13:461993 line 1297 - < 1298 - /* check if enough sweeps to be called a good hit */ 1299 - if (*sweepj3tr >= (active_ptr->spb lock - 1)) 1300 - < 1301 - good hits++; 1302 - } 1303 - else 1304 - { 1305 - good hits = 0; 1306 - > 1307 - 1308 - /* point to next transition */ 1309 - intptr--; 1310 - sweepjstr--; 1311 - > 1312 - 1313 - /* if enough good hits were found and pointer is not too close to front of active buffer */ 1314 - if ((good hits >= req_good hits) && ((intptr - align key offset + good hits) >= activej.tr->active start)) 1315 - i ~ 1316 - /* back up to first good hit */ 1317 - intptr += good hits; 1318 - 1319 - /* verify pointing at bar */ 1320 - if (("intptr & 0x00010000) != BLACK_BAR) 1321 - intptr--; 1322 - 1323 - /* go foward in buffer to pick align key */ 1324 - alignjcey ptr = intptr - align keyjjffset; 1325 } 1326 - else 1327 - t 1328 - /* best align key is the front of the active buffer */ 1329 - alignjcey ptr = activej.tr->active_start; 1330 - > 1331 - 1332 - 1333 - /* now choose align key preference by space/bar/space size */ 1334 - original alignjcey = "align key .tr; 1335 - 1336 - /* use align key around the biggest bar and spaces */ 1337 - bar 0 = "(align key ptr - 2) & OxOOOOffff; 1338 - space 1 = *(align~key ptr - 1) & OxOOOOffff; 1339 - bar 1~ = *(align~key~ptr) & OxOOOOffff; 1340 - space 2 = "(alignjcey ' ptr + 1) & OxOOOOffff; 1341 - bar 2 _ = "(align key ' ptr + 2) & OxOOOOffff 1342 - space 3 = "(align~key .tr + 3) & OxOOOOffff 1343 - bar_3~ = "(aIign_keyj.tr + 4) & OxOOOOffff 1344 - ssppaaccee__44 == *"((aalliiggnn~_kkeeyy ..ttrr ++ 55)) &_• OOxxOOOOOOOOffffffff; 1345 - bbaarr_44~~ == "*((aalliiggnnj~kceeyy_ppttrr ++ 66)) && OOxxOOOOOOOOffffffff; 1346 1347 align_key_size = (bar_0»1) + space_1 + bar_1 + space_2 + (bar_2>>1); 1348 align_key2_size = (bar_1»1) + space_2 + bar_2 + space_3 + (bar_3»1); 1349 align_key3_size = (bar_2»1) + space_3 + bar_3 + space_4 + (bar_4»1); 1350 1351 /* sort align keys based on halfbar-s_ r pace-bar-space-halfbar */ 1352 - if (align key2 size > align key size) 1353 - < 1354 - if (align_key2_size >= align_key3 size) 1355 - { 1356 - /* align key 2 is biggest */ 1357 align_key_ptr_array[0] = atignjceyj.tr + 2; 1358 if (align_key3_size > align_key_size) 1359 - 1360 al ign_key_ptr_array[1] = al ign_key_ptr + 4; 1361 al i gn key ptr array[2] = al ign keyj.tr; 1362 - 1363 - else 1364 - 1365 - al i gn_key_ptr_array[1] = al i gn_key_ptr; 1366 - al i gn_key_ptr array[2] = al ignjcey ptr + 4; 1 1T3A677. \ ~ 1368 file: SD_TSD.C page: 20 date: Sat Sep 11 13:13:46 1993 line 1369 - else 1370 - { 1371 - /* align key 3 is biggest */ 1372 - align_key_ptr_array[0] = align_key_ptr + 4; 1373 - align_key_ptr_array[1] = align_keyj.tr + 2; 1374 - align key jtr array[2] = align key .tr; 1375 - 1376 - 1377 - else if (align key3 size > align key size) 1378 - 1379 - /* align key 3 is biggest */ 1380 - align_key_ptr_array[0] = align_key_ptr + 4; 1381 - align_key_ptr_array[1] = align_key_ptr; 1382 - align keyjatr array[2] = align key .tr + 2; 1383 - > 1384 - else 1385 - { 1386 - /* align key is biggest */ 1387 - align_key_ptr_array[0] = align_key_ptr; 1388 - if (align key2 size >= align key3 size) 1389 - 1390 - align_key_ptr_array[1] = align_key_ptr + 2; 1391 - align_keyj.tr array [2] = align keyj.tr + 4; 1392 - > 1393 - else 1394 - - 1395 - align_key_ptr_array[1] = align_keyj.tr + 4; 1396 - align keyj.tr array[2] = align key ptr + 2; 1397 - > 1398 - ) 1399 - 1400 - /* choose align key based on size and alternately reject sequence */ 1401 - if (!alternate_align_key) 1402 - - 1403 - /* select biggest align key */ 1404 - align keyj.tr = align key_ptr_array[0] ; 1405 - > 1406 - else 1407 - •C 1408 - /* alternate align key based on rejected sweep count */ 1409 - i = active_ptr->reject_count % 3; 1410 - align key jtr = align key j jtr array[i]; 1411 - } 1412 - 1413 - /* return align key found */ 1414 - return(aIign_key_ptr); 1415 - file: SD TSD.C page: 21 date: Sat Sep 11 13:13:46 1993 line 1441 - /* return (FALSE) 1442 - /* 1443 - /* return (TRUE) 1444 - /* 1445 - /* 1446 - /* 1447 - char sd adjust align(ALIGNMENT "alignment, unsigned int align_attempt) 1448 - C 1449 /* check for maximum attempts */ 1450 if (align attempt >= max align_aperature width) 1451 C 1452 /* no more attempts to be made */ 1453 return(FALSE); 1454 > 1455 1456 /* adjust alignment based on attempts tried */ 1457 switch(align attempt) 1458 { 1459 case 1: 1460 /* slide window 2 in front of align key */ 1461 alignment->new_ptr = alignment->new >tr + 2; 1462 return(TRUE); 1463 case 2: 1464 /* slide window 2 behind align key */ 1465 alignment->new_ptr = alignment->new jtr - 4; 1466 return(TRUE); 1467 case 3: 1468 /* slide window 4 in front of align key */ 1469 alignment->newjDtr = al ignment->new_ptr + 6; 1470 return(TRUE); 1471 case 4: 1472 /* slide window 4 behind align key */ 1473 alignment->new ptr = alignment->new ptr - 8; 1474 return(TRUE); ~ 1475 default: 1476 /* no more attempts to be made */ 1477 return(FALSE); 1478 > 1479 - . 1480 1481 /* 1482 /* 1483 /* TITLE - sd_calc_new_offset, calculate new position offset 1484 /* 1485 /* INPUTS - active .tr, active structure pointer 1486 /* cdj-tr, count data structure pointer 1487 /* alignment, alignment of active and new data 1488 /* 1489 /* OUTPUTS - sets the offset stored in the active structure 1490 /* 1491 /* 1492 /* ABSTRACT Using the bars pointed at by the alignment structure. 1493 /* Extract position. 1494 /* Calculate offset. 1495 /* Store new offset into active structure. 1496 /* 1497 /* 1498 void sd_calc new offset(C_PARMS "active ptr, ALIGNMENT alignment, COUNT_DATA *cd_ptr) 1499 < 1500 unsigned int "intptr; 1501 unsigned int new_position_count, active_position_count; 1502 1503 /* corrected position of new data */ 1504 intptr = alignment.new_ptr; 1505 new_position_count = (("intptr)) » 17; 1506 1507 /* position of active data */ 1508 intptr = alignment.activejtr; 1509 active_position_count = ((("intptr)) >> 17) + 1510 active_ptr->offset_pos_of_rej - cd_ptr->pos_correction; 1511 1512 /* calculate difference between new position and active position */ file: SD TSD.C page: 22 date: Sat Sep 11 13:13:46 1993 line 1513 new_offset = newjjosition_count - activej3osition_count ; 1514 1515 /* perform running average of position offset */ 1516 active )tr->offset .osition = (active >tr->offset .osition + newjjffset) / 2; 1517 1518 1519 /* 1520 /* 1521 /* TITLE - sd_align_new_data, align the new data to active data 1522 /* 1523 /* INPUTS - active .tr, active structure pointer 1524 /* cd_ptr, count data structure pointer 1525 /* align_keyj.tr, pointer to the magic bar 1526 /* 1527 /* OUTPUTS - alignment, structure to align active and new data 1528 /* 1529 /* ABSTRACT - Beginning at front end of the new data, search for the 1530 /* bar (not space) which most closely matches the position 1531 /* of the bar pointed at by alignJcey 3tr. Set alignment 1532 /* structure to align_key_ptr and the new data ptr which was 1533 /* found to match it in position 1534 /* 1535 /* 1536 ALIGNMENT sd align new_data(C PARMS "active ptr, C0UNT_DATA *cd_ptr, unsigned int "align key_ptr) 1537 (. 1538 char found; 1539 unsigned int "intptr, "bestjnatch; 1540 unsigned int newj-osition, alignment_key_position; 1541 int difference, old difference, min difference; 1542 ALIGNMENT alignment! 1543 int recalcjnotion; 1544 1545 recalc_motion = 0; 1546 1547 /* calculate position of middle of active align key */ 1548 if (active )tr->sweep direction == FWD) 1549 C 1550 /* position represents trailing edge */ 1551 alignment keyj-osition = ((("align keyj-tr) » 17) + ((*(align_key_ptr - 1)) » 17)) » 1; 1552 > 1553 else 1554 { 1555 /* position represents leading edge */ 1556 alignment key position = ((("alignjcey ptr) » 17) + (("(align key .tr + 1)) » 17)) » 1; 1557 > 1558 1559 /* correct position counts by subtracting encoder correction (subtract 1560 since correcting old position), subtracting the sum of the position 1561 correction for sweeps rejected and adding the true barcode offset */ 1562 alignment_key_position = 1563 alignment_key_position - 1564 cd_ptr->pos_correction + 1565 acϊive -tr->offsetjjosition; 1566 1567 if ((active )tr->sweep count == 4) && (activej.tr->offset pos of rej)) 1568 { 1569 alignment_key_position = 1570 alignment_key_position - 1571 active_ptr->offse7 jos_of_rej; 1572 recalcjnotion = 1; 1573 activej3tr->offsetj50S_of_rej -= active_ptr->offset_position; 1574 activej.tr->offset_position = 0; 1575 > 1576 else 1577 < 1578 alignment_key_position = 1579 alignmentjceyj-osition + 1580 activej_tr->offset pos_of rej; 1581 > 1582 1583 /* point at first bar in new fragment */ 1584 if ((*cd_ptr->data_start & 0x00010000) != BLACK_BAR) cd_ptr->data_start++; file: SD TSD.C page: 23 date: Sat Sep 11 13:13:46 1993 1586 - /* perform linear search of new data fragment */ 1587 - if (linear search) 1588 - { 1589 - /* initialize search variables */ 1590 - old difference = 0x7fffffff; 1591 - found = FALSE; 1592 - intptr = cdj.tr->data_start; 1593 - 1594 - /* find best position match */ 1595 - while (intptr <= cd_ptr->data end && Ifound) 1596 - < 1597 - /* calculate position of middle of new data bar */ 1598 - if (active_ptr->sweep direction == FUD) 1599 - t 1600 - /* position represents trailing edge */ 1601 - if (intptr > cd_ptr->scan start) 1602 - C 1603 - new position = ((("intptr) » 17) + (("(intptr - 1)) » 17)) » 1; 1604 - ~> 1605 - else 1606 - < 1607 - new josition = (("intptr) » 17) » 1; 1608 - > 1609 - > 1610 - else 1611 - ( 1612 - /* position represents leading edge */ 1613 - if (intptr < cdj>tr->data end) 1614 - { 1615 - newjDosition = ((("intptr) » 17) + (("(intptr + 1)) » 17)) » 1; 1616 - > 1617 - else 1618 - { 1619 - new position = ((("intptr) » 17) + ((*(cd_ptr->data_start - 1)) » 17)) » 1; 1620 - ~> 1621 - > 1622 - 1623 - /* difference between new and active position */ 1624 - difference = new_position - alignment keyj.osition; 1625 - 1626 - /* get absolute value */ 1627 - if (difference < 0) difference = -difference; 1628 - 1629 - /* closest position found when difference increases */ 1630 - if (difference >= old_difference) 1631 - { 1632 - alignment.activej.tr = align_key j .tr; 1633 - alignment.ne )tr = intptr - 2; 1634 - found = TRUE; 1635 - > 1636 - 1637 - /* update difference variable */ 1638 - old difference = difference; 1639 - 1640 - /* point at next bar */ 1641 - intptr+=2; 1642 - > /* end of while Ifound */ 1643 - 1644 - /* if not found, do not align to new data */ 1645 - if ((alignment.new ptr == cdj.tr->data start) II (Ifound)) 1646 - { 1647 - alignment.active_ptr = align_key_ptr; 1648 - alignment.new_ptr = 0; 1649 - > 1650 - else 1651 - C 1652 - if (recalcjnotion) 1653 - { 1654 - sd_calc new offset(active_ptr, alignment, cd ptr); 1655 > 1656 - } file: SD_TSD.C page: 24 date: Sat Sep 11 13:13:46 1993 1666 - /* find best position match */ 1667 - while (intptr <= cd ptr->data end) 1668 - { 1669 - /* calculate position of middle of new data bar */ 1670 - if (active ptr->sweep direction == FWD) 1671 - { 1672 - /* position represents trailing edge */ 1673 - if (intptr > cd_ptr->scan start) 1674 - { 1675 - new_position = ((("intptr) » 17) + (("(intptr - 1)) » 17)) » 1; 1676 - > 1677 - else 1678 - C 1679 - new position = (("intptr) » 17) » 1; 1680 - ~> 1681 - > 1682 - else 1683 - C 1684 - /* position represents leading edge */ 1685 - if (intptr < cd ptr->data end) 1686 - - 1687 - new position = ((("intptr) » 17) + (("(intptr + 1)) » 17)) » 1; 1688 - ~> 1689 - else 1690 - { 1691 - new -osi ti on = ( ( ("intptr) » 17) + ( (*(cd_ptr->data start - 1 ) ) » 17) ) » 1 ; 1692 - > 1693 - > 1694 - 1695 - /* difference between new and active position */ 1696 - difference = new aosition - alignmentjceyj-osition; 1697 - 1698 - /* get absolute value */ 1699 - if (difference < 0) difference = -difference; 1700 - 1701 - /* closest position found when difference is minimum (min -ifference hold minimum) */ 1702 - if (difference < min difference) 1703 - C 1704 - bestjnatch = intptr; 1705 - min difference = difference; 1706 - > 1707 - 1708 - /* point at next bar */ 1709 - intptr+=2; 1710 - > 1711 - 1712 - /" if not found, do not align to new data */ 1713 - if ((bestjnatch == cd_ptr->data start) || (bestjnatch == cdj.tr->data_end)) 1714 - < 1715 - al ignment. activej.tr = al i gnjcey_ptr; 1716 - al ignment. new ptr = 0; 1717 - > 1718 - else 1719 - { 1720 - al ignment .active_ptr = al ign_keyj.tr; 1721 - al ignment.new_ptr = bestjnatch; 1722 - i f (recalc moti on) 1723 - { 1724 - sd_calc new offset(active_ptr, alignment, cdj.tr); 1725 - > 1726 - > 1727 - } 1728 - f i le: SD TSD .C page: 25 date: Sat Sep 11 13: 13:46 1993 l ine 1729 - /* return pointers to best position matchup */ 1730 - return (alignment); 1731 - 1776 - /* calculate distance of alignment key from start of new data */ 1777 - start_difference = alignment.newj.tr - cd_ptr->data_start; 1778 - if (startjdifference < 0) 1779 - start_difference = -start_difference; 1780 - 1781 - /* calculate distance of alignment key from end of new data */ 1782 - endjdifference = cd jtr->data_end - alignment.new_ptr; 1783 - if (endjdifference < 0) 1784 - endjdi ference = -endjdifference; 1785 - 1786 - /* calculate distance of alignment key from middle of new data */ 1787 - temp = (cd -tr->data_end - cd_ptr->data_start) / 2; 1788 - tempi = cd_ptr->data_start - ali nment.new_ptr; 1789 - middle_difference = temp + tempi; 1790 - if (middlejdifference < 0) 1791 - middlejdifference = -middlejdifference; 1792 - 1793 - /* see if alignment key is closest to start, end or middle */ 1794 - if ((middle difference <= start difference) && (middle difference «.= end difference)) 1795 - • 1796 - /* middle is closest so center window on the alignment key */ 1797 - alignment.newj.tr = alignment.new .tr - 2; 1798 - alignment.active ptr = alignment.activej.tr - 2; 1799 - > 1800 - else if (end difference < start difference) file: SD TSD.C page: 26 date: Sat Sep 11 13:13:46 1993 line 1801 - 1802 - /* end is closest so set window in front of alignment key */ 1803 - alignment.ne jjtr = alignment.new .tr - 4; 1804 - alignment.activej.tr = alignment.active .tr - 4; 1805 - > 1806 - /* else start is closest so leave window behind alignment key */ 1807 - 1808 - /* return alignment compare window */ 1809 - return(aIignment); 1810 - alignment) 1835 - unsigned int "new_dataj.tr, *active_data_ptr, overlap_count; 1836 - unsigned int mismatch, i; 1837 - 1838 - /* verify overlap of 5 between active and new data */ 1839 - overlap_count = 5; 1840 - 1841 - /* set pointers to front of window */ 1842 - new_dataj.tr = alignment.newjstr, • 1843 - active_data .tr = alignment.activej.tr; 1844 - 1845 - /* check for required overlap */ 1846 - i f ( ( (cd_ptr->dataj;nd - new_data_ptr) < 4) | | 1847 - ( (active_ptr->active_end - active data ptr) < 4) | | 1848 - (new_data_ptr < cd_ptr->data_sta?t) |J 1849 - (active dataj.tr < activejJtr->active_start) ) 1850 - • 1851 - /* not enough overlap so return FALSE */ 1852 - return( ALSE); 1853 - > 1854 - 1855 - /* compare transitions within window */ 1856 - mismatch = 0; 1857 - for (i = 0; i < overlap count; i++) 1858 - t 1859 - /* compare transition between new and active data buffers */ 1860 - if (!sd bar_match(new data ptr, active data_ptr)) 1861 - < 1862 - /* count up mismatches within window */ 1863 - mismatch++; 1864 - > 1865 - 1866 - /* increment pointers to next transition */ 1867 - new_data_ptr++; 1868 - active data_ptr++; 1869 - > 1870 - 1871 - mismatch_count = mismatch; 1872 - f i le: SDJTSD .C page: 27 date: Sat Sep 11 13: 13:46 1993 line 1873 - /* check for too many mismatches 1874 - if (mismatch <= max mismatch) 1875 - return(TRUE); 1876 - else 1877 - return(FALSE); 1878 - 1879 - 1880 - /* 1881 - /* 1882 - /* TITLE - sd_replace_transition, replace dest with src transition 1883 - /* 1884 - /* INPUTS - destination, pointer to destination 1885 - /* source, pointer to source 1886 - /* 1887 - /* OUTPUTS - "destination is set 1888 - /* 1889 - /" 1890 - /* ABSTRACT - *(short*)destination = *(short*)source 1891 - /* 1892 - /* 1893 /* 1894 void sd replace transition(unsigned int "destination, unsigned int "source) 1895 C 1896 unsigned short "dest, "src; 1897 1898 /* set short pointers */ 1899 dest = (unsigned short*)destination; 1900 src = (unsigned short*)source; 1901 1902 /* do short assign */ 1903 "dest = "src; 1904 - > 1905 1906 /* 1907 /* 1908 /* TITLE - sd_average_transition, average dest and src transitions 1909 /* 1910 /* INPUTS - destination, pointer to destination 1911 /* source, pointer to source 1912 /* 1913 /* OUTPUTS - "destination is set 1914 /* 1915 /* 1916 /* ABSTRACT - *(short*)destination = (3 x *(short*)destination + 1917 /* *(short*)source) / 4 1918 /* 1919 /* 1920 void sd average transition(unsigned int "destination, unsigned int "source) 1921 { 1922 unsigned short "dest, "src; 1923 unsigned int destx3; 1924 1925 /* set short pointers */ 1926 dest = (unsigned short*)destination; 1927 src = (unsigned short*)source; 1928 1929 /* multiply dest by 3 */ 1930 destx3 = ("dest « 1) + "dest; 1931 1932 /* perform weighted average */ 1933 "dest = (destx3 + "src) / 4; 1934 - > 1935 1936 - /* 1937 - /* 1938 - /* TITLE - sd_replace_position, replace dest with src position 1939 - /* 1940 - /* INPUTS - destination, pointer to destination 1941 - /* source, pointer to source 1942 - /* 1943 - /* OUTPUTS - "destination position is set 1944 - /* file: SD TSD.C page: 28 date: Sat Sep 11 13:13:46 1993 line 1945 - /* 1946 - /* ABSTRACT - upper 2 bytes of "destination = 1947 - /* upper 2 bytes of "source 1948 - /* 1949 - /* 1950 - /* 1951 - void sd replace position(unsigned int "destination, unsigned int "source) 1952 - - 1953 - unsigned short "dest, "src; 1954 - 1955 - /* set short ponters */ 1956 - dest = (unsigned short*)destination; 1957 - src = (unsigned short*)source; 1958 - 1959 - /* point to upper 16 bits (position data) */ 1960 - dest++; 1961 - src++; 1962 - 1963 - /* do the assign */ 1964 - "dest = "src; 1965 - 1966 - 1967 - */ 1968 - */ 1969 - TITLE - sd_do_the_data, do things to the new data */ 1970 - */ 1971 - INPUTS - active_ptr, active structure pointer; cd_ptr, */ 1972 - new data pointers; alignment, alignment pointers */ 1973 - */ 1974 - OUTPUTS - new data saved in active buffer, mismatch table */ 1975 - updated */ 1976 - */ 1977 - ABSTRACT - This procedure resolves old mismatches, detects */ 1978 - new mismatches, saves new data and updates the */ 1979 - sweeps per bar buffer. */ 1980 - */ 1981 - */ 1982 - int sd do the data(C PARMS *active_ptr, COUNTJJATA *cd_ptr, ALIGNMENT alignment) 1983 - 1984 - unsigned int i, j, k, *end_of_new_in_active; 1985 - unsigned int *new_data_start, *new_data_end, *new_data_ptr; 1986 - unsigned int *active_data_start, *active_data_end, *active_data_ptr; 1987 - unsigned int *aspb_ptr, "aligned .tr, "temp jtr, temp, *end_of_active; 1988 - unsigned int n_trans, mm_trans, old_mm_found; 1989 - 1990 - /* set up pointers (do not modify the active structure at all until after fragment is accepted) */ 1991 - new_data_start = cd_ptr->data_start; 1992 - new_data_end = cdj.tr->data_end; 1993 - active_data_start = alignment.active_ptr + (new_data_start - alignment.new_ptr); 1994 - active_data_end = active_ptr->active_end; 1995 - end_of_active = active ~x->active_buffer + ACTIVE_SIZE - 1; 1996 - 1997 - /* clip the front of the new data if needed */ 1998 - if (active data start < active ptr->active start) 1999 - { 2000 - /* clip front of new data */ 2001 - new_data_start += active_ptr->active_start - active_data_start; 2002 - active_data_start = active_ptr->active_start; 2003 - slicejjffset = (alignment.activej.tr - active_data_start) - 2004 - (alignment.newj.tr - new data_startT; 2005 - } 2006 - 2007 - /* scan past leading garbage (need req_good_hits matches) */ 2008 - i = 0; 2009 - new_data_ptr = new_data_start; 2010 - active_data_ptr = active_data_start; 2011 - while (new_data_ptr <= new_data_end && 2012 - active_dataj.tr <= active_data_end && 2013 - i < req_good hits) 2014 - < 2015 - if (sd_bar match(new data_ptr++, active j data ptr++)) 2016 - C file: SD TSD.C page: 29 date: Sat Sep 11 13:13:46 1993 line 2017 - i++; 2018 - > 2019 - else 2020 - { 2021 - i = 0; 2022 - > 2023 - > 2024 - /* back up pointer to first good hit in a row */ 2025 - new_data_start = new_data_ptr - i; 2026 - actϊve_data start = active_data_ptr - i; 2027 - 2028 - /* scan to front of trailing garbage (need req_good_hits matches) */ 2029 - /* start by finding end of overlap */ 2030 - end_of_new_in_active = (new_data_end - alignment.newj.tr) + alignment.activejJtr; 2031 - if Tend of new in active > active_data end) 2032 - { 2033 - /* new data extends past active data end, so pull new data end back */ 2034 - newjiata end = (active_data_end - alignment.active ptr) + alignment.new ptr; 2035 > 2036 - else 2037 - { 2038 - /* active data extends past new data end, so pull active end back */ 2039 - active data end = end of new in active; 2040 - ) 2041 - /* count up good hits at end */ 2042 - i = 0; 2043 - new_dataj.tr = new_data_end; 2044 - active_data_ptr = active_data_end; 2045 - whi le (new_data_ptr >= new_data_start && 2046 - active datajJtr >= active_data_start && 2047 - i < req_good hi ts) 2048 - { 2049 - if (sd bar match(new_data ptr--, active data_ptr--)) 2050 - <C 2051 - i++; 2052 - > 2053 - else 2054 - { 2055 - i = 0; 2056 - > 2057 - } 2058 - /* bump up pointer to first good hit in a row */ 2059 - new_data_end = newjdatajjtr + i ; 2060 - active data end = active_data_ptr + i ; 2061 - 2062 - /* decide whether to reject fragment based on too small a good overlap */ 2063 - n_trans = new_data_end - new_data_start + 1; 2064 - if (π trans < min_good overlap) 2065 - { " 2066 - /* indicate fragment rejected */ 2067 - return(O); 2068 - > 2069 - 2070 - /* decide whether to reject fragment based on mismatches thoughout fragment (old and new) */ 2071 - if (do mismatch reject) 2072 - { ~ 2073 - /* count old mismatches */ 2074 - mm_trans = 0; 2075 - for (i = 0; i < mm_size; i++) 2076 - { 2077 - /* see if mm in array */ 2078 - if (active_ptr->mm_ptr[i] != 0) 2079 - ( 2080 - /* old mm is present */ 2081 - mm trans++; 2082 - } ~ 2083 - > 2084 - 2085 - /* count the total resultant mismatches and matches in the fragment */ 2086 - newjdatajjtr = new_data_start; 2087 - active_data_ptr = active_data_start; 2088 - while (newjdatajjtr <= new_da~a_end && active_data_ptr <= active_data_end && file: SD_TSD.C page: 30 date: Sat Sep 11 13:13:461993 line 2089 - activejdatajtr < end of active) 2090 { 2091 - /" is new mismatch present? "/ 2092 - if (sd bar match(new_data ptr, active data_ptr)) 2093 - ~ < ~ 2094 - /* is new matching data going to vote on old mismatch? */ 2095 - old_mm_found = 0; 2096 - for (i = 0; i < mm size && lold mm found; i++) 2097 - C 2098 - if (active dataj tr == active jtr->mm_ptr [i ] ) oldjn found = 1 ; 2099 - > ~ 2100 - if (old mm found) mm trans--; 2101 - > 2102 - else 2103 - 2104 - /* could old mismatch be resolved with this fragment? */ 2105 - otd_mm_found = 0; 2106 - for (i = θJ i < mm size && lold mm found; i++) 2107 - C 2108 - i f (activejdata ptr == activej tr->mm_ptr [i] ) old mm found = 1 ; 2109 - > 2110 - if (oldjnm found) 2111 - { 2112 - i f (sd_bar match (new_dataj.tr, &acti ve_ptr->mm data [- - i ] .val [1] ) ) 2113 - { 2114 - /* new data agrees with mismatch data */ 2115 - mm_trans--; 2116 - > 2117 - /* else old mm stays unresolved so one mismatch has already been 2118 - counted against this fragment */ 2119 - > 2120 - else 2121 - { 2122 - /* new mismatch detected with no old mismatch to resolve 2123 - so one more mismatch is counted against this fragment */ 21 4 - mm trans++; 2125 - > ~ 2126 - } 2127 - active_data_ptr++; 2128 - new da~ajjtr++; 2129 - > 2130 - 2131 - /* decide whether to reject fragment based on too many mismatches in fragment */ 2132 - if (mm_trans > mm_size || nm_trans > (n_traπs » m pet frag)) 2133 C 2134 - /* indicate fragment rejected */ 2135 - return(O); 2136 - > 2137 - > 2138 - 2139 - /*****************#**w*******************^ 2140 - 2141 - /* new data fragment has been accepted */ 2142 - 2143 - /* IMPORTANT: do not modify the active */ 2144 - /* structure in any code above */ 2145 - /* this line */ 2146 - 2147 - *****************************************^ 2148 - 2149 - /* remove mismatches not in new data */ 2150 - for (i = 0; i < mm_size; i++) 2151 - t 2152 - /* see i f mm in array */ 2153 - i f (active ptr->mm_ptr [i] ! = 0) 2154 - < 2155 - /* point into new data */ 2156 - al igned ptr = al i gnment .newjjtr + (act ive_ptr->mm ptr [i] - al ignment . active j Jtr) ; 2157 - 2158 - /* see if mm is not in new data */ 2159 - if (aligned_ptr < new data_start || aligned ptr > new data_end) 2160 - { file: SD_TSD.C page: 31 date: Sat Sep 11 13:13:46 1993 line 2161 - /* mm is not in new data, vote with sweeps per bar */ 2162 - aspbjjtr = activejjtr->sweepsjer_bar + (active_ptr->mm_ptr[i] - active_ptr->active_buffer); 2163 - if (active ptr->mm_spb[i] > "aspbjjtr) 2164 - { 2165 - /* use mm data since more hits on it */ 2166 - "aspbjjtr = active_ptr->mm_spb[i] ; 2167 - sd replace transition(active ptr->mmjjtr[i] , &active_ptr->mm_data[i] .val [1] ); 2168 - > ~ 2169 - /* clear mismatch */ 2170 - active ptr->mm_ptr[i] = 0; 2171 - > 2172 - > 2173 - > 2174 - 2175 - /* sort the mismatch array putting nulls at the end, modified bubble sort */ 2176 - for (j = 0; j < mm size - 1; j++) 2177 - - 2178 - for (i = j + 1; i < mm size; i++) 2179 - { 2180 - if ((active_ptr->mm_ptr[j] > active jtr->mm_ptr[i] -,& active_ptr->πτn_ptr[i] != 0) || 2181 - (active_ptr->mm_ptr[j] == 0 && active_ptr->mm_ptr[i] != 0)) 2182 - { 2183 - temp .tr = active_ptr->mm_ptr[i] ; 2184 - active_ptr->mm_ptr[i] = active_ptr->mm_ptr[j] ; 2185 - active_ptr->mm_ptr[j] = temp p~r; 2186 - 2187 - for (k = 0; k < 3; k++) 2188 - { 2189 - temp = active_ptr->π-m_data[i] .val [k] ; 2190 - activejtr->πm_data[i] .val[k] = active_ptr->mm_data[j] .val [k] ; 2191 - active_ptr->mm_data[j] .val [k] = temp; 2192 - > 2193 - 2194 - temp = active_ptr->mm_spb[i] ; 2195 - active_ptr->mm_spb[i] = active_ptr->mm_spb[j] ; 2196 - active_ptr->mm_spb[j] = temp; 2197 - > 2198 - > 2199 - 1 2200 - 2201 - /* process the new data by scanning the good overlap (avoid the text and margin noise) */ 2202 - newjdatajjtr = new_data_start; 2203 - active_data ptr = active_data_start; 2204 - i = 0; 2205 - aspbjjtr = active_ptr->sweeps_per_bar + (active_data_start - active_ptr->active_buffer); 2206 - while (newjdatajjtr <= new_daϊa_end && activejdatajjtr <= active_daTa_end && 2207 - activejdatajjtr < end of active) 2208 - . 2209 - /* does old mismatch need resolving? */ 2210 - if (activejdata ptr == active_ptr->mm_ptr[i] ) 2211 - { 2212 - /* vote on mismatch */ 2213 - if (sd_bar match(new_data_ptr, active data ptr)) 2214 - { 2215 - /* mismatch data outvoted, so average active and new data */ 2216 - "aspbjjtr += 1; 2217 - sd_average_transition( activejdatajjtr, newjdatajjtr); 2218 - /* clear mismatch only if active data has more sweeps per bar */ 2219 - if ("aspb ptr > active_ptr->mm spb[i]) 2220 - < 2221 - active ptr->mm_ptr[i] = 0; 2222 - } 2223 - } 2224 - else if (sd_bar_match(new data ptr, &activejtr->mm dataCi] .val [1] )) 2225 ( 2226 - /* active data outvoted, so average mismatch and new data */ 2227 - active_ptr->mm_spb[i] += 1; 2228 - sd_average_transition(&active_ptr->mm_data[i] .vat [1] , new_dataj.tr); 2229 - /* transfer mismatch only if mismatch data has more sweeps per bar */ 2230 - if (active_ptr->mm_spb[ii > *aspb_ptr) 2231 - C 2232 - "aspbjjtr = active_ptr->mm_spb[i] ; file: SD TSD.C page: 32 date: Sat Sep 11 13:13:46 1993 line 2233 - "activejdatajjtr = active_ptr->mm_data [i] .val [1] ; 2234 - act ive jJtr->mm ptr [i] = 0; 2235 - > 2236 - > 2237 - else 2238 - i 2239 - /* no majority in voting, so save new data after deciding to keep mmjdata or activejdata */ 2240 - if ("aspbjjtr > activejJtr->mm spb[i]) 2241 - < 2242 - activejJtr->mπι_spb[i] = *aspb_ptr; 2243 - active_ptr->πτn_data [i] .val [0] = "(activejdatajjtr - 1 ) ; 2244 - active_ptr->mm_data (i] .val [1] = "(activejdatajjtr) ; 2245 - active ptr->mm data [i] .val [2] = "(active data ptr + 1 ) ; 2246 - } 2247 - 2248 - /* save new data */ 2249 - "aspbjjtr = 1; 2250 - sd replace transition(active data ptr, new datajjtr); 2251 - > " 2252 - 2253 - /* point to next mismatch */ 2254 - i++; 2255 - } 2256 - 2257 - /" is new mismatch present? */ 2258 - else if (Isd bar_match(new_data ptr, active datajjtr)) 2259 - { ~ 2260 - /* is sweeps per bar locking this location? */ 2261 - if ("aspbjjtr < active ptr->spb lock) 2262 - ( 2263 - /* indicate new mismatch, start by find empty location in list */ 2264 - j = 0; 2265 - while ( j < mm_size && active_ptr->mm ptr[j] != 0) 2266 - { 2267 - j++; 2268 - } 2269 - /* if empty location was found */ 2270 - if (j < mm_size) 2271 - < 2272 - /* save up mismatch information */ 2273 - active_ptr->mm_ptr [j] = activejdatajjtr; 2274 - active_ptr->mm_data [j] .val [0] = "(active j datajjtr - 1 ) ; 2275 - active_ptr->mm_data [j] .val [1] = "(activejdatajjtr) ; 2276 - active_ptr->πm_data [j] .val [2] = "(active~data .tr + 1 ); 2277 - active ptr->πm spb[j] = "aspb ptr; 2278 - "aspbjjtr = 1 ;~ 2279 - sd replace transi ti on(active_data_ptr, new data ptr) ; 2280 - > ~ 2281 - > 2282 - > 2283 - /* no mismatch, old or new, so average active and new data */ 2284 - else 2285 - < 2286 - sd_average_transition(active data ptr, new datajjtr); 2287 - "aspbjjtr += 1; 2288 - ) 2289 - 2290 - /* update positon of bar/space */ 2291 - sd replace position(active data ptr++, new_data_ptr++); 2292 - 2293 - /* increment sweeps per bar pointer */ 2294 - aspb ptr++; 2295 - > 2296 - 2297 - /* copy remainder of new data i f any */ 2298 - whi le (newjdatajjtr <= cd ptr->data_end && active_data_ptr < end_of_active) 2299 - C 2300 - *active_data_ptr++ = *new_data_ptr++; 2301 - *aspb_ptr++ = 1; 2302 - > 2303 - /* point to last new transition */ 2304 - activejdatajjtr--; file: SD_TSD.C page: 33 date: Sat Sep 11 13:13:46 1993 line 2305 2306 /* set end of active buffer (trim transitions below the sweeps per bar lock) */ 2307 aspbjjtr = active_ptr->sweepsjjer_bar + (activejJtr->active_end - active_ptr->active_buffer); 2308 while ((active_ptr->active end > active data ptr) SS ("aspbjjtr < 2)) 2309 2310 activejtr->active_end--; 2311 aspb ptr--; 2312 > 2313 2314 /* defeat above logic */ 2315 activejJtr->active_end = active_data .tr; 2316 2317 /* count up current list of mismatched data */ 2318 mismatch_count = 0; 2319 for (j=0; j<mm size; j++) 2320 • C 2321 i f (active_ptr->mmj tr [j] ) mismatch count++; 2322 > 2323 2324 /* indicate fragment accepted */ 2325 returnd); 2326 - > 2349 ALIGNMENT alignment; 2350 unsigned int "alignjceyjjtr; 2351 unsigned int will_align, i, "ptr, "savejJtr; 2352 2353 /* save active data if in debug mode */ 2354 if (mode == DEBUG) 2355 t 2356 i = 0; 2357 ptr = active_ptr->active_start; 2358 savejJtr = save.start = save.buffer; 2359 while (ptr <= active ptr->active_end && i++ < ACTIVE SIZE) 2360 - 2361 "save ptr++ = *ptr++; 2362 ) 2363 save.end = savejJtr - 1; 2364 > 2365 2366 /* if a fragment has already align into this area do not attempt to align another one */ 2367 if (lactive ptr->align status) 2368 I 2369 /* automatically adjust sweeps per bar lock and sweeps per align key */ 2370 sd_adjust_spb(active_ptr); 2371 2372 /* find bar with >= (active_ptr->spb_lock - 1) sweeps per bar */ 2373 alignjceyjjtr = sd_find_align_key(active_ptr); 2374 2375 /* align active alignment key with new data, save debug information */ 2376 alignment = sd_align_new_data(active_ptr, cdjjtr, alignjceyjjtr); file: SD_TSD.C page: 34 date: Sat Sep 11 13:13:46 1993 line 2377 - 2378 - /* make sure alignment key was found in new data fragment */ 2379 - if (alignment.πewjJtr) 2380 - { 2381 - /* save debug information */ 2382 - active_align_key = "alignment.activejJtr; 2383 - new alignjcey = "alignment.new tr; 2384 - 2385 - sl icejjffset = (al ignment.activejjtr - active_ptr->active_start) - 2386 - (al i gnment.newjjtr - cd tr->data start) ; 2387 - 2388 - /* diagnostics */ 2389 - if (mode == DIAGE) 2390 - { 2391 - sprintf(out_buf,"A%do%d",active_area_number, slicejjffset); 2392 - sd send string(out buf); 2393 - > ~ 2394 - 2395 - /* set compare window right, left, or center of active alignment key, save debug information */ 2396 - alignment = sd set window(cdjjtr, alignment); 2397 - 2398 - /* check alignment compare window to see if alignment is good */ 2399 - atign_attempt = 1; 2400 - will align = TRUE; 2401 - 2402 - /* check current window */ 2403 - while (!sd check_window(active_ptr, cd_ptr, alignment) && will align) 2404 - { ~ 2405 - /* adjust alignment if max attempts not exceeded */ 2406 - witl_align = sd_adjust_align(&alignment, align_attempt); 2407 - align attempt++; 2408 - > 2409 - activejjtr->al i gn_status = wi l l_al ign; 2410 - 2411 - /* see if good compare could not be found */ 2412 - if (!will_align) 2413 - { 2414 - /* rejecting this sweep so save up position correction and current real offset */ 2415 - /* this seems to lack accuracy, rejecting sweeps seems to always cause sliding on the next sw 2416 - active_ptr->offset_pos_of_rej += (active_ptr->offset_position - cd_ptr->pos_correction); 2417 - active_ptr->reject_count++; 2418 - new_offset = 0; 2419 - " slicejjffset = 0; 2420 - return; 2421 - > 2422 - 2423 - /* resolve old mismatches, detect new mismatches and save the new data */ 2424 - active_ptr->align status = sdjdo the_data(active ptr, cdjjtr, alignment); 2425 - 2426 - /* if not rejecting this sweep clear reject offset, save debug variable */ 2427 - if (active_ptr->align status) 2428 - { 2429 - /* recalculate offset based on new alignment (must be done before clearing offset_pos_of_rej) 2430 - if (update_bar_motion) sd_calc_new_offset(active_ptr, alignment, cdjjtr); 2431 - else new offset = 0; 2432 - 2433 - /* indicate fragment accepted */ 2434 - active_ptr->offset_pos_of_rej = 0; 2435 - active_ptr->reject_count = 0; 2436 - sl i cejjffset = (at ignment. activejJtr - acti vej tr->active_start) - 2437 - (al ignment.new ptr - cd_ptr->data_start); 2438 - 2439 - /* diagnostics */ 2440 - if (mode == DIAGE) 2441 - < 2442 - sprintf(out_buf,"A%do%d",active_area_number, slicejjffset); 2443 - sd send_string(out buf); 2444 - > ~ 2445 - > 2446 - else 2447 - ( 2448 - /* rejecting this sweep so save up position correction and current real offset */ file: SD_TSD.C page: 35 date: Sat Sep 11 13:13:46 1993 /* but only if a fragment has not already aligned into this area */ /* this seems to lack accuracy, probably due to the resolution of the position clock (8MHz) active_ptr->offsetjjos_of_rej += (activejtr->offset_position - cdjJtr->pos_correction); active_ptr->reject_count++; new_offset = 0; slicejjffset = 0; activejtr->align_status = 0; else < /* rejecting this sweep so save up position correction and current real offset */ /* but only if a fragment has not already aligned into this area */ /* this seems to lack accuracy, probably due to the resolution of the position clock (8MHz) */ active jtr->offset_pos_of_rej += (active >tr->offset_position - cd_ptr->pos_correction); active_ptr->reject_count++; new_offset = 0; slicejjffset = 0; active_align_key = "alignment.activejJtr; new_align_key = 0; active tr->align status = 0; > > else <. I* save debug information */ align_attempt = 0; active_align_key = 0; new_align_key = 0; slice offset = 0; >~ */ */ TITLE - sd_close_active - process closing of active area */ */ INPUTS - activejJtr */ */ */ OUTPUTS - modified active structure */ */ */ ABSTRACT - This procedure closes an active area by resolvin */ any remaining mismatches and trimming the end */ of the active data based on sweeps per bar */ */ */ */ */ d sd_close_active(C_PARMS "activejJtr) int i; unsigned int *aspb_ptr; unsigned int "intptr; /* resolve mi smatches sti l l in mi smatch array */ for (i ••• 0; i < mm size; i++) C /* see i f mm i n array */ i f (acti ve ptr->mm ptr [i] ! = 0) { /* mm i s not resolved, vote wi th sweeps per bar */ aspbjjtr = active_ptr->sweeps_per_bar + (active_ptr->mm_ptr [i] - act ivejJtr->active_buffer) ; i f (active ptr->πm_spb[i] > *aspb~ptr) - /* use mm data since more hi ts on i t */ "aspbjjtr = active_ptr->mm_spb[i] ; sd replace_transition(active ptr->mm_ptr [i] , &active_ptr->mm_data [i] .vat [1] ) ; > ~ /* clear mismatch */ active_ptr->mm_ptr [i ] = 0; > file: SD_TSD.C page: 36 date: Sat Sep 11 13:13:46 1993 2523 - /* set end of active buffer (trim transitions too few sweeps per bar) */ 2524 - aspbjjtr = active_ptr->sweepsjer_bar + (activejjtr->active_end - active_ptr->active_buffer); 2525 - intptr = activejtr->active_end; 2526 - 2527 - /* point to last space */ 2528 - while (("intptr & 0x00010000) == BLACK BAR) 2529 - < 2530 - intptr--; 2531 - aspb ptr--; 2532 - > 2533 - 2534 - /* trim space/bar pairs if space doesn't have enough sweeps */ 2535 - while ((intptr > activejJtr->active start) && ("aspbjjtr < min spb for_trim)) 2536 - t 2537 - /* back up to previous space */ 2538 - intptr-=2; 2539 - aspbjjtr-=2; 2540 - > 2541 - 2542 - /* set active end to last bar left after spb trimming */ 2543 - activejjtr->active_end = intptr + 1; 2544 - 2545 - 2546 - 2547 - 2548 - 2549 - 2550 - 2551 - 2552 - 2553 - 2554 - 2555 - 2556 - 2557 - 2558 - 2559 - 2560 - unsigned int bc_len_type, save_first, save nsweeps; 2561 - unsigned int ss_at_front, ss_a~_back; 2562 - unsigned int i, decode_status, old_sweep, older_sweep; 2563 - unsigned int *start_da~a_ptr, "end datajjtr; 2564 - unsigned int first_sweep_count, second_sweep_count; 2565 - C_PARMS "activejJtr; 2566 - I_ ARMS "ignore ptr; 2567 - COUNT DATA *old~cd_ptr; 2568 - 2569 - /* reset counts * 2570 - transition_count 0; 2571 - data_count = 0; 2572 - 2573 - /* increment scan count */ 2574 - scan_count++; 2575 - 2576 - /* calculate transition count */ 2577 - transi tion_count = (cdj tr->scan_end - cd_ptr->scan_start + 1 ); 2578 - 2579 - /* find bars and spaces */ 2580 - while (sd find bs(cd_ptr)) 2581 - { 2582 - /* calculate data count */ 2583 - data_count = (cdjjtr->data_end - cd_ptr->data_start + 1); 2584 - 2585 - /* reset debug variables */ 2586 - mismatch_count = 0; 2587 - margin_atign_status = FALSE; 2588 - 2589 - /* check for fragment overlapping ignore area */ 2590 - if (!sd_ignore area(cd ptr)) 2591 - C 2592 - /" check if fragment is in an area which is already active */ file: SD_TSD.C page: 37 date: Sat Sep 11 13:13:46 1993 l ine 2593 - i f ( (activejJtr = sd_active area(cd_ptr) ) == 0) 2594 - { 2595 - /* create active area based on new unassociated fragment */ 2596 - if ((active ptr = sd add active area(cdjjtr)) != 0) 2597 - - 2598 - /* set members of active structure */ 2599 - active_area_count++; 2600 - active_ptr->spb_lock = spb_lock; 2601 - active_ptr->ss_found = FALSE; 2602 - active_ptr->offsetj osi tion = 0; 2603 - activej tr->offset os_of_rej = 0; 2604 - activejjtr->code_di rection = activej tr->sweep_di recti on = FWD; 2605 - active_ptr->bars_found = TRUE; 2606 - activejJtr->fragment_count = 0; 2607 - active tr->empty_sweeps = 0; 2608 - activejjtr->codeJtype = 0; 2609 - for ( i = 0; i < mmjsi ze; i++) activejJtr->mmj tr [i] = 0; 2610 - active_ptr->f i rst_sweep_start = cd_ptr->data_start; 2611 - active_ptr->f i rst_sweep_end = cd_p~r->data_end; 2612 - activej tr->sweep_count = 1 ; 2613 - active_ptr->active_start = active_ptr->active_end = active_ptr->active_buffer; 2614 - active_ptr->align_status = 0; 2615 - active_ptr->reject count = 0; 2616 - 2617 - /* check front for possible barcode */ 2618 - active_ptr->sweep_directioπ = FWD; 2619 - ss at front = sd_possible_barcode(active_ptr, cdjjtr); 2620 - 2621 - /* check front for possible barcode */ 2622 - active_ptr->sweep_direction = REV; 2623 - ss at back = sd possible barcode(activejJtr, cdjjtr); 2624 - 2625 - /* see if start/stop at front or back */ 2626 - if (Iss at_front && Iss at_back) 2627 - C 2628 - /* not a possible barcode, so don't allocate active area for it */ 2629 - sd_remove_active_area(active_ptr); 2630 - active area count--; 2631 - > ~ 2632 - > 2633 - > 2634 - else /* process case of fragment overlapping active area */ 2635 - { 2636 - /* increment sweep count */ 2637 - active_ptr->sweep_count++; 2638 - 2639 - /* if second sweep for this active area, lots of special things to do */ 2640 - if (active ptr->sweep_count == 2) 2641 - 2642 - /* check for ambiguous sweep direction or complete barcode cases */ 2643 - first_sweep_count = active_ptr->first_sweep_end - active_ptr->first_sweep_start + 1; 2644 - second_sweep_count = cd_ptr->data_end - cd_ptr->data_start + 1; 2645 - if (first sweep_count == second sweep_count) 2646 - { 2647 - /* check length to see if good barcode length */ 2648 - if (be len type = sd barcode length(second sweep count)) 2649 - 2650 - /* check front of buffer for start/stop */ 2651 - active_ptr->sweep_direction = FWD; 2652 - if (ss at front = sd possible_barcode(active ptr, cdjjtr)) 2653 - ( 2654 - /* check back of buffer for start/stop */ 2655 - active_ptr->sweep_direction = REV; 2656 - if (ss at back = sd possible barcode(activejjtr, cdjjtr)) 2657 - C 2658 - /* verify length, front and back are all same barcode type */ 2659 - if (ss at front == be len_type && ss at front == ss at back) 2660 - { " " 2661 - /* see if code is disabled */ 2662 - if (ss at front == CODE_OFF) 2663 - C 2664 - /* always ignore disabled barcodes */ file: SD TSD.C page: 38 date: Sat Sep 11 13:13:46 1993 line 2665 - sd_add_ignore_area(active_ptr); 2666 - ignore_area_count++; 2667 - sd_remove_active_area(active_ptr); 2668 - active area count--; 2669 - > 2670 - else 2671 - { 2672 - /* complete barcode is being received, set structure members */ 2673 - activejjtr->sweep_direction = FWD; 2674 - activejtr->ss found = ss at front; 2675 - 2676 - /* resolve sweep 1 to sweep 2 mismatches */ 2677 - sd resolve counts(activejJtr, cdjjtr); 2678 - 2679 - /* calculate position offset from sweep 1 to sweep 2 */ 2680 - sd average_offset(active_ptr, cdjjtr); 2681 - 2682 - /* copy fragment from count data buffer to active buffer */ 2683 - sd copy count data(activejjtr, cdjjtr); 2684 - 2685 - /* debug */ 2686 - if (mode == DEBUG) 2687 - { 2688 - sd storejjre_msg(cd_ptr, active ptr); 2689 - > " 2690 - } 2691 - > 2692 - > 2693 - > 2694 - > 2695 - 2696 - /" if not start/stop found then we have a case of */ 2697 - /* ambigous sweep direction caused by equal length fragments */ 2698 - /* wait for next sweep so size of fragment will be bigger */ 2699 - if ((active ptr->ss found) 2700 - < 2701 - /* debug */ 2702 - if (mode == DEBUG) 2703 - ( 2704 - sd store re msg(cdjjtr, activejJtr); 2705 - > ~ 2706 - 2707 - /* reset structure members for retry on next sweep */ 2708 - activejjtr->sweep_direction = FWD; 2709 - active_ptr->bars_found = TRUE; 2710 - active_ptr->fragment_count = 0; 2711 - active_ptr->empty_sweeps = 0; 2712 - active_ptr->first_sweep_start = cd_ptr->data_start; 2713 - active_ptr->first_sweep_eπd = cd_ptr->data_end; 2714 - activej)tr->sweep_count = 1; 2715 - active_ptr->align_status = 0; 2716 - active ptr->reject count = 0; 2717 - } 2718 - > 2719 - else 2720 - < 2721 - /* fragments are unequal in length so attempt margin alignment */ 2722 - if (margin align status = sd find direction(activejjtr, cdjjtr)) 2723 - < 2724 - /* look for start/stop based on margin direction */ 2725 - if (activejtr->ss found = sd possible barcode(active ptr, cd j jtr)) 2726 - ( 2727 - /* check for disabled code type */ 2728 - if (active ptr->ss found == CODE OFF) 2729 - < 2730 - /* always i gnore turned off code types */ 2731 - sd_add_ignore_area(activej>tr); 2732 - i gnore_area_count++; 2733 - sd_remove_active_area(active_ptr); 2734 - active area count--; 2735 - 2736 - /* debug */ file: SD_TSD.C page: 39 date: Sat Sep 11 13:13:46 1993 Iine 2737 - if (mode == DEBUG) 2738 - ( 2739 - sd storej-re msg(cd ptr, activejJtr) ; 2740 - > 2741 - > 2742 - else 2743 - { 2744 - /* start/stop found and not disabled */ 2745 - /* reverse all fragments if reverse sweep */ 2746 - if (activejitr->sweep direction == REV) 2747 - { 2748 - /* reverse count data, sweep 2. */ 2749 - sd_reverse_cd(cd_ptr); 2750 - /* reverse f i rst data, sweep 1 */ 2751 - sd_reverse f i rst(activejjtr); 2752 - > 2753 - /* resolve sweep 1 to sweep 2 mismatches */ 2754 - sd_resolve counts(active_ptr, cdjjtr); 2755 - 2756 - /* calculate position offset from sweep 1 to sweep 2 */ 2757 - sd average offset(activejjtr, cdjjtr); 2758 - 2759 - /* copy fragment from count data buffer to active buffer */ 2760 - sd copy count_data(active_ptr, cd_ptr); 2761 - 2762 - /* debug */ 2763 - if (mode == DEBUG) 2764 - C 2765 - sd store pre msg(cd ptr, activejJtr); 2766 - ~ 2767 - > 2768 - > 2769 - else 2770 - { 2771 - /* ignore area if no start/stop found and it's ok_to_ignore */ 2772 - if (ok to ignore) 2773 - - 2774 - /* ignore because no start/stop found */ 2775 - sd_add_ignore_area(active_ptr); 2776 - ignore_area_count++; 2777 - sd_remove_active_area(active_ptr); 2778 - active area count--; 2779 - 2780 - /* debug */ 2781 - if (mode == DEBUG) 2782 - { 2783 - sd_store_pre_msg(cd_ptr, active ptr); 2784 - > 2785 - } 2786 - else 2787 - C 2788 - /* debug */ 2789 - if (mode == DEBUG) 2790 - C 2791 - sd store pre_msg(cd_ptr, activejJtr); 2792 - > ~ 2793 - 2794 - /* don't ignore, set up for retry on next sweep */ 2795 - activejjtr->sweep_direction = FWD; 2796 - active_ptr->bars_found = TRUE; 2797 - active_ptr->fragment_count = 0; 2798 - active_ptr->empty_sweeps = 0; 2799 - active_ptr->first_sweep_start = cd_ptr->data_start; 2800 - active_ptr->first_sweep~end = cd_ptr->data_end; 2801 - active_ptr->sweep_count = 1; 2802 - active_ptr->align_status = 0; 2803 - activejtr->reject count = 0; 2804 - } 2805 - > 2806 - > 2807 - else 2808 - { file: SD_TSD.C page: 40 date: Sat Sep 11 13:13:46 1993 line 2809 - /* ignore area if no margin found and it's ok_to_ignore */ 2810 - if (ok to ignore) 2811 - C 2812 - /* ignore because no margin found */ 2813 - sd_add_ignore_area(active_ptr); 2814 - ignore_area_count++; 2815 - sd_remove_active_area(active_ptr); 2816 - active_area count--; 2817 - 2818 - /* debug */ 2819 - if (mode == DEBUG) 2820 - { 2821 - sd store re msg(cdjtr, activejJtr); 2822 - > ~ 2823 - > 2824 - else 2825 - < 2826 - /* debug */ 2827 - if (mode == DEBUG) 2828 - < 2829 - sd storejjre msg(cdj tr, active .tr); 2830 - > " 2831 - 2832 - /* don't ignore, set up for retry on next sweep */ 2833 - active_ptr->sweep_direction = FWD; 2834 - activejjtr->bars_found = TRUE; 2835 - active_ptr->fragment_count = 0; 2836 - active_ptr->empty_sweeps = 0; 2837 - active_ptr->first_sweep_start = cd_ptr->data_start; 2838 - active_ptr->first_sweep_end = cd_ptr->data_end; 2839 - active_ptr->sweep_count = 1; 2840 - active_ptr->align_status = 0; 2841 - active_ptr->reject count = 0; 2842 - > 2843 - > 2844 - > 2845 - > 2846 - else /* SWEEP COUNT > 2, so time for reconstruction */ 2847 - { 2848 - /* reverse all fragment is reverse sweep */ 2849 - if (active_ptr->sweep direction == REV) 2850 - { 2851 - sd reverse_cd(cdjjtr); 2852 - > ~ 2853 - 2854 - /* time to do what we came here to do */ 2855 - sd time slice(activejtr, cdjjtr); 2856 - 2857 - /* debug */ 2858 - if (mode == DEBUG) 2859 - { 2860 - sd_store_post msg(active ptr, cdjjtr); 2861 - > 2862 - > 2863 - } 2864 - > 2865 - 2866 - } /* end of while find bars/spaces */ 2867 - 2868 - /* check list of active pointers */ 2869 - for (i = 0; i < num of actjjtrs; i++) 2870 - -C 2871 - /* see if pointer is being used */ 2872 - activejJtr = active_ptrs [i] ; 2873 - i f (active ptr ! = 0) 2874 - ( 2875 - /* was fragment found to overlap this active area? */ 2876 - if (!activejtr->bars found) 2877 - { 2878 - /* have enough empty sweeps been seen to terminate this barcode */ 2879 - if (++active jtr->empty sweeps >= max_empty sweeps) 2880 - { f i le: SDJTSD .C page: 41 date: Sat Sep 11 13: 13:46 1993 tine 2881 - /* eliminate anything with only 1 sweep */ 2882 - if (active_ptr->sweep_count > 1) 2883 - { 2884 - /* close active area before attempting decode */ 2885 - sd_close active(activejjtr); 2886 - 2887 - /* reset status */ 2888 - decode status = 0; 2889 - 2890 - /* setup for normalize */ 2891 - start_data_ptr = activejtr->active_start; 2892 - end data ptr = active_ptr->active end; 2893 - 2894 - /* do the threshold normalize as both a 2 wide and a 4 wide and put in global buffer */ 2895 - sd threshold_norm(start datajjtr, endjdatajjtr); 2896 - 2897 - /* check for correct length and start/stop at both ends */ 2898 - if (sd barcode complete(activejtr)) 2899 - < 2900 - /* attempt to decode */ 2901 - if (decode status = sd decode(activejJtr)) 2902 - ( 2903 - /* good decode so save label data */ 2904 - label_struct.code_direction = activejjtr->code direction; 2905 - label_struct.sweep_direction = activejjtr->sweep direction; 2906 - label_struct.code_type = active_ptr->code_type; ~ 2907 - label_struct.position = active_ptr->end_position » 7; 2908 - label struct.full position = actιve_ptr->end josition; 2909 - label~struct.label valid = TRUE; 2910 - 2911 - /* count up good decodes */ 2912 - success count++; 2913 - 2914 - /* if not diagnostics */ 2915 - if (mode != DIAGF) 2916 - C 2917 - /* send label message */ 2918 - sd send labelO; 2919 - > ~ 2920 - } 2921 - ) 2922 - 2923 - if ("decode status) 2924 - { 2925 - /* do the normal i ze as both a 2 wide and a 4 wide and put in global buffer */ 2926 - sd_histo2_norm(start_data_ptr, endjdatajjtr) ; 2927 - sd histo4 norm(start_data ptr, endjdatajjtr) ; 2928 - 2929 - /* check for correct length and start/stop at both ends */ 2930 - if (sd barcode complete(active ptr)) 2931 - < ~ 2932 - /* attempt to decode */ 2933 - if (decode status = sd decode(active ptr)) 2934 - < 2935 - /* good decode so save label data */ 2936 - labeljstruct.codejdi rection = activejJtr->code_di rection; 2937 - label_struct.sweep_di rection = active_ptr->sweep_di rection; 2938 - labet_struct.code_type = active_ptr->code_type; 2939 - label_struct . posi tion = active_ptr->endjjosi tion » 7; 2940 - labeljstruct. ful ljjosi tion = active ptr->end_posi tion; 2941 - label_struct. label_val id = TRUE; 2942 - 2943 - /* count up good decodes */ 2944 - success count++; 2945 - 2946 - /" if not diagnostics */ 2947 - if (mode != DIAGF) 2948 - { 2949 - /* send label message */ 2950 - sd_send_label(); 2951 - > 2952 - > file: SD TSD.C page: 42 date: Sat Sep 11 13:13:461993 2956 - /* diagnostics */ 2957 - if (mode == DIAGE && active ptr->sweep count > 1) 2958 - < 2959 - sprintf(out_buf,"S%d",activejJtr->sweep_count); 2960 - sd_send_strTng(out_buf); 2961 - sprintf(out_buf,"B%d",active_ptr->active_end - active_ptr->active_start + 1); 2962 - sd send stringtout buf); 2963 - > " 2964 - 2965 - /* debug, stop and scan dump if no decode */ 2966 - if (mode == DEBUG) 2967 - { 2968 - if ((trapjioread && Idecode status && activejjtr->sweep_count > 5) | | 2969 - (trap~misread && decode~status && strcmp("*JITTER TEST*",label struct.label_buf))) 2970 - i 2971 - /* save missed sweeps */ 2972 - save msweeps = missed_sweeps; 2973 - 2974 - /* scan dump current and previous two scans */ 2975 - if (first_sweep == 0) old_sweep = SWEEP_BUF_SIZE - 1; 2976 - else old sweep = first sweep - 1; 2977 - 2978 - if (oldjsweep == 0) older_sweep = SWEEP_BUF_SIZE - 1; 2979 - else older_sweep = old sweep - 1; 2980 - 2981 - /* protect previous sweeps */ 2982 - save_first = first_sweep; 2983 - if (older sweep != last sweep &_, old sweep != last sweep) 2984 - t 2985 - first sweep = older sweep; 2986 - > 2987 - else if (old sweep != last sweep) 2988 - C 2989 - first_sweep = old sweep; 2990 - > 2991 - 2992 - /* output last sweep index */ 2993 - sprintf(out_buf,"\n\rLatest sweep buffer # is %d\n\r", last_sweep); 2994 - sd send string(out buf); 2995 - 2996 - if (old_sweep == last sweep M older sweep == last sweep) 2997 - C 2998 - sprintf(out_buf,"\n\rTwo back buffer (#%d) already overwritten\n\r", 2999 - older_sweep); 3000 - sd send_string(out buf); 3001 - > ~ 3002 - else 3003 - <_ 3004 - sprintf(out_buf,"\n\rTwo back sweep buffer (#%d)\n\r", older_sweep); 3005 - sd_send_string(out_buf); 3006 - old_cd_ptr = &cd_struct[older_sweep]; 3007 - old_cd_ptr->data_start = old_cdjjtr->scan_start; 3008 - old_cd_ptr->data~end = old_cd_ptr->scan_start; 3009 - sd_scan dump(old cdjjtr); 3010 - > 3011 - 3012 - if (old_sweep == last sweep) 3013 - { 3014 - sprintf(out_buf."Previous buffer (#%d) already overwritten\n\r", 3015 - oldjsweep); 3016 - sd_send string(out buf); 3017 - > 3018 - else 3019 - C 3020 - sprintf(out_buf,"Previous sweep buffer (#%d)\n\r", 3021 - old_sweep); 3022 - sd_send_string(out_buf); 3023 - old_cd_ptr = &cd_struct[oldjsweep]; 3024 - old_cd_ptr->data~start = old_cd_ptr->scan_start; file: SD TSD.C page: 43 date: Sat Sep 11 13:13:46 1993 l i ne 3025 - old_cd_ptr->data_end = old_cdj tr->scan_start; 3026 - sd scan dtmp(old cdjjtr) ; 3027 - > " 3028 - 3029 - firstjsweep = save_first; 3030 - sprintf(out_buf,"Current sweep buffer (#%d)\n\r",first_sweep); 3031 - sd_send_string(out_buf); 3032 - cd_ptr->data_start = cd_ptr->scan_start; 3033 - cdj tr->data_end = cd_ptr->scan_start; 3034 - sd scan du pTcdj tr); 3035 - 3036 - /* output missed sweeps */ 3037 - sprintf(out_buf,"\n\r***** Missed Sweeps = %d *****\n\r", savejnsweeps); 3038 - sd_send_string(out_buf); 3039 - missed sweeps = 0; 3040 - 3041 - /* empty debug message buffer */ 3042 - sd send_debug_msgs(); 3043 - 3044 - /* output header for future sweeps */ 3045 - /* sd send_string("\n\r***** CONTINUING IN SCAN DUMP MODE *****\n\r"); 3046 - mode = DIAGA; */ 3047 - 3048 - /* timeline exceeded, so restart */ 3049 - restart = TRUE; 3050 - > 3051 - } 3052 - 3053 - /* diagnostics, check and see if an attempt was made */ 3054 - if (active ptr->ss found) 3055 - C 3056 - attempt_count++; 3057 - ss found_count++; 3058 - > ~ 3059 - 3060 - /* diagnostics, update discard statistics */ 3061 - if (Idecode status) 3062 - ( 3063 - i = active_ptr->sweep count; 3064 - if (i > 9) i = 9; 3065 - sweepsjjer discard[i]++; 3066 - > 3067 - } /* end if sweep count > 1*/ 3068 - 3069 - /* no more bars so remove active area */ 3070 - sd_remove_active_area(active_ptr); 3071 - active_area_count--; 3072 - > /* end i? enough empty sweeps */ 3073 - > /* end if no more bars */ 3074 - else 3075 - ( 3076 - /* bars were found, so update area 's posi tion */ 3077 - activejjtr->startj osi tion = activej tr->new_start_pos; 3078 - active jtr->end_posi tion = active ptr->new endjjosj 3079 - 3080 - /* check for two fragments in this area and sweep */ 3081 - if (check frag count && active_ptr->fragment count > 1) 3082 - { 3083 - if ("SERIAL ENABLE) pprintf("f%d",active_ptr->fragment count); 3084 - } 3085 - 3086 - /* decide whether to ignore area based on too many rejected sweeps */ 3087 - if (active_ptr->reject count > max reject count) 3088 - { - - - 3089 - /* ignore the misassembling barcode */ 3090 - sd_add_ignore_area(active_ptr); 3091 - ignore_area_count++; 3092 - sd_remove_active_area(active_ptr); 3093 - active area count--; 3094 - >~ 3095 - > 3096 - file: SD_TSD.C page: 44 date: Sat Sep 11 13:13:461993 line 3097 - /* reset bars found flag, fragment count and align status for next sweep */ 3098 - active_ptr->bars_found = FALSE; 3099 - active_ptr->fragment_count = 0; 3100 - active_ptr->align_status = 0; 3101 - active_ptr-:reject count = 0; 3102 - > 3103 - ) 3104 - reajrount == 0) | 3153 - /* save missed sweeps before more are missed */ 3154 - save msweeps = missed sweeps; 3155 - 3156 - /* update total counts */ 3157 - total_attempt_count += attempt_count; 3158 - total_success_count += success~count; 3159 - total_missed_sweeps += savejnsweeps; 3160 - total_active_areas += active_areas; 3161 - total_ignore_areas += ignore_areas; 3162 - total_marg_align_count += marg_align_count; 3163 - total_ss_found_count += ss_found_count; 3164 - for (i=0;i<10;i++) total_sweeps_per discardCi] += sweeps_per discardli]; 3165 - 3166 - /* clear screen */ 3167 - sd send string("\f"); 3168 - file: SD TSD.C page: 45 date: Sat Sep 11 13:13:46 1993 line 3169 - /* output label or no read */ 3170 - if (label struct.label_valid) 3171 - sd send labeK); 3172 - else ~ 3173 - sd send stringC'No Read\n\r"); 3174 - 3175 - /* output read statistics */ 3176 - sd send stringC'Current Read Statistics\n\r attempt success read rate missed sweeps\n\r"); 3177 - sprintfToutJjuf," %4d %4d %3d %d\n\r\n\r», 3178 - attempt_count, success_count, (100 * success_count) / attempt_count, 3179 - save_msweeps); 3180 - sd_send_string(out_buf); 3181 - sd send stringC'Cumulative Read Statistics\n\r attempt success read rate missed sweeps\n\r"); 3182 - spfintfTout_buf,"%6d X8d 3d %d\n\r\n\r», 3183 - total_attempt_count, total_success_count, 3184 - (100 * totat_success_count) / totaT_attempt_count, 3185 - total_missed_sweeps); 3186 - sd send string(out buf); 3187 - 3188 - /* output active,ignore statistics */ 3189 - sd send stringC'Current Active Area Statistics\n\r active areas ignore areas margins aligned start/s 3190 - sprintfloutjuf," 5S4d %4d X3d %d\n\r", 3191 - active_areas, ignore_areas, marg_align_count, ss_found_count); 3192 - sd send string(out buf); 3193 - sprintf7out_buf," sweeps-discards: H-%ά 1-%d 2-%d 3-%d 4-%d 5-%d 6-%d 7-%d 8-%d >8-%d\n\r\n\r", 3194 - sweeps_per_discard[0] , sweeps_per_discardC13 , sweeps_per_discard[2] , 3195 - sweeps_per_discardC3] , sweeps_per_discardC4] , sweeps_per_discard[5] , 3196 - sweeps_per_discard[6] , sweeps_per_discard[7] , sweeps_per_discard[8] , 3197 - sweeps_per_discardC9] ); 3198 - sd_send_string(out_buf); 3199 - sd send stringC'Cumulative Active Area Statistics\n\r active areas ignore areas margins aligned sta 3200 - sprintfToutJjuf," 5S4d X4d %3d 5Sd\n\r", 3201 - total_ac~ive_areas, totat_ignore_areas, total_marg_align_count, total_ss_found_count); 3202 - sd send string(out_buf); 3203 - sprintf7out_buf ," sweeps-discards: 0-%d 1 -%d 2-%d 3-%d 4-%d 5-%d 6-%d 7-%d 8-%d >8-%d\n\r\n\r", 3204 - total_sweeps_per_discardCO] , total_sweeps_per_discardC1] , total_sweeps_per_discard[2] , 3205 - total_sweeps_per_discardC3] , total_sweeps_per_discardC4] , total_sweeps_per_discardC53 , 3206 - total~sweepsj erjdi scardC6] , total_sweepsj er_discardC7] , total~sweeps_per~discardC8] , 3207 - total_sweeps_per_di scardC9] ); 3208 - sd send string(out buf ); 3209 - 3210 - /* reset variables for next sequence */ 3211 - labet_struct.label_valid = FALSE; 3212 - attempt_count = success_count = missed_sweeps = 0; 3213 - active_areas = ignore_areas = marg_align_count = ss_found_count = 0; 3214 - for (i=0;i<10;i++) sweepsjjer discardCi] = 0; 3215 - } 3216 - 3217 - /* debug, send debug msg if no active areas */ 3218 - if (mode == DEBUG && active_area count == 0) 3219 - C 3220 - /* output collected messages */ 3221 - /* sd send debug_msgs(); */ 3222 - 3223 - /* reset debug buffer */ 3224 - debugjnsgjtr = debug_msg_buffer; 3225 - *debug_msg_ptr = 0; 3226 - 3227 - /" timeline exceeded so restart */ 3228 - /* restart = TRUE; */ 3229 - > 3230 - > file: SD PARM.C page: 1 date: Sat Sep 11 13:16:56 1993 0029 - #include "sd_tsd.h" 0030 - 0031 - /* adjustable data parameters */ 0032 - unsigned int update_bar_motion = 0; /* enable flag for continuous update of predicted bar motion */ 0033 - unsigned int req_good_hits = 6; /* number of good matches required at leading and trailing margi 0034 - unsigned int spb_tock = 3; /* minimum sweep count on a bar or space to lock that value 0035 - unsigned int ιmn_edge_to_edge = 1; /* edge to edge(t-distance)=1 or center to center=0 */ 0036 - unsigned int mmjnethod = MMPCT; /* bar-bar space-space mismatch method, percent or threshold */ 0037 - unsigned int mm jercentjaower = 2; /* percetage allowed mismatch as binary power (i.e. 0=100%, 1=50 0038 - unsigned int mm_limit = 10; /* theshold limit on bar-bar or space-space mismatch */ 0039 - unsigned int align_key_offset = 6; /* bar/space offset of align key foward from end of good data ov 0040 - unsigned int axjnismaϊch = 0; /* maximum number of mismatches allowed in compare window */ 0041 - unsigned int data_max_threshold = 0x150; /* maximum bar/space width required by fragment finding algorith 0042 - unsigned int data_min_threshotd = 0x010; /* minimum bar/space width required by fragment finding algorith 0043 - unsigned int find_count = 11; /* minimum length required by fragment finding algorithm */ 0044 - unsigned int mismatch_limit = 1; /* maximum allowed mismatches of margin compare algorithm */ 0045 - unsigned int match_limit = 9; /* number of bar-bar/space-space co parisions margin compare 0046 - unsigned int mm_size = MM_SIZE; /* size of mismatched data buffer */ 0047 - unsigned int ok_to_ignore = 0; /* enable flag to ignore areas without an immediate start/stop * 0048 - unsigned int max_empty_sweeps = 2; /* number of empty sweeps required before closing an active area 0049 - unsigned int min_good_overlap = 1; /* mimim n good overlap required for fragment accept */ 0050 - unsigned int do_mismatch_reject = 1; /* enable flag for comparision of the entire good overlap to dec 0051 - unsigned int mm_pct_frag = 1; /* miminum percent required of good over lap to be matches, 0052 - unsigned int linear_search = 1; /* search method for new alignment key find algorithm, 1=assume 0053 - unsigned int alternate_align_key = 0; /* enable flag for alternating the active align key */ 0054 - unsigned int max_reject_count = 1000000; /* maximum number of rejected fragments allowed in a row */ 0055 - unsigned int min_spb_for_trim = 1; /* minimum sweep count on bar/space required to avoid trim befor 0056 - unsigned int check_frag_count = 0; /* enable flag for error message on multiple fragments per area 0057 - unsigned int percent_tsd_update = 8; /* number of decode attempts between percent tsd screen updates 0058 - volatile unsigned int sweep_freq_factor = 1; /* sweep frequency division factor */ 0059 - volatile unsigned int check_final_pos = 0; /* send message on bad final position */ 0060 - volatile unsigned int correct_encoder = 1; 0061 - unsigned int max_align_aperature_width = 5; 0062 - 0063 - file: SD SWEEP.C page: 1 date: Sat Sep 11 13:31:02 1993 0028 0029 - #include "sd_gen.h" 0030 - #include "sd_diags.h" 0031 - #include "sd_sweep.h" 0032 - #include "sd_com.h" 0033 - #include "sd arm.h" 0034 0035 - /* global variables */ 0036 0037 - /* version strings */ 0038 - char sd_sweep_c_net[] = "Net SModtime: 03 Jun 1993 19:57:50 $"; 0039 - char sd_sweep_c_loc[] = "Local $Id: sd_sweep.c 1.2893/09/11 13:31:03 dan Exp $"; 0040 0041 - /* sweep interrupt debug variables */ 0042 - volatile unsigned int sweep_tick = 0; 0043 - volatile unsigned int missed_sweeps = 0; 0044 - volatile int bufferjackup = 0; 0045 - volatile int home_resync = 0; 0046 0047 - /* encoder calibration */ 0048 - volatile unsigned int current_facet = 1; 0049 - volatile unsigned int mtr_spd = 0; 0050 - volatile unsigned int facet_pos_ref = 0; 0051 - volatile unsigned int cal ' nitialized = FALSE; 0052 - volatile unsigned int facet_final_pos(8] = (0, 0, 0, 0, 0, 0, 0, 0>; 0053 - volatile unsigned int encoder_cor?ection_hold_count = 0; 0054 - volatile unsigned int eos_gliTch_min = 0x70; 0055 - volatile unsigned int eos_glitch~max = 0x90; 0056 0057 - /* video buffer queue variables */ 0058 - volatile unsigned int firstjsweep; 0059 - volatile unsigned int last_sweep; 0060 - volatile unsigned int *new_sweep; 0061 - volatile unsigned int *droaO_flyby = DMA0_FLYBY_ADDR; 0062 0063 - /* video data and data pointer buffers */ 0064 - COUNT_DATA cdjstruct[SWEEP BUF SIZE]; 0065 - unsigned int sweep_buffer[SWEEP_BUF_SIZE] C1024] ; 0066 0067 /* 0068 /* 0069 /* TITLE - init_sweep_dma - initialize video dma channel 0070 /* 0071 /* INPUTS - none 0072 /* file: SD SWEEP.C page: 2 date: Sat Sep 11 13:31:02 1993 0088 /* stop dma transfer and interrupt */ 0089 asm ("clrbit 0,sf2,sf2"); 0090 asm ("clrbit 0,sf1,sf1"); 0091 asm ("clrbit 8,sf1,sf1"); 0092 0093 /* reset fifos (if resetting fifo is desired temp must be volatile) */ 0094 /* in other words this instruction doesn't work as is! */ 0095 temp = "RESET_FIF0; 0096 file: SD_SWEEP.C page: 3 date: Sat Sep 11 13:31:02 1993 line 0145 - void sd_sweep int(void) 0146 - < 0147 - int save_last , facet_ndx, count; 0148 - unsi gned int *scan_end, *scan_start , save_last_pos; 0149 - unsigned int absj os_correction; 0150 - unsigned int ok f inaljjos, f inaljjos; 0151 - 0152 - /* code to allow breakpoints in int routine */ 0153 - asm ("mov 1,r3"); 0154 - asm ("tnodpc 1,1,r3"); 0155 - asm ("mov r3,r3"); 0156 - asm ("mov r3,r3"); 0157 - asm ("mov r3,r3"); 0158 - asm ("mov r3,r3"); 0159 - 0160 - /* sweep interrupt 'pulse' */ 0161 - sweep tick++; 0162 - 0163 - /* count down hold off of encoder correction */ 0164 - i f (encoder correction hold count) encoder_correcti on_hold count- - ; 0165 - 0166 - /* disable dma and mask interrupt "/ 0167 - asm ("clrbit 0,sf2,sf2"); 0168 - asm ("clrbit 0,sf1,sf1"); 0169 - asm ("clrbit 8,sf1,sf1"); 0170 - 0171 - /* flush dma control registers to internal data ram */ 0172 - /* now *dmaO_flyby is the next address to which dma channel 0 was going to write */ 0173 - asm ("udma"); 0174 - 0175 - /* setup scan pointers */ 0176 - scan_start = &sweep_buffer[last_sweep] [0]; 0177 - scan end = (unsigned int *)(*dma0 flyby) - 1; 0178 - 0179 - /* check for empty scan */ 0180 - cd_struct Clast_sweep) .empty uffer = 0; 0181 - if 7(scan end - scan start + 1 ) == 0) 0182 { 0183 - scan_end = scan_start; 0184 - *scan_end = 0x80000000; 0185 - cd structClast sweep].empty buffer = 1; 0186 > 0187 - 0188 - /* calculate index for current facet */ 0189 - facet_ndx = current facet - 1; 0190 - 0191 - /* set facet final position */ 0192 - save_last_pos = facet_final_pos[facet_ndx]; 0193 - if (!encoder_correction_hold_count) 0194 - { 0195 - facet_f inal pos [facet ndx] = ("scan end) » 17; 0196 ) 0197 - 0198 - /* back up to good final position */ 0199 - ok_final_pos = 0; 0200 - count = θJ 0201 - while ((scan_end > scan start) && !ok_finaljos) 0202 - { 0203 - final pos = (*scan_end) » 17; 0204 - 0205 - if ((final pos <= MAX_8MHZ_P0S) && (finaljjos >= MIN 8MHZ POS)) 0206 - i C 0207 - ok final pos = 1; 0208 - > ~ 0209 - 0210 - if (!ok final pos) 0211 - { 0212 - scan_end--; 0213 - count++; 0214 - > 0215 - > 0216 - file: SD_SWEEP.C page: 4 date: Sat Sep 11 13:31:021993 line 0217 - /* set bad final position */ 0218 - if (ok final pos) 0219 - C ~ 0220 - cd structClast sweep].bad finaljjos = 0; 0221 - > " 0222 - else 0223 - I 0224 - if (facet f inal jos [facet ndx] ) 0225 - { 0226 - cd struct [last sweep] .bad_f i nal JOS = facet_f i nal _pos [facet ndx] ; 0227 > ~ 0228 - else 0229 - { 0230 - cd structClast sweep].bad finaljjos = 0x7fff; 0231 - > ~ 0232 - > 0233 - 0234 - /* reset facet final position */ 0235 - if (!encoder correction hold count) 0236 - < 0237 - facet f inal_pos [facet_ndx] = ("scan end) » 17; 0238 > 0239 - 0240 - /* make sure to set save last */ 0241 - save last = last_sweep; 0242 - 0243 - /* see if time to save sweep */ 0244 - if (sweep tick % sweep freq_factor == 0) 0245 < 0246 - /* set count data struture */ 0247 - cd_struct[last_sweep].scan_end = scan_end; 0248 - cd_structctast_sweep].scan_start = scan_start; 0249 - cd_structclast_sweep].data_start = scan_start; 0250 - cd_structClast_sweep].data_end = scan_start; 0251 - cd structClast sweep].facet = current facet; 0252 - 0253 - /* calculate next buffer index */ 0254 - save_last = last sweep; 0255 - tast~sweep = (++Tast sweep) % SWEEP BUF SIZE; 0256 - 0257 - /* make sure buffers are not full */ 0258 - if (last sweep == first sweep) 0259 - { 0260 - /* buffers full so write over newest sweep */ 0261 - last_sweep = save_last; 0262 - missed sweeps++; 0263 - 0264 - /* signal buffer backup */ 0265 - buffer backup = 1; 0266 - 0267 - /* increment position correction for the next sweep (facet_ndx is for the last sweep) */ 0268 - cd structClast sweep).pos_correction += facet finaljjosCfacet ndx] - facet jos ref; 0269 > ~ 0270 - else 0271 - < 0272 - /* signal no buffer backup */ 0273 - buffer backup = 0; 0274 - 0275 - /* store position correction for the next sweep (facet_ndx is for the last sweep) */ 0276 - cd structClast sweep].pos correction = (facet_final posCfacet ndx] - facetjjos ref); 0277 > ~ 0278 - > 0279 - else 0280 - < 0281 - /* increment position correction for this next sweep (facet_ndx is for the last sweep) */ 0282 - cd structClast sweep].pos_correction += facet inaljjosCfacet ndx] - facetjjos ref; 0283 } ~ 0284 - 0285 - /* increment facet number */ 0286 - current_facet = (current_facet % 8) + 1; 0287 - home resync = 0; 0288 - if ( » scan_end & 0x00010000) file: SD SWEEP.C page: 5 date: Sat Sep 11 13:31:021993 line 0289 - { 0290 - if (current_facet != 1) home_resync = 1; 0291 - current facet = 1; 0292 - } 0293 - 0294 - /* calculate new buffer location */ 0295 - new sweep = &sweep buffer[last sweep] [0]; 0296 - 0297 - /* setup and enable dma */ 0298 - asm ("Idconst 0x1000,r4"); /* byte count = 4Kbytes */ 0299 - asm ("Ida _new sweep,r5"); /* flyby address */ 0300 - asm ("Id (r5),r5"); /* get the address */ 0301 - asm ("Idconst 0x008b, r3"); /* control word */ 0302 - /* 32 bit flyby, destination increment */ 0303 - /* source increment, demand synchronized */ 0304 - /* source synchronized, eop */ 0305 - /* no chaining */ 0306 - asm ("sdma 0,r3,r4"); /* setup dma */ 0307 - asm ("setbit 21,sf2,sf2"); /* set dma throttle bit */ 0308 - asm ("mov r3,r3"); /* wait for sdma to finish */ 0309 - asm ("mov r3,r3"); 0310 - asm ("mov r3,r3"); 0311 - asm ("mov r3,r3"); 0312 - asm ("mov r3,r3"); 0313 - asm ("mov r3,r3"); 0314 - asm ("mov r3,r3"); 0315 - asm ("mov r3,r3"); 0316 - asm ("udma"); 0317 - asm ("setbit 0,sf2,sf2"); /* enable dma */ 0318 - 0319 - /* dont apply position correction until cal initialized */ 0320 - /* or if position corrections are not enabled */ 0321 - if (leal initialized || !correct_encoder) 0322 - { 0323 - cd structClast sweep].pos correction = 0; 0324 - > ~ 0325 - 0326 - /* check for encoder gl i tch */ 0327 - cd_struct [last_sweep] .eos_gl i tch = 0; 0328 - absjjos_correction = (cd_struct Clast_sweep] .pos_correction < 0)?(-cd_struct Ctast_sweep] ,pos_correcti on) : ( 0329 - if ( (current_facet == 1 1 1 current_facet == 2) && (abs_pos_correcti on > (eos gl itch min»1 ) && absjjos co 0330 - { 0331 - cd structClast sweep],eos glitch = 1; 0332 - > ~ 0333 - else if (abs pos correction > eos glitch min && absjjos correction < eos glitchjnax) 0334 < 0335 - cd structClast sweep).eos glitch = 1; 0336 - > " 0337 - 0338 - i f (cd struct [last_sweep] .eos gl i tch) 0339 - i ~ 0340 - encoder correction hold count = 24; 0341 - 0342 - cd_struct [last_sweep] .pos_correction -= (facet_final_pos [facet_ndx] - facetjJθs_ref ) ; 0343 - facet_f inalj os [facet_ndx] = save_last_pos; 0344 - cd struct Clast sweep] . pos correction += (facet final pos Cfacet ndx] - facetjjos ref ) ; 0345 - } ~ 0346 - 0347 - /* calculate encoder calibration if on facet 1 and facet 2 has been init 0348 - and correction algorithm is not being held off */ 0349 - if (lencoder correction hold count) 0350 - { 0351 - if (eurrent_facet == 1 && facet final_pos[1] != 0) 0352 - i 0353 - mtr_spd = 0; 0354 - for (facet ndx = 0; facet ndx < 8; facet ndx++) 0355 - C 0356 - mtr spd += facet f inaljjos [facet ndx] ; 0357 - > 0358 - facetjjos_ref = mtr_spd / 8; 0359 - /* calculate glitch values (» 7 approximates divide by 125) */ 0360 - eos_glitch_min = (facet_pos_ref » 7) - 0x18; file: SD SWEEP.C page: 6 date: Sat Sep 11 13:31:02 1993 line 0361 - eos_glitch_max = (facetjos_ref » 7) + 0x18; 0362 - cal initialized = TRUE; 0363 - > 0364 - > 0365 - 0366 - asm ("setbit 0,sf1,sf1"); /* set int mask to enable end-of-sweep int */ 0367 - asm ("setbit 8,sf1,sf1"); /* set int mask to enable terminal count int */ 0368 - > 0369 -

Claims: CLAIMS 1. A device for reading machine readable code, comprising: (a) scanning means for successively scanning the code and for outputting a signal representative of at least a portion of the code, for each successive scan of the code; (b) signal processing means for processing each of said signals outputted by said scanning means, said signal processing means further providing signal identification data, including a width and position associated with each of said signals, for each successive scan of the code; and (c) data processing means for reconstructing the code from said signal identification data for each successive scan of the code provided by said signal processing means, said data processing means also comprising, (i) position aligning means for positionally aligning succeeding scans, wherein said position aligning means comprising, means for selecting an element in a previous scan, means for calculating the position of that element in a successive scan based upon a calculated offset, said calculated offset determined by an offset calculating means which calculates the difference in position of features in previous scans, and means for aligning said successive scan with said previous scan by means of said calculated offset by placing said selected element in said successive scan in alignment with said selected element in said previous scan, and (ii) alignment verification means for verifying the alignment between said previous scan and said successive scan performed as a result of said means for aligning, wherein said alignment verification means further comprises means for attempting a predetermined number of additional alignments between said previous scan and said successive scan when said previous scan and said successive scan are not aligned by said alignment verification means. 2. The device according to claim 1, in which said data processing means further comprises means for both combining and accumulating said signal identification data. 3. The device according to claim 2, in which said offset calculating means further comprises a first offset calculating means for calculating a positional difference between the position of a selected code element in a first scan of a code, from said combining and accumulating means, and the position of the selected code element in a second scan of the code to provide said calculated offset for determining the expected position of the selected code element in the successive scan. 4. The device according to claim 3, wherein said alignment verification means further comprises a first verifying means for verifying the alignment between the first scan and the second scan based upon an occurrence of a predetermined number of mismatches when an alignment of leading edge margins of both the first and second scans is performed. 5. The device according to claim 4, wherein said means for attempting a predetermined number of additional alignments of said alignment verification means comprises a first attempt means for attempting to align the first scan with said second scan by comparing trailing edge margins of both the first and second scans. 6. The device according to claim 5 in which said offset calculating means further comprises: a second offset calculating means for calculating a positional difference between the position of a selected code element from a previous scan from said combining and accumulating means and the position of said selected code element from a successive scan to provide said calculated offset for determining the expected position of the selected code element in the successive scan. 7. The device according to claim 6 in which said position aligning means further comprises an offset averaging means for averaging said calculated offsets for previous scans with the calculated offset determined by said second offset calculating means to provide a refined calculated offset for determining the expected position of the selected code element in the successive scan. 8. The device according to claim 7 in which said position aligning means further comprises means for locating a code element in a scan which most closely matches the expected position of the selected code element in said scan by means of said calculated offset determined by said first offset calculating means, said second offset calculating means or said offset averaging means. 9. The device according to claim 8, in which said data processing means further comprises means for determining the number of scans in which a code element has been seen. 10. The device according to claim 9, wherein said alignment verification means further comprises a second verifying means for verifying the alignment between a previous scan and said successive scan by comparing width data of a predetermined number of transitions in said previous scan and corresponding transitions in said successive scan. 11. The device according to claim 10, wherein said means for attempting additional alignments of said alignment verification means comprises a second attempt means for attempting to align a previous scan with a successive scan by comparing a bar proximate to an alignment bar of said successive scan with said alignment bar of said previous scan, and repeating this step for a predetermined number of additional bars proximate to said alignment bar of said successive scan provided said previous scan and said successive scan are not aligned. 12. The device according to claim 11, in which said data processing means further comprises: means for positionally aligning said signal identification data in said combining and accumulating means with the signal identification data of a successive scan by means of said calculated offset by placing said selected element in said successive scan in alignment with said selected element in said previous scan; means for identifying width mismatches between aligned signal identification data, where said combining and accumulating means cooperates with said mismatch identifying means such that mismatched signal identification data is not combined and accumulated; and means for retaining said signal identification data, from said signal processing means, identified as having width mismatches. 13. The device according to claim 12, in which said data processing means further comprises means for resolving identified width mismatches, identified by said mismatch identifying means, by comparing width data from three scans of signal identification data. 14. The device according to claim 13, wherein said mismatch resolving means compares the width data for corresponding code elements in the first scan with width data from the third scan to determine if the corresponding widths are consistent and compares the width data for corresponding code elements in the second and third scans to determine if the corresponding widths are consistent. 15. The device according to claim 14, in which said mismatch resolving means further comprises means for indicating that the signal identification data for the scans having consistent widths is to be combined in the combining and accumulating means and that signal identification data for the other scan is to be ignored. 16. The device according to claim 15 in which said data processing means further comprises: scan direction means for determining the direction of a scan; and data reversing means, responsive to said scan direction means, for reversing the signal identification data for each code element in each scan for a bar code such that the signal identification data for all scans of the bar code is maintained in a predetermined direction. 17. The device according to claim 16, in which said data processing means further comprises: means for identifying a first area for which signal identification data is to be accumulated; and means for identifying a second area for which signal identification data is not to be accumulated. 18. The device according to claim 17 in which said data processing means further comprises a first means for comparing the signal identification data for each scan, from said signal processing means, to determine if the signal identification data overlaps said first area. 19. The device according to claim 18 in which said data processing means further comprises a second means for comparing the signal identification data for each scan, from said signal processing means, to determine if the data overlaps said second area. 20. The device according to claim 19, wherein said means for identifying a second area identifies areas containing machine readable code that is not to be decoded. 21. The device according to claim 20 wherein said elements comprise a plurality of intervals including bars and spaces of either narrow or wide interval widths and in which said data processing means further comprises: means for measuring the interval widths of said signal identification data, from said combining and accumulating means, and for normalizing the interval widths to 1,2,3, and 4 wide bars and spaces to provide a reconstructed bar code; and means for decoding the reconstructed bar code to provide the encoded information. 22. The device according to claim l, in which said scanning means further includes at least one light source and sensing means for successively illuminating a bar code with a predetermined pattern of light and successively sensing light reflected from the bar code. 23. The device according to claim 1, in which said scanning means further includes a plurality of light source and sensing means for successively illuminating a bar code with a predetermined pattern of light and successively sensing light reflected from the bar code. 24. The device according to claim 23, in which said light source and sensing means further includes a coherent light source. 25. The device according to claim 24, in which said scanning means further includes a light directing means for directing the light from said coherent light source to create the predetermined pattern of light. 26. A method for reading machine readable code, comprising the steps of: scanning the code to provide a signal representative of at least a portion of the code, and repeating scanning to obtain signals for additional portions of the code; successively processing each signal representative of the portion of the code obtained from each scan to provide signal identification data, including a width and position associated with each of said signals, for each successive scan of the code; and reconstructing the code from said signal identification data for each successive scan of the code, said reconstructing including the steps of: selecting an element in a previous scan; calculating the position of said element in a successive scan based upon a calculated offset, said calculated offset determined by the step of: calculating the difference in position of features in previous scans; and aligning said successive scan with said previous scan by means of said calculated offset by the step of: placing said selected element in said successive scan in alignment with said selected element in said previous scan; verifying the alignment between said previous scan and said successive scan performed as a result of step of aligning, wherein said step of verifying further comprises the step of: attempting a predetermined number of additional alignments between said previous scan and said successive scan when said previous scan and said successive scan are not aligned by said step of aligning. 27. The method according to claim 26, further comprising the steps of combining and accumulating said signal identification data. 28. The method according to claim 27, in which said step of calculating the position further comprises the step of: calculating a first positional difference between the position of a selected code element in a first scan of a code, from said step of combining and accumulating, and the position of said selected code element in a second scan of the code to provide said calculated offset for determining the expected position of the selected code element in the successive scan. 29. The method according to claim 28, wherein said step of verifying further comprises the step of: comparing leading edge margins of both the first and second scans to verify the alignment of the first and second scans based upon an occurrence of a preset amount of mismatches. 30. The method according to claim 29, wherein said step of attempting additional alignments of said step of verifying the alignment comprises the step of: comparing a trailing edge margins of both the first and second scans to attempt to align the first scan with said second scan. 31. The method according to claim 30, in which said step of calculating the position of a selected code element further comprises the step of: calculating a second positional difference between the position of a selected code element from a previous scan, from said step of combining and accumulating, and the position of said selected code element from a successive scan to provide said calculated offset for determining the expected position of the selected code element in the successive scan. 32. The method according to claim 31, in which said step of selecting and aligning further comprises the step of: averaging said calculated offsets for previous scans with the calculated offset from said step of calculating a positional difference to provide a refined calculated offset for determining the expected position of the selected code element in the successive scan. 33. The method according to claim 32, in which said reconstructing further comprises the step of: locating a code element in a scan which most closely matches the expected position of the selected code element in said scan by means of said first positional difference, said second positional difference or said refined calculated offset. 34. The method according to claim 33, in which said reconstructing further comprises the step of determining the number of scans in which a code element has been seen. 35. The method according to claim 34, in which said step o selecting further comprises the step of selecting a code element, from said combining and accumulating means, which has been seen i at least two scans. 36. The device according to claim 35, wherein said step o verifying the alignment further comprises the step of: comparing a second alignment of the width data of predetermined number of transitions in said previous scan an corresponding transitions in said successive scan to verify th alignment between the previous scan and said successive scan. 37. The device according to claim 36, wherein said step o attempting additional alignments of said step of verifying th alignment comprises the step of: comparing a bar proximate to an alignment bar of sai successive scan with said alignment bar of said previous scan t attempt to align said previous scan with said successive scan; an repeating said step of comparing for a predetermine number of additional bars proximate to said alignment bar of sai successive scan when said previous scan and said successive sca are not aligned by said step of aligning. 38. The method according to claim 37, in which sai reconstructing further comprises the steps of: positionally aligning said signal identification data in sai step of combining and accumulating with the signal identificatio data of a successive scan by means of said calculated offset b placing said selected element in said successive scan in alignmen with said selected element in said previous scan; identifying mismatches of code element widths between aligne signal identification data, where said step of combining an accumulating cooperates with said identifying mismatches such tha mismatched signal identification data is not combined an accumulated; retaining said signal identification data which has bee identified, from said identifying mismatches, as having widt mismatches. 39. The method according to claim 38, in which said reconstructin further comprises the step of resolving identified width mismatche from said identifying mismatches identifying means, by comparin width data from three scans of signal identification data. 40. The method according to claim 39, wherein said resolvin mismatches further compares the width data for corresponding cod elements in the first scan with width data from the third scan t determine if the corresponding widths are consistent and compare the width data for corresponding code elements in the second a third scans to determine if the corresponding widths ar consistent. 41. The method according to claim 40, in which said resolvi mismatches further comprises the step of indicating that the sign identification data for the scans having consistent widths is to combined in the combining and accumulating means and that sign identification data for the other scan is to be ignored. 42. The method according to claim 41, in which said reconstructi further comprises the steps of: determining the direction of a scan; and reversing the signal identification data for each code eleme in each scan for a bar code in response to said determining t scan direction, such that the signal identification data for a scans of the bar code is maintained in a predetermined directio 43. The method according to claim 42, in which said reconstructi further comprises the steps of: identifying a first area for which signal identification da is to be accumulated; and identifying a second area for which signal identification da is not to be accumulated. 44. The method according to claim 43, in which said reconstructi further comprises the step of comparing the first area with t signal identification data for each scan, from said sign processing, to determine if the signal identification data overlap said first area. 45. The method according to claim 44, in which said reconstructin further comprises the step of comparing the second area with th signal identification data for each scan, from said signa processing, to determine if the data overlaps said second area. 46. The method according to claim 45, wherein said step o comparing the second area further comprises identifying area containing machine readable code that is not to be decoded. 47. The method according to claim 46, wherein the code element comprise a plurality of intervals including bars and spaces o either narrow or wide interval widths and in which sai reconstructing further comprises the steps of: measuring the interval widths of said signal identificatio data, from said combining and accumulating means; normalizing the interval widths from said measuring to 1,2,3 and 4 wide bars and spaces to provide a reconstructed bar code; an decoding the reconstructed bar code to provide the encode information.

Inventors: KENNEY DANIEL A, NORDSTROM LARRY A, WALDRON JAMES R, KENNEY, DANIEL, A., NORDSTROM, LARRY, A., WALDRON, JAMES, R.
Applicants: KENNEY DANIEL A, LAZERDATA CORP, NORDSTROM LARRY A, WALDRON JAMES R, LAZERDATA CORPORATION
Application year: 1993
Main classification: G06K7
IPC codes: G06K7