# Python: module skeinforge_tools.export_plugins.binary_16_byte

skeinforge_tools.export_plugins.binary_16_byte ($Date: 2008/21/04 $) | index /home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/export_plugins/binary_16_byte.py

`Binary 16 byte is an export plugin to convert gcode into 16 byte binary segments.
An export plugin is a script in the export_plugins folder which has the functions getOuput, isArchivable and writeOutput. It is
meant to be run from the export tool. To ensure that the plugin works on platforms which do not handle file capitalization
properly, give the plugin a lower case name.
The getOutput function of this script takes a gcode text and returns that text converted into 16 byte segments. The writeOutput
function of this script takes a gcode text and writes that in a binary format converted into 16 byte segments.
Many of the functions in this script are copied from gcodec in skeinforge_utilities. They are copied rather than imported so
developers making new plugins do not have to learn about gcodec, the code here is all they need to learn.
This plugin is just a starter to make a real binary converter.
//Record structure
BinArray(0) = AscW(Inst_Code_Letter)
BinArray(1) = cInst_Code
X Data
sInt32_to_Hbytes(iXdim_1)
BinArray(2) = lsb 'short lsb
BinArray(3) = msb 'short msb
Y Data
sInt32_to_Hbytes(iYdim_2)
BinArray(4) = lsb 'short lsb
BinArray(5) = msb 'short msb
Z Data
sInt32_to_Hbytes(iZdim_3)
BinArray(6) = lsb 'short lsb
BinArray(7) = msb 'short msb
I Data
sInt32_to_Hbytes(iIdim_4)
BinArray(8) = lsb 'short lsb
BinArray(9) = msb 'short msb
J Data
sInt32_to_Hbytes(iJdim_5)
BinArray(10) = lsb 'short lsb
BinArray(11) = msb 'short msb
BinArray(12) = FP_Char
sInt32_to_Hbytes(iFP_Num)
BinArray(13) = lsb 'short lsb
BinArray(14) = bActiveFlags
BinArray(15) = AscW("#")End of record filler
Byte 14 is worth a few extra notes, this byte is used to define which of the axes are active, its used to get round the problem of say a
line of code with no mention of z. This would be put into the file as z = 0 as the space for this data is reserved, if we did nothing, this
would instruct the machine to go to z = 0. If we use the active flag to define the z axis as inactive the z = 0 is ignored and the value
set to the last saved value of z, i.e it does not move. If the z data is actually set to z = 0 then the axis would be set to active and
the move takes place.`

Modules

``

__init__ cStringIO | skeinforge_tools.skeinforge_utilities.gcodec skeinforge_tools.skeinforge_utilities.interpret | os skeinforge_tools.polyfile | skeinforge_tools.skeinforge_utilities.preferences sys

Classes

``

Binary16BytePreferences
Binary16ByteSkein

class Binary16BytePreferences
`` | `A class to handle the export preferences.`

Methods defined here:

__init__(self)
  `Set the default preferences, execute title & preferences fileName.`

execute(self)
  `Convert to binary 16 byte button has been clicked.`

class Binary16ByteSkein
`` | `A class to convert gcode into 16 byte binary segments.`

Methods defined here:

__init__(self)

parseGcode(self, gcodeText, binary16BytePreferences)
  `Parse gcode text and store the gcode.`

parseLine(self, line)
  `Parse a gcode line.`

Functions

``

getIntegerFlagFromCharacterSplitLine(character, splitLine)
  `Get the integer flag after the first occurence of the character in the split line.`

getIntegerFromCharacterLengthLineOffset(character, offset, splitLine, stepLength)
  `Get the integer after the first occurence of the character in the split line.`

getOutput(gcodeText, binary16BytePreferences=None)
  `Get the exported version of a gcode file. This function, isArchivable and writeOutput are the only necessary functions in a skeinforge export plugin.
  If this plugin writes an output than should not be printed, an empty string should be returned.`

getStringFromCharacterSplitLine(character, splitLine)
  `Get the string after the first occurence of the character in the split line.`

getSummarizedFilename(fileName)
  `Get the fileName basename if the file is in the current working directory, otherwise return the original full name.`

getTextLines(text)
  `Get the all the lines of text of a text.`

indexOfStartingWithSecond(letter, splitLine)
  `Get index of the first occurence of the given letter in the split line, starting with the second word. Return - 1 if letter is not found`

isArchivable()
  `Return whether or not this plugin is archivable.`

isReplacable()
  `Return whether or not the output from this plugin is replacable. This should be true if the output is text and false if it is binary.`

main(hashtable=None)
  `Display the export dialog.`

writeFileText(fileName, fileText)
  `Write a text to a file.`

writeOutput(fileName='', gcodeText='')
  `Write the exported version of a gcode file. This function, getOutput and isArchivable are the only necessary functions in a skeinforge export plugin.`

Data
`` |  | __author__ = 'Enrique Perez (perez_enrique@yahoo.com)' __date__ = '$Date: 2008/21/04 $' __license__ = 'GPL 3.0' absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

Author
`` |  | Enrique Perez (perez_enrique@yahoo.com)