Package: pyacptrak
pyacptrakWhat is it?pyacptrakhelps you to create ACOPOStrak resources for projects, training, meetings, mappView widgets, etc... It is a powerful tool when used together with Jupyter-Lab (Or Jupyter Notes) but could be used as stand alone module.InstallTo install pyacptrak, run the following command:pip install pyacptrakInstall with development dependenciesTo install pyacptrak, along with the tools you need to develop and run tests, run the following command:pip install pyacptrak[dev]Main FeaturesWork with segments (Segment class)The library support the 4 type of segments ('AA', 'AB', 'BA' and 'BB').Obtain segment information:import pyacptrak as at

print(at.Segment('aa').info())Output:{'length': 660,
 'type': '8F1I01.AA66.xxxx-1',
 'description': 'ACOPOStrak straight segment'}Plot segment:import pyacptrak as at

at.Segment('aa').plot()The plot function supports rotation in degrees:import pyacptrak as at

at.Segment('ab').plot(-45)Work with tracks (Track class)The library has 5 types of pre-built tracks (TRACK0, TRACK45, TRACK90, TRACK135 and TRACK180).import pyacptrak as at

at.TRACK135.plot()But you could also build your own tracks using individual segments.import pyacptrak as at
track1 = (at.Segment('aa') * 2) + at.Segment('ab') + (at.Segment('bb') * 2) + at.Segment('ba')
track1.plot()Or using the pre-configured tracks (This makes it easier).import pyacptrak as at
track1 = (at.TRACK0 * 2) + at.TRACK135
track1.plot()The plot function supports rotation for tracks:import pyacptrak as at
track1 = (at.TRACK0 * 2) + at.TRACK135
track1.plot(15)The argumentsseg_prefix(Default value "gSeg_") andseg_offset(default value "1") are available from v0.0.5 to configure the segment variable namesWork with loops (Loop class)The library supports working with loops, the arguments for the loop are width and height, the unit is considering the 660mm grid so aloop(2,1)would draw the smallest possible loop (If no arguments are passed it will consider w=2, h=1).import pyacptrak as at
at.Loop(2,1).plot()For loops wider than 1 it uses 90° tracks instead of 180°import pyacptrak as at
at.Loop(3,2).plot()The plot function also support rotation for loopsimport pyacptrak as at
at.Loop(3,2).plot(190)Save the SVG filesIt is possible to save the SVG file of any of the classes by chaining the methodsave().Thesave()accepts one argument to define the name of the output file, if no name is passed, the default filename will be the class name.import pyacptrak as at
at.Loop(3,2).plot(190).save()Output: Saves a "Loop.svg" fileConfigure shuttle type and controller settingsIt is possible to configure the shuttle type by using the size (50mm , 100mm, 244mm), selecting if it is one or two sided magnet (For diverter) and the magnet type (Straight, skewed) by using thePARAMclassat.PARAM.shuttle.size = 100                 # 50, 100, 244
at.PARAM.shuttle.magnet_plate = 1           # 1 = Non diverter, 2 = Diverter
at.PARAM.shuttle.magnet_type = 'Straight'   # Straight, SkewedIt is possible to configure the default control parameters, the PID values will be calculated automatically depending the configured shuttle and the controller type (Soft, medium, hard).at.PARAM.segment.controller = 'Hard'        # soft, medium, hardWhen any of these parameters changes, the user will be notified if the control parameters and/or the shuttle type have been updatedThe control parameters have been updated
The shuttle model and dimensions have been updated: 8F1SA.203.xxxxxx-xThe completePARAMclass is shown below:<class 'pyacptrak.pyacptrak._param'>
    segment = <class 'pyacptrak.pyacptrak._segment'>
        control_par = <class 'pyacptrak.pyacptrak._control_par'>
            ff_force_neg = 2.0
            ff_force_pos = 2.0
            ff_speed_force_factor = 2.0
            ff_total_mass = 0.8
            pos_proportional_gain = 300
            speed_proportional_gain = 180
        elongation = Inactive
        simulation = Off
        speed_filter = Not Used
        stop_reaction = Induction Halt
    shuttle = <class 'pyacptrak.pyacptrak._shuttle'>
        auto_dimensions = True
        collision_distance = 0.002
        collision_strategy = Constant
        convoy = Inactive
        count = 10
        error_stop = 0.006
        extent_back = 0.05
        extent_front = 0.05
        model = 8F1SA.203.xxxxxx-x
        stereotype = ShuttleStereotype_1
        stereotype_par = <class 'pyacptrak.pyacptrak._sh_stereotype_par'>
            acceleration = 50.0
            deceleration = 50.0
            jerk = 0.02
            recontrol = Active
            user_data = 0
            velocity = 4.0
        width = 0.03
    visu = <class 'pyacptrak.pyacptrak._visu'>
        task = 4Work with assemblies (Assembly class)The library supports working with assemblies, the arguments for the assembly are a list of Track elements and a name (By default "gAssembly_1") which will be used for the exported filesimport pyacptrak as at
asm1 = at.Assembly([at.Loop(3,1), at.Loop()])It is possible to plot each track of the assembly by accessing the track index:asm1.track[0].plot()asm1.track[1].plot()It is also possible to access all track methods from each Track element within the assembly class.The argumentsseg_prefix(Default value "gSeg_") andseg_offset(default value "1") are available from v0.0.5 to configure the segment variable names. When each track has differentseg_prefixname the offset will reset by default (This behavior could be overriden by passing a value in theseg_offsetargument):import pyacptrak as at
l1 = at.Loop(3,1, seg_prefix='gLoop1_')
l2 = at.Loop(seg_prefix='gLoop2_')
asm = at.Assembly([l1,l2])
print(asm.track[0].info())This will print all the information of the track:{'seg_prefix': 'gLoop1_',
 'seg_offset': 1,
 'length': 4560,
 'segment': [{'name': 'gLoop1_001',
   'length': 450,
   'type': '8F1I01.AB2B.xxxx-1',
   'description': 'ACOPOStrak curve segment A'},
  {'name': 'gLoop1_002',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_003',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_004',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_005',
   'length': 450,
   'type': '8F1I01.BA2B.xxxx-1',
   'description': 'ACOPOStrak curve segment B'},
  {'name': 'gLoop1_006',
   'length': 660,
   'type': '8F1I01.AA66.xxxx-1',
   'description': 'ACOPOStrak straight segment'},
  {'name': 'gLoop1_007',
   'length': 450,
   'type': '8F1I01.AB2B.xxxx-1',
   'description': 'ACOPOStrak curve segment A'},
  {'name': 'gLoop1_008',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_009',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_010',
   'length': 240,
   'type': '8F1I01.BB4B.xxxx-1',
   'description': 'ACOPOStrak circular arc segment'},
  {'name': 'gLoop1_011',
   'length': 450,
   'type': '8F1I01.BA2B.xxxx-1',
   'description': 'ACOPOStrak curve segment B'},
  {'name': 'gLoop1_012',
   'length': 660,
   'type': '8F1I01.AA66.xxxx-1',
   'description': 'ACOPOStrak straight segment'}]}Or could show the compacted version by passing thecompactoptional argument:import pyacptrak as at
l1 = at.Loop(3,1, seg_prefix='gLoop1_')
l2 = at.Loop(seg_prefix='gLoop2_')
asm = at.Assembly([l1,l2])
asm.track[0].info(compact = True)This will print the main track information and the number of segments in the track:{'seg_prefix': 'gLoop1_',
 'seg_offset': 1,
 'length': 4560,
 'segment': 'The track has 12 segments'}Configure the plot settingsIt is possible to configure the SVG settings (Starting with v0.0.6)import pyacptrak as at

at.Loop(3,1).plot(angle=20, show_id=True, seg_body_fill='#ff8800', seg_border_stroke='#0000ff', seg_id_stroke='#ff0000')LicenseCopyright © Jorge CentenoLicensed under theGNU GPLv3 license.Changesv0.0.7 (2022.07.24) [Latest release]Loop class:Bug fix: The save method was not working because of a typo in the image attribute.Bug fix: The class initialization didn't accept the argumentsseg_prefixandseg_offset.Bug fix: TheAssemblyclass export method was not working due to wrongstringtobyteconversion.v0.0.6 (2022.06.18)General changes:Change: The librarysvgutilshas been removed and replaced withsvgwrite.Change: The SVG resources installed withpyacptrakare now removed.New feature: All SVG images are now generated from scratch, this allows the library to modify the color of the elements and insert text (Like segment ID). This also expands the posibility to implement new features or add elements to the SVG images in future versions.New feature: Allplot()methods have the following optional arguments to configure the SVG image:show_id: bool = False: Show or hide the segment id.seg_body_fill: str = None: Configure the fill color of the segment, accepts a hexadecimal color code. The default value is '#EEEEEE'.seg_body_stroke: str = None: Configure the stroke (Edge) color of the segment body, acceptas a hexadecimal color code. The default value is '#A9A9A9'.seg_border_stroke: str = None: Configure the stroke color of the segment border (The work area), accepts a hexadecimal color code. The default value is '#FF8800'.seg_dir_fill: str = None: Configure the fill color of the arrow that represents the segment encoder direction, accepts a hexadecimal color code. The default value is '#CCCCCC'.seg_dir_stroke: str = None: Configure the stroke (Edge) color of the segment direction arrow, accepts a hexadecimal color code. The default value is '#CCCCCC'.seg_id_fill: str = None: Configure the fill color of the segment ID text, accepts a hexadecimal color code. The default value is '#BBBBBB'.seg_id_stroke: str = None: Configure the stroke (Edge) color of the segment id, accepts a hexadecimal color code. The default value is '#BBBBBB'.seg_id_stroke_width: float = None: Configure the width of the segment id stroke. The default value is '0.15'v0.0.5 (2022.06.12)General changes:Bug fix: Removed unecessary packages frominstall_requires. The combination some module versions generated the following error whenpyacptrakwas installed in Python 3.9:× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
      ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
      [end of output]New feature: When the shuttle type and/or the controller configuration changes via thePARAMclass, the PID controller parameters will be automatically calculated based on the recomended values from Automation Help.New feature: Theinfo()method of the Track, Loop and Assembly classes may now receive an optional argumentcompact(The default value is False).Assembly class:New feature: the export method is available, it will automatically create the assembly configuration fileAsmCfg.assemblyand the shuttle stereotype fileShCfg.shuttlestereotype. Both files will be generated in the same folder where the python program is running and could be imported (Or copy/pasted) into the Automation Studio project.New feature: Thenameargument is available to configure a name for the assembly, the default value is "gAssembly_1".Track class:New feature: Theseg_prefixargument is available to configure a prefix for the segment variable names, the default value is "gSeg_".New feature: Theseg_offsetargument is available to configure an offset for the segment variable names, the default value is "1".v0.0.4 (2022.04.26)General changes:Bug fix: As a result of moving the "img" folder location in v0.0.3 the SVG images were not installed with the package, now this works correctly and the images are installed together with the package.v0.0.3 (2022.03.23)General changes:License changed from MIT to GNU GPLv3.Added TypeError for addition and multiplication operators.Addedtypeguardandtypingpackages to typecheck the methods.Addedxmltodictpackage to create the xml configuration files for the AS project.AddedPARAMvariable to configure the exported files.Reduced the size of SVG files.Segment class:Change: Removed theinfoattribute.New feature: Theinfo()method was added to get the segment information.Bug fix: Multiplying a segment object by an integer "n" would create a Track class object with "n" segments all pointing to the same segment object.Track class:New feature: Theseg_prefixargument (Optional) was added to theTrackclass to create the segment variable. The default value is "gSeg_".New feature: Theseg_offsetargument (Optional) was added to theTrackclass to configure an offset for the segment variable. The default value is "1".New feature: Theinfo()method was added to get the track information.Bug fix: Adding or multiplying Track objects would create a Track class object with elements pointing to the same segment objects.Loop class:New feature: Added addition and multiplication operators, the result will return anAssemblyobject.Bug fix: The inheritedlength()method didn't work because theLoopclass had alengthattribute that was overwritting the methodlength()of the parent classTrack.Assembly class:New feature: Class added to the package.New feature: Theexport()method was added.The assembly configuration file (AsmCfg.assembly) will be generated.The shuttle stereotype file (ShCfg.shuttlestereotype) will be generated.