text:
<title>Negative Type Numbers - STABS</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="STABS">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Builtin-Types.html#Builtin-Types" title="Builtin Types">
<link rel="prev" href="Builtin-Type-Descriptors.html#Builtin-Type-Descriptors" title="Builtin Type Descriptors">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">

<meta http-equiv="Content-Style-Type" content="text/css">

Previous: Builtin Type Descriptors,
Up: Builtin Types

5.1.3 Negative Type Numbers

This is the method used in XCOFF for defining builtin types.
Since the debugger knows about the builtin types anyway, the idea of
negative type numbers is simply to give a special type number which
indicates the builtin type.  There is no stab defining these types.

There are several subtle issues with negative type numbers.

One is the size of the type.  A builtin type (for example the C types
int or long) might have different sizes depending on
compiler options, the target architecture, the ABI, etc.  This issue
doesn't come up for IBM tools since (so far) they just target the
RS/6000; the sizes indicated below for each size are what the IBM
RS/6000 tools use.  To deal with differing sizes, either define separate
negative type numbers for each size (which works but requires changing
the debugger, and, unless you get both AIX dbx and GDB to accept the
change, introduces an incompatibility), or use a type attribute
(see String Field) to define a new type with the appropriate size
(which merely requires a debugger which understands type attributes,
like AIX dbx or GDB).  For example,

     .stabs "boolean:t10=@s8;-16",128,0,0,0

defines an 8-bit boolean type, and

     .stabs "boolean:t10=@s64;-16",128,0,0,0

defines a 64-bit boolean type.

A similar issue is the format of the type.  This comes up most often for
floating-point types, which could have various formats (particularly
extended doubles, which vary quite a bit even among IEEE systems).
Again, it is best to define a new negative type number for each
different format; changing the format based on the target system has
various problems.  One such problem is that the Alpha has both VAX and
IEEE floating types.  One can easily imagine one library using the VAX
types and another library in the same executable using the IEEE types.
Another example is that the interpretation of whether a boolean is true
or false can be based on the least significant bit, most significant
bit, whether it is zero, etc., and different compilers (or different
options to the same compiler) might provide different kinds of boolean.

The last major issue is the names of the types.  The name of a given
type depends only on the negative type number given; these do not
vary depending on the language, the target system, or anything else.
One can always define separate type numbers—in the following list you
will see for example separate int and integer*4 types
which are identical except for the name.  But compatibility can be
maintained by not inventing new negative type numbers and instead just
defining a new type with a new name.  For example:

     .stabs "CARDINAL:t10=-8",128,0,0,0

Here is the list of negative type numbers.  The phrase <dfn>integral
type</dfn> is used to mean twos-complement (I strongly suspect that all
machines which use stabs use twos-complement; most machines use
twos-complement these days).

-1
int, 32 bit signed integral type.

-2
char, 8 bit type holding a character.   Both GDB and dbx on AIX
treat this as signed.  GCC uses this type whether char is signed
or not, which seems like a bad idea.  The AIX compiler (xlc) seems to
avoid this type; it uses -5 instead for char.

-3
short, 16 bit signed integral type.

-4
long, 32 bit signed integral type.

-5
unsigned char, 8 bit unsigned integral type.

-6
signed char, 8 bit signed integral type.

-7
unsigned short, 16 bit unsigned integral type.

-8
unsigned int, 32 bit unsigned integral type.

-9
unsigned, 32 bit unsigned integral type.

-10
unsigned long, 32 bit unsigned integral type.

-11
void, type indicating the lack of a value.

-12
float, IEEE single precision.

-13
double, IEEE double precision.

-14
long double, IEEE double precision.  The compiler claims the size
will increase in a future release, and for binary compatibility you have
to avoid using long double.  I hope when they increase it they
use a new negative type number.

-15
integer.  32 bit signed integral type.

-16
boolean.  32 bit type.  GDB and GCC assume that zero is false,
one is true, and other values have unspecified meaning.  I hope this
agrees with how the IBM tools use the type.

-17
short real.  IEEE single precision.

-18
real.  IEEE double precision.

-19
stringptr.  See Strings.

-20
character, 8 bit unsigned character type.

-21
logical*1, 8 bit type.  This Fortran type has a split
personality in that it is used for boolean variables, but can also be
used for unsigned integers.  0 is false, 1 is true, and other values are
non-boolean.

-22
logical*2, 16 bit type.  This Fortran type has a split
personality in that it is used for boolean variables, but can also be
used for unsigned integers.  0 is false, 1 is true, and other values are
non-boolean.

-23
logical*4, 32 bit type.  This Fortran type has a split
personality in that it is used for boolean variables, but can also be
used for unsigned integers.  0 is false, 1 is true, and other values are
non-boolean.

-24
logical, 32 bit type.  This Fortran type has a split
personality in that it is used for boolean variables, but can also be
used for unsigned integers.  0 is false, 1 is true, and other values are
non-boolean.

-25
complex.  A complex type consisting of two IEEE single-precision
floating point values.

-26
complex.  A complex type consisting of two IEEE double-precision
floating point values.

-27
integer*1, 8 bit signed integral type.

-28
integer*2, 16 bit signed integral type.

-29
integer*4, 32 bit signed integral type.

-30
wchar.  Wide character, 16 bits wide, unsigned (what format?
Unicode?).

-31
long long, 64 bit signed integral type.

-32
unsigned long long, 64 bit unsigned integral type.

-33
logical*8, 64 bit unsigned integral type.

-34
integer*8, 64 bit signed integral type.


text:
package functional

// func TestKMSCreate(t *testing.T) {
// 	ok := helpers.UseApp(UserEmail, UserPassword)
// 	assert.True(t, ok)
//
// 	keyAlias := helpers.GenerateString()[:24]
//
// 	cmd := helpers.PrepareCmd("kms", "create", keyAlias)
//
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	scannerOut.Scan()
// 	kmsKeyInfo := scannerOut.Text()
// 	if !strings.Contains(kmsKeyInfo, fixtures.KMSKeyInfoPatternShort) {
// 		fmt.Printf("Unexpected kms key info: %s\n", kmsKeyInfo)
// 		_ = cmd.Process.Kill()
// 	}
//
// 	scannerOut.Scan()
// 	kmsKeyCreateOutput := scannerOut.Text()
// 	assert.Equal(t, utils.KMSKeyCreateSuccess, kmsKeyCreateOutput)
//
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }
//
// func TestKMSClientPrivate(t *testing.T) {
// 	cmd := helpers.PrepareCmd("kms", "client-private")
//
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	scannerOut.Scan()
// 	clientPrivateKey := scannerOut.Text()
// 	_, err := base64.StdEncoding.DecodeString(clientPrivateKey)
// 	assert.NoError(t, err)
//
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }
//
// func TestKMSList(t *testing.T) {
// 	_, _, ok := helpers.GenerateKMSKey(UserEmail, UserPassword)
// 	assert.True(t, ok)
//
// 	cmd := helpers.PrepareCmd("kms", "list")
//
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	var kmsKeysListOutPut []string
// 	for scannerOut.Scan() {
// 		kmsKeysListOutPut = append(kmsKeysListOutPut, scannerOut.Text())
// 	}
// 	assert.NotEmpty(t, kmsKeysListOutPut)
// 	for _, appHeader := range fixtures.KMSKeysListHeaders {
// 		if len(kmsKeysListOutPut) > 0 {
// 			assert.True(t, strings.Contains(kmsKeysListOutPut[0], appHeader))
// 		}
// 	}
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }
//
// func TestKMSGetUpdateToken(t *testing.T) {
// 	keyAlias, _, ok := helpers.GenerateKMSKey(UserEmail, UserPassword)
// 	assert.True(t, ok)
//
// 	cmd := helpers.PrepareCmd("kms", "get-update-token", keyAlias)
//
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	scannerOut.Scan()
// 	updateToken := scannerOut.Text()
// 	_, err := base64.StdEncoding.DecodeString(updateToken)
// 	assert.NoError(t, err)
//
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }
//
// func TestKMSRotate(t *testing.T) {
// 	kmsPrivateKey, ok := helpers.GenerateKMSPrivateKey()
// 	assert.True(t, ok)
//
// 	_, kmsPublicKey, updateToken, ok := helpers.GetKMSUpdateToken(UserEmail, UserPassword)
// 	assert.True(t, ok)
//
// 	cmd := helpers.PrepareCmd("kms", "rotate", kmsPrivateKey, kmsPublicKey, updateToken)
//
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	scannerOut.Scan()
// 	serverPublicKeyOut := scannerOut.Text()
// 	assert.Equal(t, fixtures.KMSRotateServerPublicKey, serverPublicKeyOut)
// 	scannerOut.Scan()
// 	newServerPublicKeyContent := scannerOut.Text()
// 	assert.NotEmpty(t, newServerPublicKeyContent)
// 	_, err := base64.StdEncoding.DecodeString(newServerPublicKeyContent)
// 	assert.NoError(t, err)
// 	scannerOut.Scan()
// 	clientPrivateKeyOut := scannerOut.Text()
// 	assert.Equal(t, fixtures.KMSRotateClientPrivateKey, clientPrivateKeyOut)
// 	scannerOut.Scan()
// 	newClientPrivateKeyContent := scannerOut.Text()
// 	if strings.Contains(newClientPrivateKeyContent, "KS.") {
// 		newClientPrivateKeyContent = strings.Replace(newClientPrivateKeyContent, "KS.", "", 1)
// 	}
// 	assert.NotEmpty(t, newClientPrivateKeyContent)
// 	_, err = base64.StdEncoding.DecodeString(newClientPrivateKeyContent)
// 	assert.NoError(t, err)
//
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }
//
// func TestKMSDeleteUpdateToken(t *testing.T) {
// 	keyAlias, _, _, ok := helpers.GetKMSUpdateToken(UserEmail, UserPassword)
// 	assert.True(t, ok)
//
// 	cmd := helpers.PrepareCmd("kms", "delete-update-token", keyAlias)
// 	cmdOut, _ := cmd.StdoutPipe()
// 	cmdErr, _ := cmd.StderrPipe()
//
// 	if err := cmd.Start(); err != nil {
// 		fmt.Printf("Cmd failed to start: %+v\n", err)
// 	}
//
// 	scannerOut := bufio.NewScanner(cmdOut)
// 	scannerErr := bufio.NewScanner(cmdErr)
//
// 	scannerOut.Scan()
// 	tokenDeleteOutput := scannerOut.Text()
// 	assert.Equal(t, utils.KMSUpdateTokenDeleteSuccess, tokenDeleteOutput)
// 	helpers.CmdKiller(cmd, scannerErr)
// 	assert.NoError(t, cmd.Wait())
// }

redpajama_set_name: RedPajamaGithub


text:
using System.Runtime.Serialization;

namespace Bifrost.Public.Sdk.Communication.Messages
{
    [DataContract]
    public enum Action : byte
    {
        [EnumMember]
        Response,
        [EnumMember]
        Handshake,
        [EnumMember]
        GetNodes
    }
}


text:
common_objpfx=$1
objpfx=$2
malloc_trace=$3
cross_test_wrapper=$4

LC_ALL=C
export LC_ALL

# Generate the test data.

# Create the locale directories.
mkdir -p ${objpfx}localedir/existing-locale/LC_MESSAGES
for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do
  cp -f ${common_objpfx}localedata/de_DE.UTF-8/LC_$f \
        ${objpfx}localedir/existing-locale
done
cp -f ${common_objpfx}localedata/de_DE.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES \
      ${objpfx}localedir/existing-locale/LC_MESSAGES

# Create the domain directories.
mkdir -p ${objpfx}domaindir/existing-locale/LC_MESSAGES
mkdir -p ${objpfx}domaindir/existing-locale/LC_TIME
# Populate them.
msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/existing-domain.mo \
       -f ../po/de.po
msgfmt -o ${objpfx}domaindir/existing-locale/LC_TIME/existing-time-domain.mo \
       -f ../po/de.po

GCONV_PATH=${common_objpfx}iconvdata
export GCONV_PATH
LOCPATH=${common_objpfx}localedata
export LOCPATH

# Now run the test.
MALLOC_TRACE=$malloc_trace LOCPATH=${objpfx}localedir:$LOCPATH \
${cross_test_wrapper} \
${common_objpfx}elf/ld.so --library-path $common_objpfx \
${objpfx}tst-gettext > ${objpfx}tst-gettext.out ${objpfx}domaindir

exit $?


text:
(function () {
  'use strict';

  angular
    .module('calendars')
    .config(['calendarConfig', function (calendarConfig) {
      calendarConfig.showTimesOnWeekView = true;
    }])
    .controller('CalendarsMainCtrl', CalendarsMainCtrl);

  CalendarsMainCtrl.$inject = ['$scope', '$http', 'CalendarFactory', 'moment'];

  function CalendarsMainCtrl($scope, $http, CalendarFactory) {
    // Add information for the calendar to render
    $scope.calendarView = 'month';
    $scope.viewDate = moment();
    $scope.delActive = false;
    $http.get('/api/users/me')
      .then(function (result) {
        $scope.user = result.data;
        $scope.loadEventsIntoScope();
        // Do whatever you need to do with the userId here.
      });
    $scope.loadEventsIntoScope = function () {
      // Get College Events and Convert to JavaScript Date Objects
      var result = CalendarFactory.getEvents().then(function (response) {
        $scope.events = response.data[0].events;
        $scope.events.forEach(function (element) {
          element.startsAt = new Date(element.startsAt);
          element.endsAt = new Date(element.endsAt);
        }, this);
        if ($scope.user !== null) { // If a user is logged in, Retrieve their events and show
          var userResult = CalendarFactory.getUser($scope.user.username).then(function (responses) {
            $scope.userData = responses.data[0];
            $scope.uEvents = $scope.userData.calendarEvents;
            $scope.uEvents.forEach(function (element) {
              element.startsAt = new Date(element.startsAt);
              if (element.endsAt !== '') {
                element.endsAt = new Date(element.endsAt);
              }
              $scope.events.push(element);
            }, this);
          });
        }
      });
    };
    $scope.calendarTitle = 'Student Calendar';

    $scope.addEventForm = {
      'calTitle': '',
      'startsAtD': '',
      'startsAtM': '',
      'startsAtY': '',
      'endsAtD': '',
      'endsAtM': '',
      'endsAtY': '',
      'colour': ''
    };

    $scope.clearForm = function () {
      $scope.addEventForm.calTitle = '';
      $scope.addEventForm.startsAtD = '';
      $scope.addEventForm.startsAtM = '';
      $scope.addEventForm.startsAtY = '';
      $scope.addEventForm.endsAtD = '';
      $scope.addEventForm.endsAtM = '';
      $scope.addEventForm.endsAtY = '';
      $scope.addEventForm.colour = '';
    };
    $scope.eventClicked = function (calendarEvent) { // Populate form with selected event info
      $scope.addEventForm.calTitle = calendarEvent.title.toString();
      $scope.addEventForm.startsAtD = calendarEvent.startsAt.getDate();
      $scope.addEventForm.startsAtM = calendarEvent.startsAt.getMonth() + 1;
      $scope.addEventForm.startsAtY = calendarEvent.startsAt.getFullYear();
      if (calendarEvent.endsAt != null) {
        $scope.addEventForm.endsAtD = calendarEvent.endsAt.getDate();
        $scope.addEventForm.endsAtM = calendarEvent.endsAt.getMonth() + 1;
        $scope.addEventForm.endsAtY = calendarEvent.endsAt.getFullYear();
      }
      $scope.addEventForm.colour = calendarEvent.color.primary;
      if (calendarEvent.cssClass === 'college-events') {
        $scope.delActive = false;
      } else {
        $scope.delActive = true;
      }
    };
    $scope.tsClicked = function (calendarDate) { // Populate form with timespan that was clicked in month view
      if ($scope.calendarView === 'month') {
        $scope.addEventForm.calTitle = '';
        $scope.addEventForm.startsAtD = calendarDate.getDate();
        $scope.addEventForm.startsAtM = calendarDate.getMonth() + 1;
        $scope.addEventForm.startsAtY = calendarDate.getFullYear();
        $scope.addEventForm.endsAtD = '';
        $scope.addEventForm.endsAtM = '';
        $scope.addEventForm.endsAtY = '';
        $scope.addEventForm.colour = '';
      }
    };

    $scope.addEvent = function () {
      if ($scope.user !== null) {

        // Setting the end of the event to the start date, in case there is no end assigned i.e. starts + ends same day
        var endevent = new Date($scope.addEventForm.startsAtY, $scope.addEventForm.startsAtM - 1, $scope.addEventForm.startsAtD);
        // If there is an end event, Overwrite to that instead
        if (($scope.addEventForm.endsAtY + $scope.addEventForm.endsAtM + $scope.addEventForm.endsAtD).length > 0) {
          endevent = new Date($scope.addEventForm.endsAtY, $scope.addEventForm.endsAtM - 1, $scope.addEventForm.endsAtD);
        }
        var newEvent = { // New event object to insert
          title: $scope.addEventForm.calTitle,
          startsAt: new Date($scope.addEventForm.startsAtY, $scope.addEventForm.startsAtM - 1, $scope.addEventForm.startsAtD),
          endsAt: endevent,
          color: {
            primary: $scope.addEventForm.colour,
            secondary: '#fdf1ba'
          }
        };
        if (newEvent.calendarTitle !== '' && $scope.addEventForm.startsAtD !== '' && $scope.addEventForm.startsAtM !== '' && $scope.addEventForm.startsAtY !== '') {
          var result = CalendarFactory.addUserEvent($scope.user.username, newEvent).then(function (response) {
            $scope.clearForm();
            $scope.loadEventsIntoScope(); // Refresh calendar's view of the scope.
          });
        } else {
          alert('Event Must have a title and start date!'); // TODO: Remove alert?
        }
        // Run function to add to the user's document
      } else {
        window.location.reload();
      }
    };
    // Remove selected event
    $scope.remEvent = function () {
      if ($scope.user !== null) {
        var endevent = new Date($scope.addEventForm.startsAtY, $scope.addEventForm.startsAtM - 1, $scope.addEventForm.startsAtD);
        if (($scope.addEventForm.endsAtY + $scope.addEventForm.endsAtM + $scope.addEventForm.endsAtD).length > 0) {
          endevent = new Date($scope.addEventForm.endsAtY, $scope.addEventForm.endsAtM - 1, $scope.addEventForm.endsAtD);
        }
        var newEvent = {
          title: $scope.addEventForm.calTitle,
          startsAt: new Date($scope.addEventForm.startsAtY, $scope.addEventForm.startsAtM - 1, $scope.addEventForm.startsAtD),
          endsAt: endevent,
          color: {
            primary: $scope.addEventForm.colour,
            secondary: '#fdf1ba'
          }
        };
        var results = CalendarFactory.remUserEvent($scope.user.username, newEvent).then(function (response) {
          $scope.clearForm();
          $scope.loadEventsIntoScope();
        });
        // window.location.reload(); // TODO: I think problem is with asynchronous code here
      }
    };

    $scope.prevArrow = function () {
      if ($scope.calendarView === 'day') {
        $scope.viewDate = moment($scope.viewDate).subtract(1, 'day');
      } else if ($scope.calendarView === 'month') {
        $scope.viewDate = moment($scope.viewDate).subtract(1, 'month');
      } else {
        $scope.viewDate = moment($scope.viewDate).subtract(1, 'year');
      }
    };

    $scope.nextArrow = function () {
      if ($scope.calendarView === 'day') {
        $scope.viewDate = moment($scope.viewDate).add(1, 'day');
      } else if ($scope.calendarView === 'month') {
        $scope.viewDate = moment($scope.viewDate).add(1, 'month');
      } else {
        $scope.viewDate = moment($scope.viewDate).add(1, 'year');
      }
    };
    $scope.upArrow = function () {
      if ($scope.calendarView === 'day') {
        $scope.calendarView = 'month';
      } else if ($scope.calendarView === 'month') {
        $scope.calendarView = 'year';
      }
    };
  }
}());


text:
from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor, Adafruit_StepperMotor
import RPi.GPIO as GPIO
import time
import logging
import atexit
import threading
from collections import namedtuple

logger = logging.getLogger('dispenser.mechanism')
logger.setLevel(logging.DEBUG)

class Mechanism:
    '''
    Control for the pill dispensing mechanism
    '''
    NUM_CONTAINERS = 7
    STEPS_PER_REV = 200
    STEPS_PER_CONTAINER = STEPS_PER_REV / NUM_CONTAINERS
    FEED_ALIGN = STEPS_PER_CONTAINER / 2

    PillSlot = namedtuple('PillSlot', 'name step_location')
    LINACT_PIN = 5
    SOLENOID_PIN = 6

    def __init__(self, *args, **kwargs):
        # Call base constructor
        self.hat = Adafruit_MotorHAT(addr=0x60)
        # Release motors on exit
        atexit.register(self._turn_off_motors)
        # Assign motors
        self.stepper = self.hat.getStepper(200, 1)
        self.stepper.setSpeed(30)
        # Create threads for each stepper port
        self.st1 = threading.Thread()
        self.dc2 = threading.Thread()
        # dispenser data structures
        self.pill_dict = dict()
        self.current_step = 0
        atexit.register(self._turn_off_motors)
        # setup GPIO
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.LINACT_PIN, GPIO.OUT)
        GPIO.setup(self.SOLENOID_PIN, GPIO.OUT)

    @property
    def current_step(self):
        """
        0 steps - bottom dispense slot
        100 steps - top feed slot
        :return: int
        """
        return self.__current_step % self.STEPS_PER_REV

    @current_step.setter
    def current_step(self, val):
        if val > self.STEPS_PER_REV or val < 0:
            self.__current_step = val % self.STEPS_PER_REV
        else:
            self.__current_step = val

    @property
    def top_slot(self):
        return (self.current_step + 100) % self.STEPS_PER_REV

    @staticmethod
    def _stepper_worker(stepper, numsteps, direction, style):
        logging.info("Stepper starting...")
        stepper.step(numsteps, direction, style)
        logging.info("Stepper stopping...")

    def _turn_off_motors(self):
        logging.info("Shutting down motors../")
        self.hat.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
        self.hat.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
        self.hat.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
        self.hat.getMotor(4).run(Adafruit_MotorHAT.RELEASE)
        logging.info("All motors released")

    def _execute_motor_action(self, numsteps, direction, style):
        self.st1 = threading.Thread(target=self._stepper_worker, args=(self.stepper, numsteps, direction, style))
        self.st1.start()
        # update position
        if direction == self.FORWARD:
            self.current_step += numsteps
        elif direction == self.BACKWARD:
            self.current_step += numsteps

    def get_current_pill(self):
        return self.pill_dict.get(self.current_step)

    def add_pill(self, pill_to_add):
        name = pill_to_add.name
        self.pill_dict[self.top_slot] = self.PillSlot(name, self.top_slot)
        self.pill_dict[self.top_slot] = self.PillSlot(name, self.top_slot)

    def dispense_pill(self, pill_disp):
        while self.get_current_pill() != pill_disp:
            self._execute_motor_action(self.STEPS_PER_CONTAINER, Adafruit_MotorHAT.FORWARD, Adafruit_MotorHAT.DOUBLE)


text:
#ifndef ALIITSCALIBRATIONSDD_H
#define ALIITSCALIBRATIONSDD_H

/* $Id$ */

#include "AliITSCalibration.h"
#include "AliITSsegmentationSDD.h"
#include "TArrayI.h"

class AliITSCorrMapSDD;
class AliITSDriftSpeedArraySDD;

///////////////////////////////////////////////////////
//  Response for SDD                                 //
///////////////////////////////////////////////////////

class AliITSCalibrationSDD : public AliITSCalibration {
  public:
    //
    // Configuration methods
    //
    AliITSCalibrationSDD();
    AliITSCalibrationSDD(const char *dataType);
    virtual ~AliITSCalibrationSDD();

    virtual Float_t GetBaseline(Int_t anode) const {return fBaseline[anode];}
    virtual void SetBaseline(Int_t anode,Double_t bas) {fBaseline[anode]=bas;}
    virtual Float_t GetNoise(Int_t anode) const {return fNoise[anode];}
    virtual void SetNoise(Int_t anode, Double_t noise) {fNoise[anode]=noise;}

    virtual void  GiveCompressParam(Int_t *x) const;

    void SetZSLowThreshold(Int_t iWing, Int_t thr=25){fZSTL[iWing]=thr;}
    void SetZSHighThreshold(Int_t iWing, Int_t thr=29){fZSTH[iWing]=thr;}
    Int_t GetZSLowThreshold(Int_t iWing) const {return fZSTL[iWing];}
    Int_t GetZSHighThreshold(Int_t iWing) const {return fZSTH[iWing];}

    void  SetNoiseAfterElectronics(Int_t anode,Double_t n=2.38){
	// Noise after electronics (ADC units)
	// 2.36 for ALICE from beam test measurements 2001
	fNoiseAfterEl[anode]=n;}
    Float_t  GetNoiseAfterElectronics(Int_t anode) const {
	// Noise after electronics (ADC units)
	return fNoiseAfterEl[anode];}
    //void SetDeadChannels(Int_t nchips=0, Int_t nchannels=0);
    void SetDeadChannels(Int_t ndead=0){fDeadChannels=ndead; fBadChannels.Set(ndead);}
    Int_t GetDeadChips() const { return fDeadChips; }
    Int_t GetDeadChannels() const { return fDeadChannels; }
    Float_t GetChannelGain(Int_t anode) const {return fGain[anode];}
    virtual void SetGain(Int_t anode,Double_t g){fGain[anode]=g;}

    Int_t GetWing(Int_t anode) const{
      if(anode>=fgkChips*fgkChannels) return 1;
      else return 0;
    }
    Int_t GetChipChannel(Int_t anode) const {return anode%fgkChannels;}
    Int_t GetChip(Int_t anode) const {return anode/fgkChannels;}
    Int_t GetAnodeNumber(Int_t iwing, Int_t ichip03, Int_t ichan) const {
      if(iwing>=2 || ichip03>=4 || ichan>=64) return -1;
      else return iwing*fgkChips*fgkChannels+ichip03*fgkChannels+ichan;
    }
    Int_t GetAnodeNumber(Int_t ichip07, Int_t ichan) const {
      if(ichip07>=8 || ichan>=64) return -1;
      else return ichip07*fgkChannels+ichan;
    }

    void    PrintGains() const;
    void    Print();
    virtual void Print(ostream *os) const {AliITSCalibrationSDD::Print(os);}
    virtual void Print(Option_t *option="") const {AliITSCalibrationSDD::Print(option);}
    // not implemented virtual methods (devlared in the mother class
    virtual  void   SetDetParam(Double_t *)
      {NotImplemented("SetDetParam");}
    virtual void   GetDetParam(Double_t *) const
      {NotImplemented("GetDetParam");}
    virtual  void   SetNDetParam(Int_t /* n */)
      {NotImplemented("SetNDetParam");}
    virtual Int_t  NDetParam() const
      {NotImplemented("NDetParam"); return 0;}
    virtual void    SetSigmaSpread(Double_t, Double_t)
      {NotImplemented("SetSigmaSpread");}
    virtual void    SigmaSpread(Double_t & /* p1 */,Double_t & /* p2 */) const
      {NotImplemented("SigmaSpread");}

    void   SetBad() {
      fIsBad = kTRUE;
      for(Int_t i=0;i<fgkChips*fgkWings;i++) fIsChipBad[i]=kTRUE;
    }
    virtual Bool_t IsBad() const { return fIsBad; }
    void   SetChipBad(Int_t nChip) {
      fIsChipBad[nChip] = kTRUE;
    }
    virtual Bool_t IsChipBad(Int_t nChip) const {
      return fIsChipBad[nChip];
    }
    virtual Bool_t IsWingBad(Int_t nwing) const
    {
      if(nwing<0 || nwing>1) return kFALSE;
      if(IsChipBad(nwing*4) && IsChipBad(nwing*4+1) && IsChipBad(nwing*4+2) && IsChipBad(nwing*4+3)) return kTRUE;
      return kFALSE;
    }

    Int_t Wings()const{return fgkWings;}//Total number of SDD wings
    Int_t Chips() const{return fgkChips;} // Number of chips/module
    Int_t Channels() const{ return fgkChannels;}//Number of channels/chip
    Int_t NOfAnodes() const {return fgkChannels*fgkChips*fgkWings;}

    virtual void SetBadChannel(Int_t i,Int_t anode);
    Int_t GetBadChannel(Int_t i) const {return fBadChannels[i];}
    Bool_t IsBadChannel(Int_t anode) const{
      if(GetChannelGain(anode)==0) return kTRUE;
      else return kFALSE;
    }
    Float_t GetMapACell(Int_t i,Int_t j) const {
      if(i<256) return fMapAW0->GetCellContent(i,j);
      else return fMapAW1->GetCellContent(i-256,j);
    }
    virtual void SetMapA(Int_t wing,AliITSCorrMapSDD* mapA) {
      if(wing==0) fMapAW0=mapA;
      else fMapAW1=mapA;
    }
    Float_t GetMapTCell(Int_t i,Int_t j) const {
      if(i<256) return fMapTW0->GetCellContent(i,j);
      else return fMapTW1->GetCellContent(i-256,j);
    }
    virtual void SetMapT(Int_t wing,AliITSCorrMapSDD* mapT) {
      if(wing==0) fMapTW0=mapT;
      else fMapTW1=mapT;
    }

    virtual void SetDriftSpeed(Int_t wing, AliITSDriftSpeedArraySDD* arr){
      if(wing==0) fDrSpeed0=arr;
      else fDrSpeed1=arr;
    }

    virtual Float_t GetDriftSpeedAtAnode(Float_t nAnode) const{
      if(fDrSpeed0==0 || fDrSpeed1==0) AliFatal("Drift speed not set\n");
      if(nAnode<256) return fDrSpeed0->GetDriftSpeed(0,nAnode);
      else return fDrSpeed1->GetDriftSpeed(0,nAnode-256);
    }

    virtual void SetZeroSupp(Bool_t opt=kTRUE) {fZeroSupp=opt;}
    virtual Bool_t GetZeroSupp() const {return fZeroSupp;}

    virtual void SetAMAt40MHz() {fAMAt20MHz=kFALSE;}
    virtual void SetAMAt20MHz() {fAMAt20MHz=kTRUE;}
    virtual Bool_t IsAMAt20MHz() const {return fAMAt20MHz;}

    void GetCorrections(Float_t z, Float_t x, Float_t &devz, Float_t &devx, AliITSsegmentationSDD* seg);
    void GetShiftsForSimulation(Float_t z, Float_t x, Float_t &devz, Float_t &devx, AliITSsegmentationSDD* seg);
    virtual Float_t GetThresholdAnode(Int_t anode, Double_t nsigma=2.2) const {
      return nsigma*fNoiseAfterEl[anode];}

 protected:

    // these statis const should be move to AliITSsegmentationSDD
    static const Int_t fgkWings = 2;     // Number of wings per module
    static const Int_t fgkChips = 4;        // Number of chips/module
    static const Int_t fgkChannels = 64;    // Number of channels/chip
    static const Float_t fgkTemperatureDefault; // default for fT (Kelvin)
    static const Float_t fgkNoiseDefault; // default for fNoise
    static const Float_t fgkBaselineDefault; // default for fBaseline
    static const Float_t fgkGainDefault; //default for gain

    Bool_t fZeroSupp;    // zero suppression
    Bool_t fAMAt20MHz;   // flag for Analog memory of Pascal at 20 MHz
    Int_t fDeadChips;                     // Number of dead chips
    Int_t fDeadChannels;                  // Number of dead channels
    Float_t fGain[fgkWings*fgkChips*fgkChannels];           //Array for channel gains
    Float_t fNoise[fgkWings*fgkChips*fgkChannels];          // Noise array
    Float_t fBaseline[fgkWings*fgkChips*fgkChannels];       // Baseline array
    Float_t fNoiseAfterEl[fgkWings*fgkChips*fgkChannels];   // Noise after electronics

    Int_t   fZSTL[2];     //  Low threshold in 2D zero-suppression (2 hybrids)
    Int_t   fZSTH[2];     // High threshold in 2D zero-suppression (2 hybrids)

    Bool_t   fIsBad;                         // module is dead or alive ?
    Bool_t   fIsChipBad[fgkWings*fgkChips];  // chip is dead or alive ?
    TArrayI  fBadChannels;                   //Array with bad anodes number (0-512)

    AliITSCorrMapSDD* fMapAW0;     //! map of residuals on anode coord. wing 0
    AliITSCorrMapSDD* fMapAW1;     //! map of residuals on anode coord. wing 1
    AliITSCorrMapSDD* fMapTW0;     //! map of residuals on time coord. wing 0
    AliITSCorrMapSDD* fMapTW1;     //! map of residuals on time coord. wing 1
    AliITSDriftSpeedArraySDD* fDrSpeed0; //! drift speed for wing 0
    AliITSDriftSpeedArraySDD* fDrSpeed1; //! drift speed for wing 1

 private:
    AliITSCalibrationSDD(const AliITSCalibrationSDD &ob); // copy constructor
    AliITSCalibrationSDD& operator=(const AliITSCalibrationSDD & /* source */); // ass. op.

    ClassDef(AliITSCalibrationSDD,17)

    };
#endif


text:
//%DEFINE-START%
var scn_pkg="org.scn.community.";if(sap.firefly!=undefined){scn_pkg=scn_pkg.replace(".","_");}
define([
	"sap/designstudio/sdk/component",
	"./NiceChartSpec",
	"../../../"+scn_pkg+"shared/modules/component.core",
	"../../../"+scn_pkg+"shared/modules/component.basics",
	"../../../"+scn_pkg+"shared/modules/component.databound",
	"../../../"+scn_pkg+"databound/os/chartjs/Chart",
	"../../../"+scn_pkg+"databound/os/color/ColorScheme"
	],
	function(
		Component,
		spec,
		core,
		basics
	) {
//%DEFINE-END%

var myComponentData = spec;

NiceChart = function () {

	var that = this;

	that.init = function() {
		// define root component
		org_scn_community_basics.fillDummyDataInit(that, that.initAsync);
	};

	that.initAsync = function (owner) {
		var that = owner;
		org_scn_community_component_Core(that, myComponentData);

		/* COMPONENT SPECIFIC CODE - START(initDesignStudio)*/
		// that.addStyleClass("scn-pack-?");

		/* COMPONENT SPECIFIC CODE - END(initDesignStudio)*/
	};

	that.afterUpdate = function() {
		/* COMPONENT SPECIFIC CODE - START(afterDesignStudioUpdate)*/

		var flatData = {};

		/* COMPONENT SPECIFIC CODE - START(afterDesignStudioUpdate)*/
		if(!org_scn_community_databound.hasData(that.getData())) {
			flatData = org_scn_community_databound.getSampleDataFlat(that, that.processData, that.afterPrepare);
			return;
		} else {
			org_scn_community_basics.fillDummyData(that, that.processData, that.afterPrepare);
			return;
		}

		/* COMPONENT SPECIFIC CODE - START(afterDesignStudioUpdate)*/
	};

	/* COMPONENT SPECIFIC CODE - START METHODS*/
	that.onResize = function (width, height, parent) {
		that.resetSizes(width, height);
		that.afterUpdate(parent);
	}

	that.resetSizes = function (width, height) {
		if(!width) { width = that._containerWidth; }
		if(!height) { height = that._containerHeight; }

		var legendSize = that.getDLegendWidth();
		if(!that.getDShowLegend()) {
			legendSize = 0;
			that._legend.style.width = '0px';
			that._legend.style.display = "none";
		} else {
			that._legend.style.width = legendSize + 'px';
			that._legend.style.display = "block";
		}
		that._canvas.style.width = (width - legendSize) + 'px';
		that._canvas.style.height =  height + 'px';

		that._canvas.width = (width - legendSize);
		that._canvas.height =  height;

		if(that._chartInstance) {
			that._chartInstance.width = (width - legendSize);
			that._chartInstance.height =  height;
		}

		if(that.getDLegendPosition() == "Left") {
			that._canvas.style.left = legendSize + 'px';
			that._legend.style.left = '10px';
		} else {
			that._canvas.style.left = '0px';
			that._legend.style.left = (width - legendSize + 10) + 'px';
		}

		if(that.makeOverflow > 0) {
			that._overflow.style.width =  '260px';
			that._overflow.style.height =  '20px';
			that._overflow.style.display = "block";
			that._overflow.innerHTML = "Overflow of " + that.makeOverflow + " data sets!";
		} else {
			that._overflow.style.width =  '0px';
			that._overflow.style.height =  '0px';
			that._overflow.style.display = "none";
		}
	}

	/* COMPONENT SPECIFIC CODE - START METHODS*/
	that.processData = function (flatData, afterPrepare, owner) {
		var that = owner;

		if(flatData == undefined) {
			var options = org_scn_community_databound.initializeOptions();
			options.ignoreResults = true;

			flatData = org_scn_community_databound.flatten(that.getData(),options);
		}

		var data = {};
		var colors = that.simpleRandomColors();

		if (that.getDChartType() == "Line" || that.getDChartType() == "Bar" || that.getDChartType() == "LineBar" || that.getDChartType() == "Radar") {
			data.labels = [];
			var length = flatData.geometry.rowLength;
			var headers = flatData.rowHeaders;
			var otherLength = flatData.geometry.colLength;
			var otherHeaders = flatData.columnHeaders;
			if(that.getDSwapAxes()) {
				var length = flatData.geometry.colLength;
				var headers = flatData.columnHeaders;
				var otherLength = flatData.geometry.rowLength;
				var otherHeaders = flatData.rowHeaders;
			}
			that.maxRows = Math.min(length, that.getDMaxDataPoints());
			for (var i = 0; i < that.maxRows; i++) {
				data.labels.push(headers[i]);
			}

			data.datasets = [];
			that.maxSeries = Math.min(otherLength, colors.hard.length);
			that.makeOverflow = otherLength - that.maxSeries;
			for (var iC = 0; iC < that.maxSeries; iC++) {
				var dataSet = {};
				dataSet.label = otherHeaders[iC];

				dataSet.pointHighlightFill= "#fff";

				dataSet.strokeColor= "#"+colors.pastel[iC];
				dataSet.pointColor= "#"+colors.soft[iC];
				dataSet.pointStrokeColor= "#"+colors.hard[iC];
				dataSet.pointHighlightStroke= "#"+colors.soft[iC];
				dataSet.fillColor = "#"+colors.soft[iC];

				if(that.getDChartType() == "LineBar") {
					// for starting point, only the first one is line
					if(iC % 2 == 1) {
						dataSet.type = "line";
						dataSet.fillColor = "#fff";
					} else {
						dataSet.fillColor = "#"+colors.hard[iC];
					}
				}

				dataSet.data = [];
				for (var iR = 0; iR < length; iR++) {
					if(that.getDSwapAxes()) {
						dataSet.data.push(flatData.values[iC][iR]);
					} else {
						dataSet.data.push(flatData.values[iR][iC]);
					}
				}

				data.datasets.push(dataSet);
			}
		} else if (that.getDChartType() == "PolarArea" || that.getDChartType() == "Pie" || that.getDChartType() == "Doughnut") {
			data = [];
			var multiplication = 1;
			if(that.getDChartType() == "Pie" || that.getDChartType() == "Doughnut") {
				multiplication = 100;
			}

			var length = flatData.geometry.rowLength;
			var headers = flatData.rowHeaders;
			if(that.getDSwapAxes()) {
				var length = flatData.geometry.colLength;
				var headers = flatData.columnHeaders;
			}

			that.maxSeries = Math.min(length, colors.hard.length);
			that.makeOverflow = length - that.maxSeries;
			for (var iR = 0; iR < that.maxSeries; iR++) {
		    	var dataSet = {};

		    	if(that.getDSwapAxes()) {
		    		dataSet.value = flatData.values[0][iR] * multiplication;
		    	} else {
		    		dataSet.value = flatData.values[iR][0] * multiplication;
		    	}

		    	dataSet.color = "#"+colors.hard[iR];
		    	dataSet.fillColor = "#"+colors.hard[iR];
		    	dataSet.highlight = "#"+colors.pastel[iR];
		    	dataSet.label = headers[iR];

				data.push(dataSet);
		    }
		}

		that._data = data;

		// processing on data
		that.afterPrepare(that);
	};

	that.getPreparedOptions = function () {
		var options = {};

		options.customTooltips = that.customTooltips;

		var locale = "en";
        if(that._data && that._data.locale) {
        	locale = that._data.locale;
        }

        options.scaleLabel = "<%= org_scn_community_basics.getFormattedValue(value, '"+locale+"', 2)%>"

		return options;
	};

	that.formatLegend = function () {
		var parent = that._legend;
		var data = that._data;

	    var datas = data.hasOwnProperty('datasets') ? data.datasets : data;

	    // remove possible children of the parent
	    while(parent.hasChildNodes()) {
	        parent.removeChild(parent.lastChild);
	    }

	    datas.forEach(function(d) {
	        var title = document.createElement('span');
	        title.className = 'title';
	        parent.appendChild(title);

	        var colorSample = document.createElement('div');
	        colorSample.className = 'color-sample';
	        colorSample.style.backgroundColor = d.hasOwnProperty('strokeColor') ? d.strokeColor : d.color;
	        colorSample.style.borderColor = d.hasOwnProperty('fillColor') ? d.fillColor : d.color;
	        title.appendChild(colorSample);

	        var text = document.createTextNode(d.label);
	        title.appendChild(text);
	    });
	}

	that.simpleRandomColors = function () {
		var colors = {};

		var colorHue = that.getDColorHue();
		var colorDistance = that.getDColorDistance();
		var colorPalette = that.getDColorPalette().toLowerCase();

		var scm = new ColorScheme();
		scm.from_hue(colorHue)
		   .scheme(colorPalette)
		   .distance(colorDistance)
		   .add_complement(false)
		   .variation('light')
		   .web_safe(false);
		colors.light = scm.colors();
		scm.from_hue(colorHue)
		   .scheme(colorPalette)
		   .distance(colorDistance)
		   .add_complement(false)
		   .variation('hard')
		   .web_safe(false);
		colors.hard = scm.colors();
		scm.from_hue(colorHue)
		   .scheme(colorPalette)
		   .distance(colorDistance)
		   .add_complement(false)
		   .variation('soft')
		   .web_safe(false);
		colors.soft = scm.colors();
		scm.from_hue(colorHue)
		   .scheme(colorPalette)
		   .distance(colorDistance)
		   .add_complement(false)
		   .variation('pastel')
		   .web_safe(false);
		colors.pastel = scm.colors();
		return colors;
	}

	that.customTooltips = function(tooltip) {
		var tooltipEl = $("#" + that._jqThis[0].id + "_tooltip");
        if (!tooltip) {
            tooltipEl.css({
                opacity: 0
            });
            return;
        }
        tooltipEl.removeClass('above below');
        tooltipEl.addClass(tooltip.yAlign);

        var locale = "en";
        if(that._data && that._data.locale) {
        	locale = that._data.locale;
        }

        var width = tooltipEl.outerWidth();
        width = width - 40;
        var innerHtml = '';

        if(tooltip.labels) {
	        for (var i = 0; i < tooltip.labels.length; i++) {
	        	var tooltipValue = org_scn_community_basics.getFormattedValue(tooltip.labels[i], locale, 2);
	        	var dataSetLabel = that._data.datasets[i].label;

	        	innerHtml += [
	        		'
',
	        		'	',
	        		'	' + dataSetLabel + '',
	        		'	' + tooltipValue + '',
	        		'
'
	        	].join('');
	        }

	        tooltipEl.css({
	            opacity: 1,
	            left: tooltip.chart.canvas.offsetLeft + 60 + tooltip.x + 'px',
	            top: tooltip.chart.canvas.offsetTop - 100 + tooltip.y + 'px',
	            height: ((18 * tooltip.labels.length)) + 'px',
	            fontFamily: tooltip.fontFamily,
	            fontSize: tooltip.fontSize,
	            fontStyle: tooltip.fontStyle,
	        });
        } else {
        	var textValue = tooltip.text.split(":");
        	var multiplication = 1;
			if(that.getDChartType() == "Pie" || that.getDChartType() == "Doughnut") {
				multiplication = 100;
			}
			var tooltipValue = org_scn_community_basics.getFormattedValue(textValue[1] / multiplication, locale, 2);

			innerHtml += [
	        		'
',
	        		'	' + textValue[0] + '',
	        		'	' + tooltipValue + '',
	        		'
'
	        	].join('');

        	tooltipEl.css({
	            opacity: 1,
	            left: tooltip.chart.canvas.offsetLeft + 60 + tooltip.x + 'px',
	            top: tooltip.chart.canvas.offsetTop - 40 + tooltip.y + 'px',
	            height: (20) + 'px',
	            fontFamily: tooltip.fontFamily,
	            fontSize: tooltip.fontSize,
	            fontStyle: tooltip.fontStyle,
	        });
        }

        tooltipEl.html(innerHtml);

    };

	that.afterPrepare = function (owner) {
		var that = owner;

		if(!that._oContentPlaced) {
			// Get the context of the canvas element we want to select
			var $ = document; // shortcut
			that._jqThis = that.$();

			that._canvas = document.createElement('canvas');
			that._canvas.id = that._jqThis[0].id + "_canvas";
			that._canvas.className = "org-scn-NiceChart-Canvas";
			that._canvas.style.position = 'absolute';
			that._canvas.style.top = '0';

			that._jqThis[0].appendChild(that._canvas);

			that._tool = document.createElement('div');
			that._tool.id = that._jqThis[0].id + "_tooltip";
			that._tool.className = "org-scn-NiceChart-Tooltip";
			that._tool.style.position = 'absolute';
			that._tool.style.left = '0px';
			that._tool.style.top = '0px';
			that._jqThis[0].appendChild(that._tool);

			that._legend = document.createElement('div');
			that._legend.id = that._jqThis[0].id + "_legend";
			that._legend.className = "org-scn-NiceChart-Legend";
			that._legend.style.position = 'absolute';
			that._legend.style.top = '10px';

			that._jqThis[0].appendChild(that._legend);

			that._overflow = document.createElement('div');
			that._overflow.id = that._jqThis[0].id + "_overflow";
			that._overflow.className = "org-scn-NiceChart-Overflow";
			that._overflow.innerHTML = "Overflow !"
			that._jqThis[0].appendChild(that._overflow);

			that._ctx = that._canvas.getContext("2d");
			that._chartInstance = new ChartJs(that._ctx);

			org_scn_community_basics.resizeContentAbsoluteLayout(that, that._canvas, that.onResize);
		}

		that._options = that.getPreparedOptions();

		org_scn_community_basics.determineOwnSize(that);
		that.resetSizes();

		// visualization on processed data
		if(that._chart) {
			// destroy first
			that._chart.clear();
			that._chart.destroy();
		}

		// recreate instance
		that._chart = that._chartInstance[that.getDChartType()](that._data, that._options);

		// legend and other properties
		that.formatLegend();
	};

	/* COMPONENT SPECIFIC CODE - END METHODS*/

	org_scn_community_component_Core(that, myComponentData);

	return that;
};
//%INIT-START%
myComponentData.instance = NiceChart;
Component.subclass(myComponentData.fullComponentName, myComponentData.instance);

});


text:
package org.broadinstitute.dsde.firecloud.integrationtest

import akka.stream.Materializer
import com.typesafe.scalalogging.LazyLogging
import org.broadinstitute.dsde.firecloud.integrationtest.ESIntegrationSupport.searchDAO
import org.broadinstitute.dsde.firecloud.model.DataUse.{DiseaseOntologyNodeId, ResearchPurpose}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

class ResearchPurposeSearchSpec extends AnyFreeSpec with SearchResultValidation with Matchers with BeforeAndAfterAll with LazyLogging {

  override def beforeAll() = {
    // use re-create here, since instantiating the DAO will create it in the first place
    searchDAO.recreateIndex()
    // make sure we specify refresh=true here; otherwise, the documents may not be available in the index by the
    // time the tests start, leading to test failures.
    logger.info("indexing fixtures ...")
    searchDAO.bulkIndex(ResearchPurposeSearchTestFixtures.fixtureDocs, refresh = true)
    logger.info("... fixtures indexed.")
  }

  override def afterAll() = {
    searchDAO.deleteIndex()
  }

  // we don't have to test any use cases of the user omitting a research purpose - all the
  // other tests do that.
  "Library research-purpose-aware search" - {

    "Elastic Search" - {
      "Index exists" in {
        assert(searchDAO.indexExists())
      }
    }

    "Research purpose for aggregate analysis (NAGR)" - {
      val researchPurpose = ResearchPurpose.default.copy(NAGR = true)
      "should return any dataset where NAGR is false and is (GRU or HMB)" - {
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val filter = Map("library:projectName" -> Seq("helium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("six", "seven"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("eleven", "twelve"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          Set("antiaging", "antialias", "antibody", "antic", "anticoagulant", "anticorruption"),
          searchResponse
        )
      }
    }

    "Research purpose for population origins/ancestry (POA)" - {
      val researchPurpose = ResearchPurpose.default.copy(POA = true)
      "should return any dataset where GRU is true" - {
        val expected = Set("one", "six", "eleven")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val filter = Map("library:projectName" -> Seq("helium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("six"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("eleven"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          Set("antiaging", "antibody", "anticoagulant"),
          searchResponse
        )
      }
    }

    "Research purpose for commercial use (NCU)" - {
      val researchPurpose = ResearchPurpose.default.copy(NCU = true)
      "should return any dataset where NPU and NCU are both false" - {
        val expected = Set("two", "four", "seven", "nine", "twelve", "fourteen")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val filter = Map("library:projectName" -> Seq("helium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("seven", "nine"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("twelve", "fourteen"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          Set("antialias", "antibacterial", "antic", "anticipate", "anticorruption", "antidisestablishmentarianism"),
          searchResponse
        )
      }
    }

    "Disease focused research (DS)" - {
      "should return any dataset where the disease matches exactly" - {
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve", "sixteen", "eighteen") // GRU, HMB, and sleep disorder
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any dataset where the RP's disease is a child of the dataset's disease" - {
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_9220")))
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve", "sixteen", "seventeen", "eighteen", "twenty") // GRU, HMB, central sleep apnea, and sleep disorder
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any GRU or HMB dataset" - {
        // disease search for leukemia, which is not in our test fixtures
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_1240")))
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val filter = Map("library:projectName" -> Seq("beryllium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("sixteen", "eighteen"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("eleven", "twelve"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val researchPurpose = ResearchPurpose.default.copy(DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          // Set("one", "two", "six", "seven", "eleven", "twelve", "sixteen", "eighteen"), // GRU, HMB, and sleep disorder
          Set("antiaging", "antialias", "antibody", "antic", "anticoagulant", "anticorruption", "antiegalitarian", "antielitism"),
          searchResponse
        )
      }
    }

    "Methods development/Validation study (NMDS)" - {
      "should return any dataset where NMDS is true and the disease matches exactly" - {
        val researchPurpose = ResearchPurpose.default.copy(NMDS=true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve", "sixteen", "eighteen") // NMDS=false or (NMDS=true and disease-match logic)
        // NB: this doesn't match fixture "twenty" because even though the NMDS clauses are satisfied, the DS
        // clause is not. In other words, if you made this search without specifying NMDS=true, you wouldn't
        // match on "twenty".
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any dataset where NMDS is true and the RP's disease is a child of the dataset's disease" - {
        val researchPurpose = ResearchPurpose.default.copy(NMDS=true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_9220")))
        val expected = Set("one", "two", "six", "seven", "eleven", "twelve", "sixteen", "seventeen", "eighteen", "twenty")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any dataset where NMDS is false" - {
        val researchPurpose = ResearchPurpose.default.copy(NMDS = true)
        val expected = Set("one", "six", "eleven", "sixteen", "twenty")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val researchPurpose = ResearchPurpose.default.copy(NMDS=true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val filter = Map("library:projectName" -> Seq("beryllium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("sixteen", "eighteen"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val researchPurpose = ResearchPurpose.default.copy(NMDS=true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_9220")))
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("eleven", "twelve"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val researchPurpose = ResearchPurpose.default.copy(NMDS=true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_9220")))
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          Set("antiaging", "antialias", "antibody", "antic", "anticoagulant", "anticorruption", "antiegalitarian", "antielectron", "antielitism", "antifashion"),
          searchResponse
        )
      }
    }

    "Control set (NCTRL)" - {
      "should return any dataset where the disease matches exactly" - {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val expected = Set("two", "six", "twelve", "sixteen", "eighteen")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any dataset where the RP's disease is a child of the dataset's disease" - {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_9220")))
        val expected = Set("two", "six", "twelve", "sixteen", "seventeen", "eighteen", "twenty")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should return any dataset where NCTRL is false and is (GRU or HMB)" - {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true)
        val expected = Set("two", "six", "twelve")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
      "should intersect with a standard facet filter" in {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val filter = Map("library:projectName" -> Seq("beryllium"))
        val searchResponse = searchWithPurpose(researchPurpose, filter)
        validateResultNames(
          Set("sixteen", "eighteen"),
          searchResponse
        )
      }
      "should intersect with a text search" in {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val searchResponse = searchWithPurpose(researchPurpose, "lazy")
        validateResultNames(
          Set("twelve"),
          searchResponse
        )
      }
      "should affect search suggestions" in {
        val researchPurpose = ResearchPurpose.default.copy(NCTRL = true, DS = Seq(DiseaseOntologyNodeId("http://purl.obolibrary.org/obo/DOID_535")))
        val searchResponse = suggestWithPurpose(researchPurpose, "anti")
        validateSuggestions(
          Set("antialias", "antibody", "anticorruption", "antiegalitarian", "antielitism"),
          searchResponse
        )
      }
    }

    "Research purpose with multiple restrictions enabled" - {
      "should intersect each restriction" - {
        val researchPurpose = ResearchPurpose.default.copy(NAGR = true, NCU = true)
        val expected = Set("two", "seven", "twelve")
        "monolithic search" in {
          val searchResponse = searchWithPurpose(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
        "external search using researchPurposeQuery" in {
          val searchResponse = searchWithResearchPurposeQuery(researchPurpose)
          validateResultNames(expected, searchResponse)
        }
      }
    }

  }
}


text:
export default function login(req) {
  const user = {
    nickname: req.body.nickname,
    username: req.body.username,
    password: req.body.password
  };
  req.session.user = user;
  return Promise.resolve(user);
}


text:
package org.unitils.mock;

import org.junit.Test;
import org.unitils.core.UnitilsException;

import java.util.List;
import java.util.Map;
import java.util.Properties;

import static org.junit.Assert.assertNotNull;

/**
 * Tests the mock module functionality.
 *
 * @author Tim Ducheyne
 * @author Filip Neven
 */
public class MockModuleTest {

    /* Class under test */
    private MockModule mockModule = new MockModule();

    private RegularMockType regularMockType = new RegularMockType();
    private GenericMockType genericMockType = new GenericMockType();
    private MockTypeNotSpecified mockTypeNotSpecified = new MockTypeNotSpecified();

    @Test
    public void createAndInjectMocksIntoTest() {
        mockModule.createAndInjectMocksIntoTest(regularMockType);
        assertNotNull(regularMockType.mock.getMock());
    }

    @Test
    public void genericMockType() {
        mockModule.createAndInjectMocksIntoTest(genericMockType);
        assertNotNull(genericMockType.mock.getMock());
    }

    @Test(expected = UnitilsException.class)
    public void mockTypeNotSpecified() {
        mockModule.createAndInjectMocksIntoTest(mockTypeNotSpecified);
        assertNotNull(mockTypeNotSpecified.mock.getMock());
    }

    private static class RegularMockType {

        public Mock<Properties> mock;

    }

    private static class GenericMockType {

        public Mock<Map<String, List<String>>> mock;

    }

    private static class MockTypeNotSpecified {

        public Mock mock;

    }

}


text:
package zmaster587.advancedRocketry.util;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import zmaster587.advancedRocketry.network.PacketBiomeIDChange;
import zmaster587.libVulpes.network.PacketHandler;
import zmaster587.libVulpes.util.HashedBlockPosition;

public class BiomeHandler {

	public static void changeBiome(World world, int biomeId, BlockPos pos) {
		Chunk chunk = world.getChunkFromBlockCoords(pos);

		Biome biome = world.getBiome(pos);
		Biome biomeTo = Biome.getBiome(biomeId);

		if(biome == biomeTo)
			return;

		int y = 60;
		if(biome.topBlock != biomeTo.topBlock) {
			BlockPos yy = world.getHeight(pos);

			while(!world.getBlockState(yy.down()).isOpaqueCube() && yy.getY() > 0)
				yy = yy.down();

			if(world.getBlockState(yy.down()) == biome.topBlock)
				world.setBlockState(yy.down(), biomeTo.topBlock);
		}

		byte[] biomeArr = chunk.getBiomeArray();
		try {
			biomeArr[(pos.getX() & 15) + (pos.getZ() & 15)*16] = (byte)biomeId;
		} catch (IndexOutOfBoundsException e) {
			e.printStackTrace();
		}

		PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new HashedBlockPosition(pos)), world.provider.getDimension(), pos, 256);
	}

	public static void changeBiome(World world, int biomeId, int x, int z) {
		changeBiome(world, biomeId, new BlockPos(x, 0, z));
	}

	public static void changeBiome(World world, int biomeId, Chunk chunk, int x, int z) {

	}

	public static void changeBiome(World world, int biomeId, Chunk chunk, BlockPos pos) {

		Biome biome = world.getBiome(pos);
		Biome biomeTo = Biome.getBiome(biomeId);

		int x = pos.getX();
		int z = pos.getZ();
		if(biome == biomeTo)
			return;

		int y = 60;
		if(biome.topBlock != biomeTo.topBlock) {
			int yy = chunk.getHeightValue(x & 15, z & 15);

			while(!world.getBlockState(new BlockPos(x, yy - 1, z)).isOpaqueCube() && yy > 0)
				yy--;

			if(yy == 0)
				return;

			if(chunk.getBlockState(x & 15, yy - 1, z & 15) == biome.topBlock)
				chunk.setBlockState(new BlockPos(x & 15, yy - 1, z & 15), biomeTo.topBlock);

			y = (short)yy;
		}

		byte[] biomeArr = chunk.getBiomeArray();
		biomeArr[(x & 15) + (z & 15)*16] = (byte)biomeId;

		//PacketHandler.sendToNearby(new PacketBiomeIDChange(chunk, world, new BlockPosition(x, y, z)), world.provider.dimensionId, x, y, z, 256);
	}
}