text:
#ifndef SMARTT_SOCKET_H
#define SMARTT_SOCKET_H

// Standard library dependencies
#include <exception>
#include <string>
#include <string.h>

// SSL dependencies
#include <openssl/ssl.h>
#include <openssl/err.h>

using namespace std;

/*************************************************************************************************
  Smartt Socket Exception class
*************************************************************************************************/
// Constants
#define SMARTT_SOCKET_EXCEPTION_SOCKET_INFO_STR_MAX 4096
#define SMARTT_SOCKET_EXCEPTION_ERRNO_STR_MAX       4096

// Class declaration
class SmarttSocketException: public std::exception
{
    string error_description_;
    string socket_info_;

    // Builds the socket tuple string consisted of the socket host and port: "(host,port)"
    string format_socket_info(const string &host, int port);

public:
    // Constructors
    SmarttSocketException(const string &error_description, const string &host, int port);

    SmarttSocketException(const string &error_description, int error_number, const string &host, int port);

    ~SmarttSocketException() throw ();

    virtual const char* what() const throw();
};

/*************************************************************************************************
  Smartt Socket class
    A socket connection to connect with the Smartt server
*************************************************************************************************/
class SmarttSocket {

public:

    // Constructor
    SmarttSocket(const string &host, int port, bool use_ssl = true);

    void connect();
    void disconnect();

    void write(const string &message);
    string read();

    // Read until socket is exhausted of data
    string readUntilEmpty();

private:

    // Host address
    string host_;

    // Port to connect in the host
    int port_;

    // Socket identifier returned by the socket api
    int socket_id_;

    // -----------
    // SSL Stuff

    // Private static flag used only for SSL Library initialization
    static int ssl_library_init_;

    // SSL context of the socket
    SSL_CTX *ssl_context_;

    // SSL protocol handler
    SSL *ssl_;

    // Does this socket use SSL?
    bool use_ssl_;

    // Inits SSL for this socket
    void setupSSL();

};

#endif // SMARTT_SOCKET_H


text:
/* jshint jasmine: true */

exports.defineAutoTests = function() {
  describe('Device Information (window.device)', function () {
    it("should exist", function() {
      expect(window.device).toBeDefined();
    });

    it("should contain a platform specification that is a string", function() {
      expect(window.device.platform).toBeDefined();
      expect((String(window.device.platform)).length > 0).toBe(true);
    });

    it("should contain a version specification that is a string", function() {
      expect(window.device.version).toBeDefined();
      expect((String(window.device.version)).length > 0).toBe(true);
    });

    it("should contain a UUID specification that is a string or a number", function() {
      expect(window.device.uuid).toBeDefined();
      if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
        expect((String(window.device.uuid)).length > 0).toBe(true);
      } else {
        expect(window.device.uuid > 0).toBe(true);
      }
    });

    it("should contain a cordova specification that is a string", function() {
      expect(window.device.cordova).toBeDefined();
      expect((String(window.device.cordova)).length > 0).toBe(true);
    });

    it("should depend on the presence of cordova.version string", function() {
      expect(window.cordova.version).toBeDefined();
      expect((String(window.cordova.version)).length > 0).toBe(true);
    });

    it("should contain device.cordova equal to cordova.version", function() {
      expect(window.device.cordova).toBe(window.cordova.version);
    });

    it("should contain a model specification that is a string", function() {
      expect(window.device.model).toBeDefined();
      expect((String(window.device.model)).length > 0).toBe(true);
    });

    it("should contain a manufacturer property that is a string", function() {
      expect(window.device.manufacturer).toBeDefined();
      expect((String(window.device.manufacturer)).length > 0).toBe(true);
    });

    it("should contain an isVirtual property that is a boolean", function() {
      expect(window.device.isVirtual).toBeDefined();
      expect(typeof window.device.isVirtual).toBe("boolean");
    });

    it("should contain a serial number specification that is a string", function() {
      expect(window.device.serial).toBeDefined();
      expect((String(window.device.serial)).length > 0).toBe(true);

    });

  });
};

exports.defineManualTests = function(contentEl, createActionButton) {
    var logMessage = function (message, color) {
        var log = document.getElementById('info');
        var logLine = document.createElement('div');
        if (color) {
            logLine.style.color = color;
        }
        logLine.innerHTML = message;
        log.appendChild(logLine);
    };

    var clearLog = function () {
        var log = document.getElementById('info');
        log.innerHTML = '';
    };

    var device_tests = '
Press Dump Device button to get device information
' +
        '

' +
        'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)';

    contentEl.innerHTML = '

' + device_tests;

    createActionButton('Dump device', function() {
      clearLog();
      logMessage(JSON.stringify(window.device, null, '\t'));
    }, "dump_device");
};

redpajama_set_name: RedPajamaGithub


text:
// ProgressWnd.cpp : implementation file
//
// Written by Chris Maunder (chrismaunder@codeguru.com)
// Copyright 1998.
//
// CProgressWnd is a drop-in popup progress window for use in
// programs that a time consuming. Check out the header file
// or the accompanying HTML doc file for details.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this
// notice and the authors name is included. If the source code in
// this file is used in any commercial application then an email to
// the me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer, causes your pet cat to fall ill, increases baldness or
// makes you car start emitting strange noises when you start it up.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
//
// Updated May 18 1998 - added PeekAndPump function to allow modal operation,
//                       with optional "Cancel on ESC" (Michael <mbh-ep@post5.tele.dk>)
//         Nov 27 1998 - Removed modal stuff from PeekAndPump
//         Dec 18 1998 - added WS_EX_TOPMOST to the creation flag

#include "stdafx.h"
#include "ProgressWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define IDC_CANCEL   10
#define IDC_TEXT     11
#define IDC_PRGRS	 12

LPCTSTR szSection = _T("Settings");
LPCTSTR szEntryX  = _T("ProgressWinX");
LPCTSTR szEntryY  = _T("ProgressWinY");

/////////////////////////////////////////////////////////////////////////////
// CProgressWnd

CProgressWnd::CProgressWnd()
{
    CommonConstruct();
}

CProgressWnd::CProgressWnd(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    CommonConstruct();
    m_strTitle = pszTitle;

    Create(pParent, pszTitle, bSmooth);
}

void CProgressWnd::CommonConstruct()
{
    m_nNumTextLines  = 4;
    m_nPrevPos       = 0;
    m_nPrevPercent   = 0;
    m_nStep          = 1;
    m_nMinValue      = 0;
    m_nMaxValue      = 100;

    m_strTitle       = _T("Progress");
    m_strCancelLabel = _T(" Cancel ");
    m_bCancelled     = FALSE;
    m_bModal         = FALSE;

    m_bPersistantPosition = TRUE;   // saves and restores position automatically
}

CProgressWnd::~CProgressWnd()
{
    DestroyWindow();
}

BOOL CProgressWnd::Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    BOOL bSuccess;

    // Register window class
    CString csClassName = AfxRegisterWndClass(CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
                                              ::LoadCursor(NULL, IDC_APPSTARTING),
                                              CBrush(::GetSysColor(COLOR_BTNFACE)));

    // Get the system window message font for use in the cancel button and text area
    NONCLIENTMETRICS ncm;
    ncm.cbSize = sizeof(NONCLIENTMETRICS);
    VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
    m_font.CreateFontIndirect(&(ncm.lfMessageFont));

    // If no parent supplied then try and get a pointer to it anyway
    if (!pParent)
        pParent = AfxGetMainWnd();

    // Create popup window
    bSuccess = CreateEx(WS_EX_DLGMODALFRAME|WS_EX_TOPMOST, // Extended style
                        csClassName,                       // Classname
                        pszTitle,                          // Title
                        WS_POPUP|WS_BORDER|WS_CAPTION,     // style
                        0,0,                               // position - updated soon.
                        390,130,                           // Size - updated soon
                        pParent->GetSafeHwnd(),            // handle to parent
                        0,                                 // No menu
                        NULL);
    if (!bSuccess) return FALSE;

    // Now create the controls
    CRect TempRect(0,0,10,10);

    bSuccess = m_Text.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP,
                             TempRect, this, IDC_TEXT);
    if (!bSuccess) return FALSE;

    DWORD dwProgressStyle = WS_CHILD|WS_VISIBLE;
#ifdef PBS_SMOOTH
    if (bSmooth)
       dwProgressStyle |= PBS_SMOOTH;
#endif
    bSuccess = m_wndProgress.Create(dwProgressStyle, TempRect, this, IDC_PRGRS);
    if (!bSuccess) return FALSE;

    bSuccess = m_CancelButton.Create(m_strCancelLabel,
                                     WS_CHILD|WS_VISIBLE|WS_TABSTOP| BS_PUSHBUTTON,
                                     TempRect, this, IDC_CANCEL);
    if (!bSuccess) return FALSE;

    m_CancelButton.SetFont(&m_font, TRUE);
    m_Text.SetFont(&m_font, TRUE);

    // Resize the whole thing according to the number of text lines, desired window
    // width and current font.
    SetWindowSize(m_nNumTextLines, 390);

    // Center and show window
    if (m_bPersistantPosition)
        GetPreviousSettings();
    else
        CenterWindow();

    Show();

    return TRUE;
}

BOOL CProgressWnd::GoModal(LPCTSTR pszTitle /*=_T("Progress")"*/, BOOL bSmooth /*=FALSE*/)
{
    CWnd *pMainWnd = AfxGetMainWnd();

    if (!::IsWindow(m_hWnd) && !Create(pMainWnd, pszTitle, bSmooth))
        return FALSE;

    // Disable main window
    if (pMainWnd)
        pMainWnd->EnableWindow(FALSE);

    // Re-enable this window
    EnableWindow(TRUE);

    m_bModal = TRUE;

    return TRUE;
}

void CProgressWnd::SetWindowSize(int nNumTextLines, int nWindowWidth /*=390*/)
{
    int nMargin = 10;
    CSize EdgeSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));

    CRect TextRect, CancelRect, ProgressRect;
    CSize CancelSize;

    // Set up a default size for the text area in case things go wrong
    TextRect.SetRect(nMargin,nMargin, nWindowWidth-2*nMargin, 100+2*nMargin);

    // Get DrawText to tell us how tall the text area will be (while we're at
    // it, we'll see how big the word "Cancel" is)
    CDC* pDC = GetDC();
    if (pDC) {
        CFont* pOldFont = pDC->SelectObject(&m_font);
        CString str = _T("M");
        for (int i = 0; i < nNumTextLines-1; i++) str += _T("\nM");
        pDC->DrawText(str, TextRect, DT_CALCRECT|DT_NOCLIP|DT_NOPREFIX);
        TextRect.right = TextRect.left + nWindowWidth;
        CancelSize = pDC->GetTextExtent(m_strCancelLabel + _T("  ")) +
                                             CSize(EdgeSize.cx*4, EdgeSize.cy*3);
        pDC->SelectObject(pOldFont);
        ReleaseDC(pDC);
    }

    // Work out how big (and where) the cancel button should be
    CancelRect.SetRect(TextRect.right-CancelSize.cx, TextRect.bottom+nMargin,
                       TextRect.right, TextRect.bottom+nMargin + CancelSize.cy);

    // Work out how big (and where) the progress control should be
    ProgressRect.SetRect(TextRect.left, CancelRect.top + EdgeSize.cy,
                         CancelRect.left-nMargin, CancelRect.bottom - EdgeSize.cy);

    // Resize the main window to fit the controls
    CSize ClientSize(nMargin + TextRect.Width() + nMargin,
                     nMargin + TextRect.Height() + nMargin + CancelRect.Height() + nMargin);

    CRect WndRect, ClientRect;
    GetWindowRect(WndRect); GetClientRect(ClientRect);
    WndRect.right = WndRect.left + WndRect.Width()-ClientRect.Width()+ClientSize.cx;
    WndRect.bottom = WndRect.top + WndRect.Height()-ClientRect.Height()+ClientSize.cy;
    MoveWindow(WndRect);

    // Now reposition the controls...
    m_wndProgress.MoveWindow(ProgressRect);
    m_CancelButton.MoveWindow(CancelRect);
    m_Text.MoveWindow(TextRect);
}

void CProgressWnd::Clear()
{
    SetText(_T(""));
    SetPos(0);
    m_bCancelled = FALSE;
    m_nPrevPos = 0;

    if (::IsWindow(GetSafeHwnd()))
        UpdateWindow();
}

void CProgressWnd::Hide()
{
    if (!::IsWindow(GetSafeHwnd()))
        return;

    if (IsWindowVisible())
    {
        ShowWindow(SW_HIDE);
        ModifyStyle(WS_VISIBLE, 0);
    }
}

void CProgressWnd::Show()
{
    if (!::IsWindow(GetSafeHwnd()))
        return;

    if (!IsWindowVisible())
    {
        ModifyStyle(0, WS_VISIBLE);
        ShowWindow(SW_SHOWNA);
        RedrawWindow(NULL,NULL,RDW_ERASE|RDW_FRAME|RDW_INVALIDATE);
    }
}

void CProgressWnd::SetRange(int nLower, int nUpper, int nStep /* = 1 */)
{
    if (!::IsWindow(GetSafeHwnd()))
        return;

    // To take advantage of the Extended Range Values we use the PBM_SETRANGE32
    // message intead of calling CProgressCtrl::SetRange directly. If this is
    // being compiled under something less than VC 5.0, the necessary defines
    // may not be available.
#ifdef PBM_SETRANGE32
    ASSERT(-0x7FFFFFFF <= nLower && nLower <= 0x7FFFFFFF);
    ASSERT(-0x7FFFFFFF <= nUpper && nUpper <= 0x7FFFFFFF);
    m_wndProgress.SendMessage(PBM_SETRANGE32, (WPARAM) nLower, (LPARAM) nUpper);
#else
    ASSERT(0 <= nLower && nLower <= 65535);
    ASSERT(0 <= nUpper && nUpper <= 65535);
    m_wndProgress.SetRange(nLower, nUpper);
#endif

    m_nMaxValue = nUpper;
    m_nMinValue = nLower;
    m_nStep     = nStep;

    m_wndProgress.SetStep(nStep);
}

int CProgressWnd::OffsetPos(int nPos)
{
    if (!::IsWindow(GetSafeHwnd()))
        return m_nPrevPos;

    Show();

    return SetPos(m_nPrevPos + nPos);
}

int CProgressWnd::StepIt()
{
    if (!::IsWindow(GetSafeHwnd()))
        return m_nPrevPos;

    Show();

    return SetPos(m_nPrevPos + m_nStep);
}

int CProgressWnd::SetStep(int nStep)
{
    int nOldStep = m_nStep;
    m_nStep = nStep;
    if (!::IsWindow(GetSafeHwnd()))
        return nOldStep;

    return m_wndProgress.SetStep(nStep);
}

int CProgressWnd::SetPos(int nPos)
{
#ifdef PBM_SETRANGE32
    ASSERT(-0x7FFFFFFF <= nPos && nPos <= 0x7FFFFFFF);
#else
    ASSERT(0 <= nPos && nPos <= 65535);
#endif

    if (!::IsWindow(GetSafeHwnd()))
        return m_nPrevPos;

    Show();

    CString strTitle;
    int nPercentage;

    m_nPrevPos = nPos;

    if (m_nMaxValue > m_nMinValue)
        nPercentage = (nPos*100)/(m_nMaxValue - m_nMinValue);
    else
        nPercentage = 0;

    if (nPercentage != m_nPrevPercent)
    {
        m_nPrevPercent = nPercentage;
        strTitle.Format(_T("%s [%d%%]"),m_strTitle,nPercentage);
        SetWindowText(strTitle);
    }
    return m_wndProgress.SetPos(nPos);
}

void CProgressWnd::SetText(LPCTSTR fmt, ...)
{
    if (!::IsWindow(GetSafeHwnd()))
        return;

    va_list args;
    TCHAR buffer[512];

    va_start(args, fmt);
    _vstprintf_s(buffer, sizeof(buffer)/sizeof(buffer[0]), fmt, args);
    va_end(args);

    m_Text.SetWindowText(buffer);
}

BEGIN_MESSAGE_MAP(CProgressWnd, CWnd)
    //{{AFX_MSG_MAP(CProgressWnd)
    ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_CANCEL, OnCancel)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProgressWnd message handlers

BOOL CProgressWnd::OnEraseBkgnd(CDC* pDC)
{
    // Fill background with Catchment background colour
    CBrush backBrush(GetSysColor(COLOR_BTNFACE));
    CBrush* pOldBrush = pDC->SelectObject(&backBrush);
    CRect rect;
    pDC->GetClipBox(&rect);     // Erase the area needed
    pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
    pDC->SelectObject(pOldBrush);

    return TRUE;
}

void CProgressWnd::OnCancel()
{
    m_bCancelled = TRUE;
    Hide();

    if (m_bModal)
        SendMessage(WM_CLOSE);

    CWnd *pWnd = AfxGetMainWnd();
    if (pWnd && ::IsWindow(pWnd->m_hWnd))
        pWnd->SetForegroundWindow();
}

BOOL CProgressWnd::DestroyWindow()
{
    if (m_bPersistantPosition)
        SaveCurrentSettings();

    if (m_bModal)
    {
        m_bModal = FALSE;
        CWnd *pMainWnd = AfxGetMainWnd();

        if (pMainWnd)
            pMainWnd->EnableWindow(TRUE);
    }

	return CWnd::DestroyWindow();
}

// Message pumping function that can either be used to pump messages during
// long operations. This version will only pass messages to this window (and
// all child windows). (Thanks to Michael <mbh-ep@post5.tele.dk> for this)
void CProgressWnd::PeekAndPump(BOOL bCancelOnESCkey /*= TRUE*/)
{
    if (m_bModal && ::GetFocus() != m_hWnd)
        SetFocus();

    MSG msg;
    while (!m_bCancelled && ::PeekMessage(&msg, NULL,0,0,PM_NOREMOVE))
    {
        if (bCancelOnESCkey && (msg.message == WM_CHAR) && (msg.wParam == VK_ESCAPE))
            OnCancel();

        // Cancel button disabled if modal, so we fake it.
        if (m_bModal && (msg.message == WM_LBUTTONUP))
        {
            CRect rect;
            m_CancelButton.GetWindowRect(rect);
            if (rect.PtInRect(msg.pt))
                OnCancel();
        }

        if (!AfxGetApp()->PumpMessage())
        {
            ::PostQuitMessage(0);
            return;
        }
    }
}

// Retores the previous window size from the registry
void CProgressWnd::GetPreviousSettings()
{
    int x = AfxGetApp()->GetProfileInt(szSection, szEntryX, -1);
    int y = AfxGetApp()->GetProfileInt(szSection, szEntryY, -1);

    if (x >= 0 && x < GetSystemMetrics(SM_CXSCREEN) &&
        y >= 0 && y < GetSystemMetrics(SM_CYSCREEN))
    {
        SetWindowPos(NULL, x,y, 0,0, SWP_NOSIZE|SWP_NOZORDER);
    }
    else
        CenterWindow();
}

// Saves the current window position registry
void CProgressWnd::SaveCurrentSettings()
{
    if (!IsWindow(m_hWnd))
        return;

    CRect rect;
    GetWindowRect(rect);

    AfxGetApp()->WriteProfileInt(szSection, szEntryX, rect.left);
    AfxGetApp()->WriteProfileInt(szSection, szEntryY, rect.top);
}


text:
'use strict';

angular.module('prosperWrangler')
  .controller('HomeCtrl', function ($scope, ProsperSvc) {

  });


text:
/*
 * MyPathPlanning.cpp
 *
 *  Created on: 22/giu/2016
 *      Author: gabrielefcg
 */
#include "MyPathPlanning.h"

MyPathPlanning::MyPathPlanning(int unit, Mappa* mappa, ArRobot* robot) {
	// TODO Auto-generated constructor stub
	this->unit=unit;
	this->mappa=mappa;
	this->robot=robot;
	this->num_cell = 1;
	this->duration = 3000;

}

MyPathPlanning::~MyPathPlanning() {
	// TODO Auto-generated destructor stub
}

void MyPathPlanning::percorri()
{
	SensorReadingBox* sensor = new SensorReadingBox(mappa, robot, unit, num_cell);
	int duration = 90000;

	// Collision avoidance actions at higher priority
	ArActionStallRecover recover("stall recover",unit/11);
	ArActionBumpers bumpers;
	ArActionLimiterForwards limiterAction("speed limiter far", unit/100, unit, 110);
	//ArActionLimiterForwards limiterAction("speed limiter far", 200, 1000, 200, 1);

	ArActionAvoidFront avoidFrontNear("Avoid Front Near", unit/3, 110, 45);
	//ArActionAvoidFront avoidFrontNear("Avoid Front Near", 450, 200, 15);

	robot->addAction(&recover, 100);
	robot->addAction(&bumpers, 75);
	robot->addAction(&avoidFrontNear, 55);
	//robot->addAction(&avoidFrontNear, 90);

	robot->addAction(&limiterAction, 90);
	//robot->addAction(&limiterAction, 55);

	// Action to set goal to robot
	ArActionGoto gotoPoseAction("goto");
	robot->addAction(&gotoPoseAction, 50);

	// Stop action at lower priority, so the robot stops if it has no goal
	ArActionStop stopAction("stop");
	ArActionStop stopToMapping("stop_mapping");
	robot->addAction(&stopAction, 40);

	// turn on the motors, turn off amigobot sounds
	robot->enableMotors();
	robot->comInt(ArCommands::SOUNDTOG, 0);

	//int goalNum = 0;
	// fase di inizializzazione parametri posizione robot
	int direction=0;
	ArTime start;
	start.setToNow();
	int previus_x=-1;
	int previus_y=-1;
	mappa->creaCasella(0,0);

	int numero_iterazione_ciclo = 1;

	while (Aria::getRunning())
	{
		robot->remAction(&avoidFrontNear);
		robot->remAction(&limiterAction);
		robot->remAction(&gotoPoseAction);

		cout<<"\n### INIZIO CICLO #"<< numero_iterazione_ciclo++ <<" ###"<<endl;
		robot->lock();
		int current_x;
		int current_y;

		//robot->addAction(&stopToMapping, 99);
		//cout << "stoppato" << endl;
		//ArUtil::sleep(3000);
		this->getXY(&current_x,&current_y);
		cout << "appena assegnate: x = " << current_x << " y = " << current_y << endl;
		int my_position[2];
		MyUtil::coordinateFromRobotToMine(current_x, current_y, my_position);
		current_x = MyUtil::centraCoordinate(my_position[0], unit);
		current_y = MyUtil::centraCoordinate(my_position[1], unit);
		cout << "dopo trasformazione: x = " << current_x << " y = " << current_y << endl;

		sensor->readSensor();
		/*int my_position[2];
		MyUtil::coordinateFromRobotToMine(current_x, current_y, my_position);
		current_x = my_position[0];
		current_y = my_position[1];*/
		mappa->pulisciCasella(current_x, current_y);

		if(current_x != previus_x  ||  current_y != previus_y)
		{
			start.setToNow();
		}
		previus_y = current_y;
		previus_x = current_x;

		int future_x;
		int future_y;
//numerazione stile quadranti orologio, la posizione delle celle locali non cambia in base alla direzione ma in base alla direzione della mappa;
    		int x[8];
    		int y[8];

		for(int i = 0; i < 8; i++)
		{
			x[i] = current_x;
			y[i] = current_y;
			if(i >= 1  &&  i <= 3)
			{
				x[i] = x[i] + unit; //per andare dall'indirizzo della cella dove sono a quelle subito vicine
			}
			if(i >= 5  &&  i <= 7)
			{
				x[i] = x[i] - unit;
			}
			if(i == 7  ||  (i >= 0  &&  i <= 1))
			{
				y[i] = y[i] + unit;
			}
			if(i >= 3  &&  i <= 5)
			{
				y[i] = y[i] - unit;
			}
		}
		ArPose current_position = robot->getPose();
		direction = this->approssimation2(current_position.getTh()); // modificato segno current position getTh
		cout<<"direzione del robot non approssimata: "<<current_position.getTh()<<endl;
		cout<<"direzione del robot: "<<direction<<endl;
		//cout<<"prima di scelta euristica"<<endl;
		int futura_direzione = this->sceltaEuristica(x,y,direction);
		// cout<<"prima di scelta euristica"<<endl;

		if(futura_direzione == -1)
		{
			gotoPoseAction.cancelGoal();
			robot->unlock();
			ArUtil::sleep(3000);
			cout << "pulizia completata" << endl;
			break;
		}

		future_x=x[futura_direzione];
		future_y=y[futura_direzione];

		direction=futura_direzione;

		Casella* casella= mappa->getCasella(future_x,future_y);
		cout << endl;
		cout << " - DETERMINAZIONE FUTURA DIREZIONE" << endl;
		cout << "Posizione attuale: x = " << current_x << ", y = " << current_y << endl;
		//ArLog::log(ArLog::Normal, "Going to  x = %d y = %d", future_x, future_y);
		cout << "Diretto a: x = " << future_x << ", y = " << future_y << endl;
		//cout<<"nuova casella"<<endl;
		if(casella->isOstacolo())
			cout << "Casella occupata e ";
		else
			cout << "Casella libera e ";
		if(casella->isSporco())
			cout << "sporca" << endl;
		else
			cout << "pulita" << endl;

		int future_goal_coordinate[2];
		MyUtil::coordinateFromMineToRobot(future_x, future_y, future_goal_coordinate);
		//robot->remAction(&stopToMapping);
		gotoPoseAction.setGoal(ArPose(future_goal_coordinate[0], future_goal_coordinate[1]));

		//int my_goal[2];
		//MyUtil::coordinateFromRobotToMine(gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY(), my_goal);
		//ArLog::log(ArLog::Normal, "Going to next goal  at %d %d", my_goal[0], my_goal[1]);

		if(start.mSecSince() >= duration)
		{
			ArLog::log(ArLog::Normal, "%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000);
			gotoPoseAction.cancelGoal();
			robot->unlock();
			ArUtil::sleep(500);
			break;
		}

		robot->addAction(&avoidFrontNear, 55);
		robot->addAction(&limiterAction, 90);
		robot->addAction(&gotoPoseAction, 50);

		robot->unlock();

		cout << endl;
		cout << "- STATO MAPPA" << endl;
		this->mappa->toString();
		cout << endl;
		cout<<"### FINE CICLO ###"<<endl<<endl<<endl;
		ArUtil::sleep(300);
}
cout<<"uscita dal ciclo"<<endl;

// Robot disconnected or time elapsed, shut down
Aria::exit(0);

}

//le caselle aggiornano stato occupato o meno quando ci ripasso
int MyPathPlanning::sceltaEuristica(int x[],int y[], int direzione)
{
	bool all_cleaned=true;

	int euristica_max=0;
	int indice_casella_max=0;
	int direzione_max=direzione;
	bool casella_non_visitata=false;

int euristiche_uguali=-1;
	//la direzione migliore è quella di andare avanti seguendo la propria direzione che all'inizio corrisponde alla direzione 0
	for(int i=0;i<8;i++)
	{
		int euristica=0;
		int direzione_analizzata=(direzione+i)%8;
		// cout<<"casella da valutare "<<x[i]<<" , "<<y[i]<<endl;
		//cout<<"direzione, direzione analizzata "<<direzione<<" , "<<direzione_analizzata<<endl;
		Casella* casella=mappa->getCasella(x[direzione_analizzata],y[direzione_analizzata]);
		//cout<<"ho ricevuto la casella"<<endl;

		if(!casella->isOstacolo() && casella->isExist()) // se è libera ed esiste
		{
      			euristica=euristica+12;
		}
		if(!casella->isExist()) // la casella esiste nella struttura dati ma non l'abbiamo ancora letta
	 	{
			euristica=euristica+1;
			casella_non_visitata=true; // usato per la terminazione della pulizia
	 	}
		if(casella->isSporco() && casella->isExist())
		{
			if(direzione_analizzata == direzione)
			{
				euristica = euristica + 6;
			}
			if(direzione_analizzata == (direzione+1)%8  ||  direzione_analizzata == (direzione+7)%8)
			{
				euristica=euristica+5;
			}
			if(direzione_analizzata==(direzione+2)%8||direzione_analizzata==(direzione+6)%8)
			{
				euristica=euristica+4;
			}
			if(direzione_analizzata==(direzione+3)%8||direzione_analizzata==(direzione+5)%8)
			{
				euristica=euristica+3;
			}
			if(direzione_analizzata==(direzione+4)%8)
			{
				euristica=euristica+2;
			}
    		}

		if(euristica>euristica_max)
		{
			euristica_max=euristica;
			direzione_max=direzione_analizzata;
		}
		else
		{
			if(euristica==euristica_max)
			{
				direzione_max=this->valutazioneEuristicheUguali(x, y, direzione_analizzata, direzione_max);
				//cout << "direzione migliore " << direzione_max << endl;
euristiche_uguali=direzione_max;

			}
		}
		//cout<<"euristica "<<euristica<<endl;
		//cout<<"direzione "<<direzione_analizzata<<endl;
		if(direzione_analizzata==direzione_max)
		{
			indice_casella_max=i;
		}
	}
	if(euristiche_uguali==direzione_max)
{
cout<<"euristica scelta tra uguali: "<<euristiche_uguali<<endl;
}
	//cout << "euristica max" << euristica_max << endl;
	//cout << "direzione migliore " << direzione_max << endl;
	std::vector<Casella>  lista;
	mappa->getTutteCaselle(&lista);
	for(int i=0;i<(int)lista.size();i++)
	{

		Casella da_controllare=lista[i];
		//Per essere una casella sporca deve essere sporca e anche esistere, per evitare che il robot cerchi di pulire anche caselle che non esistono realmente
		if(da_controllare.isSporco() == true  &&  da_controllare.isExist() == true)
		{
			all_cleaned=false;
		}
	}
	//Se ho pulito tutte le caselle della mappa corrente e nell'intorno del robot non esistono caselle che non sono
	//state viste in precedenza allora ho finito
	//il controllo sulle caselle è stato aggiunto per evitare che il robot finisca subito se inizia rivolto verso il muro
	if(all_cleaned == true  &&  casella_non_visitata == false)
	{
		return -1; // significa che ha pulito tutto
	}
	return direzione_max;
}

int MyPathPlanning::valutazioneEuristicheUguali(int x[],int y[], int direzione1, int direzione2)
{
	double sommatoria_settore1=0;
	double sommatoria_settore2=0;
	double sommatoria_settore1_sporco=0;
	double sommatoria_settore2_sporco=0;

	std::vector<Casella> lista;

	//cout << "direzione da controllare: " << direzione1 << endl;
	//cout << "direzione massima: " << direzione2 << endl;
	mappa->getTutteCaselle(&lista);
	for(int i=0;i<(int)lista.size();i++)
	{
		//spazzolo tutta la mappa salvando le due medie
		Casella da_controllare=lista[i];
		if(da_controllare.isExist()==true)
		{
			double angolo1=this->fromDirectionToAngle(direzione1); //Possibile problema
			double angolo2=this->fromDirectionToAngle(direzione2);

			int x_casella=da_controllare.getX();
			int y_casella=da_controllare.getY();

			int x_robot;
			int y_robot;
			this->getXY(&x_robot,&y_robot);
			//trasformazione delle coordinate del robot nel sistema di riferimento cartesiano "nostro"
			int my_position[2];
			MyUtil::coordinateFromRobotToMine(x_robot, y_robot, my_position);
			double angolo_casella=fromCartToPolar(my_position[0],my_position[1],x_casella,y_casella);
			//cout << "casella da controllare x = " << da_controllare.getX() << " y = " << da_controllare.getY() << endl;
			//cout << "angolo_casella: " << angolo_casella << endl;

			if(angolo1 == 180)
			{
				if(angolo_casella <= (-180+22.5)   ||  angolo_casella >= (180-22.5))
				{
					sommatoria_settore1++;
					if(da_controllare.isSporco()==true)
					{
						sommatoria_settore1_sporco++;
					}
				}
			}
			else
			{
				if(angolo_casella >= (angolo1-22.5)  &&  angolo_casella <= (angolo1+22.5))
				{
					sommatoria_settore1++;
					if(da_controllare.isSporco()==true)
					{
						sommatoria_settore1_sporco++;
					}
				}
			}
			if(angolo2 == 180)
			{
				if(angolo_casella <= (-180+22.5)   ||  angolo_casella >= (180-22.5))
				{
					sommatoria_settore2++;
					if(da_controllare.isSporco()==true)
					{
						sommatoria_settore2_sporco++;
					}
				}
			}
			else
			{
				if(angolo_casella >= (angolo2-22.5)  &&  angolo_casella <= (angolo2+22.5))
				{
					sommatoria_settore2++;
					if(da_controllare.isSporco()==true)
					{
						sommatoria_settore2_sporco++;
					}
				}
			}
		}

	}
	double media1=sommatoria_settore1_sporco/sommatoria_settore1;
	double media2=sommatoria_settore2_sporco/sommatoria_settore2;
	/*if(media2>media1&&media1>0)
	{
		return direzione1;
	}
	else
	{
		if(media2>0)
		{
			return direzione2;
		}
		return direzione1;
	}*/
	if(media2 > media1  &&  media2>0)
	{
		return direzione2;
	}
	else
	{
		if(media1>0)
		{
			return direzione1;
		}
		return direzione2;
	}
}

void MyPathPlanning::getXY(int* x, int* y)
{
	 ArPose current_position = robot->getPose();
	 *x = current_position.getX();
	 *y = current_position.getY();
}
  double MyPathPlanning::fromDirectionToAngle(int direzione)
  {
		double angolo;
		switch (direzione)
		{
			case 0:
				return 90.;
			case 1:
				return 45.;
			case 2:
				return 0.;
			case 3:
				return -45.;
			case 4:
				return -90.;
			case 5:
				return -135.;
			case 6:
				return 180.;
			case 7:
				return 135.;
			default:
				return 0.;

		/*
		case 0:
			return 90.;
		case 1:
			return 135.;
		case 2:
			return 180.;
		case 3:
			return -135.;
		case 4:
			return -90.;
		case 5:
			return -45.;
		case 6:
			return 0.;
		case 7:
			return 45.;
			*/
		}

		/*if(direzione<3)
		{
			angolo=90-45*direzione;
		}
		else
		{
			angolo=360-45*(direzione-2);
		}*/
  }

  double MyPathPlanning::fromCartToPolar(int origin_x, int origin_y, int x, int y)
  {
	double polar = atan2((double)(y-origin_y),(double)(x-origin_x)) * 180 / M_PI;
	if (polar == -180)
		return 180;
	  return atan2((double)(y-origin_y),(double)(x-origin_x)) * 180 / M_PI;
  }

int MyPathPlanning::approssimation2(double angle)
{
	if(angle<=(0+22.5)&&angle>=(0-22.5))
	{
		return 0;
	}
	if(angle<=(90+22.5)&&angle>=(90-22.5))
	{
		return 6;
	}
	if(angle<=(-90+22.5)&&angle>=(-90-22.5))
	{
		return 2;
	}
	if(angle<=(45+22.5)&&angle>=(45-22.5))
	{
		return 7;
	}

	if(angle<=(-45+22.5)&&angle>=(-45-22.5))
	{
		return 1;
	}
	if(angle<=(-135+22.5)&&angle>=(-135-22.5))
	{
		return 3;
	}
	if(angle<=(135+22.5)&&angle>=(135-22.5))
	{
		return 5;
	}
	return 4;

}
/*
void MyPathPlanning::MyGoto(int direzione)
{
	int angle=0;
	switch(direzione)
	{
	case 1:
		angle=45;
		break;
	case 2:
		angle=90;
		break;
	case 3:
		angle=135;
		break;
	case 4:
		angle=180;
		break;
	case 5:
		angle=-135;
		break;
	case 6:
		angle= -90;
		break;
	case 7:
		angle=-45;
		break;
	}
	robot->setDeltaHeading(angle);
	robot->move(sqrt(2*angle*angle));

	}

}
*/


text:
package com.svbio.cloudkeeper.examples.modules;

import com.svbio.cloudkeeper.model.bare.element.module.BareInputModule;
import com.svbio.cloudkeeper.model.beans.element.module.MutableChildOutToParentOutConnection;
import com.svbio.cloudkeeper.model.beans.element.module.MutableCompositeModule;
import com.svbio.cloudkeeper.model.beans.element.module.MutableConnection;
import com.svbio.cloudkeeper.model.beans.element.module.MutableInputModule;
import com.svbio.cloudkeeper.model.beans.element.module.MutableModule;
import com.svbio.cloudkeeper.model.beans.element.module.MutableOutPort;
import com.svbio.cloudkeeper.model.beans.element.module.MutablePort;
import com.svbio.cloudkeeper.model.beans.element.module.MutableProxyModule;
import com.svbio.cloudkeeper.model.beans.element.module.MutableSiblingConnection;
import com.svbio.cloudkeeper.model.beans.type.MutableDeclaredType;

import java.util.ArrayList;
import java.util.List;

public final class PascalTriangle {
    private PascalTriangle() { }

    /**
     * Returns a composite module that has the form of Pascal's triangle.
     *
     *
The composite module has {@code numOutPorts} out-ports, named {@code coef_0}, {@code coef_1}, ...,
     * {@code coef_numOutPorts} that contain the values binomial({@code n}, 0) to
     * binomial({@code n}, {@code numOutPorts}).
     *
     * @param n Number of rows in pascal triangle - 1.
     * @param numOutPorts Number of out-ports, containing the values binomial({@code n}, 0) to
     *     binomial({@code n}, {@code numOutPorts}).
     * @return composite module
     * @throws IndexOutOfBoundsException if {@code n < 1} or {@code numOutPorts < 1} or {@code numOutPorts > n + 1}
     */
    public static MutableCompositeModule createCompositeModule(int n, int numOutPorts) {
        if (n < 1 || numOutPorts < 1 || numOutPorts > n + 1) {
            throw new IndexOutOfBoundsException("Invalid arguments for Pascal triangle.");
        }

        List<MutableModule<?>> children = new ArrayList<>();
        List<MutableConnection<?>> connections = new ArrayList<>();
        children.add(
            new MutableInputModule()
                .setSimpleName("one")
                .setValue(1)
                .setOutPortType(MutableDeclaredType.fromType(Integer.class))
        );
        for (int i = 2; i <= n; ++i) {
            for (int j = 1; j < i; ++j) {
                String firstAncestorModule = j == 1 ? "one" : "pos_" + (i - 1) + '_' + (j - 1);
                String secondAncestorModule = j == i - 1 ? "one" : "pos_" + (i - 1) + '_' + j;
                String firstOutPortName = "one".equals(firstAncestorModule) ? BareInputModule.OUT_PORT_NAME : "sum";
                String secondOutPortName = "one".equals(secondAncestorModule) ? BareInputModule.OUT_PORT_NAME : "sum";
                String newModuleName = "pos_" + i + '_' + j;
                children.add(
                    new MutableProxyModule()
                        .setSimpleName(newModuleName)
                        .setDeclaration(BinarySum.class.getName())
                );
                connections.add(
                    new MutableSiblingConnection()
                        .setFromModule(firstAncestorModule).setFromPort(firstOutPortName)
                        .setToModule(newModuleName).setToPort("num1")
                );
                connections.add(
                    new MutableSiblingConnection()
                        .setFromModule(secondAncestorModule).setFromPort(secondOutPortName)
                        .setToModule(newModuleName).setToPort("num2")
                );
            }
        }

        List<MutablePort<?>> ports = new ArrayList<>();
        ports.add(
            new MutableOutPort()
                .setSimpleName("coef_0")
                .setType(MutableDeclaredType.fromType(Integer.class))
        );
        connections.add(
            new MutableChildOutToParentOutConnection()
                .setFromModule("one").setFromPort(BareInputModule.OUT_PORT_NAME)
                .setToPort("coef_0")
        );
        for (int i = 1; i < numOutPorts && i < n; ++i) {
            ports.add(
                new MutableOutPort()
                    .setSimpleName("coef_" + i)
                    .setType(MutableDeclaredType.fromType(Integer.class))
            );
            connections.add(
                new MutableChildOutToParentOutConnection()
                    .setFromModule("pos_" + n + '_' + i).setFromPort("sum")
                    .setToPort("coef_" + i)
            );
        }
        if (numOutPorts == n + 1) {
            ports.add(
                new MutableOutPort()
                    .setSimpleName("coef_" + n)
                    .setType(MutableDeclaredType.fromType(Integer.class))
            );
            connections.add(
                new MutableChildOutToParentOutConnection()
                    .setFromModule("one").setFromPort(BareInputModule.OUT_PORT_NAME)
                    .setToPort("coef_" + n)
            );
        }

        return new MutableCompositeModule()
            .setDeclaredPorts(ports)
            .setModules(children)
            .setConnections(connections);
    }

    /**
     * Returns a composite module that has the form of Pascal's triangle.
     *
     *
This method is equivalent to {@link #createCompositeModule(int, int)} with arguments {@code n} and
     * {@code n + 1}.
     *
     * @param n Number of rows in pascal triangle - 1.
     * @return composite module
     * @throws IndexOutOfBoundsException if {@code n < 1}
     */
    public static MutableCompositeModule createCompositeModule(int n) {
        return createCompositeModule(n, n + 1);
    }
}


text:
import asyncio
import gc
import unittest
from unittest import mock

import aiohttp
from aiohttp.client_reqrep import ClientRequest, ClientResponse

def _create_mocked_loop():
    """
    Single place where to define the loop to be used as mock for the tests
    Delete the `create_future()` from the mock, so it defaults to a new Future
    """
    loop_mock = unittest.mock.Mock()()
    del loop_mock.create_future
    return loop_mock

class TestProxy(unittest.TestCase):

    def setUp(self):
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

    def tearDown(self):
        # just in case if we have transport close callbacks
        self.loop.stop()
        self.loop.run_forever()
        self.loop.close()
        gc.collect()

    def _fake_coroutine(self, mock, return_value):

        def coro(*args, **kw):
            if isinstance(return_value, Exception):
                raise return_value
            return return_value
            yield  # pragma: no cover
        mock.side_effect = coro

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_connect(self, ClientRequestMock):
        req = ClientRequest(
            'GET', 'http://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop
        )
        self.assertEqual(req.proxy, 'http://proxy.example.com')

        # mock all the things!
        loop_mock = _create_mocked_loop()
        connector = aiohttp.TCPConnector(loop=loop_mock)
        self.assertIs(loop_mock, connector._loop)
        resolve_host = unittest.mock.Mock()
        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])
        connector._resolve_host = resolve_host

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))
        conn = self.loop.run_until_complete(connector.connect(req))
        self.assertEqual(req.path, 'http://www.python.org/')
        self.assertIs(conn._transport, tr)
        self.assertIs(conn._protocol, proto)

        ClientRequestMock.assert_called_with(
            'GET', 'http://proxy.example.com',
            auth=None,
            headers={'Host': 'www.python.org'},
            loop=loop_mock)

    def test_proxy_auth(self):
        with self.assertRaises(ValueError) as ctx:
            ClientRequest(
                'GET', 'http://python.org',
                proxy='http://proxy.example.com',
                proxy_auth=('user', 'pass'),
                loop=unittest.mock.Mock())
        self.assertEqual(
            ctx.exception.args[0],
            "proxy_auth must be None or BasicAuth() tuple",
        )

    def test_proxy_connection_error(self):
        connector = aiohttp.TCPConnector(loop=self.loop)
        connector._resolve_host = resolve_mock = unittest.mock.Mock()
        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))

        req = ClientRequest(
            'GET', 'http://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        expected_headers = dict(req.headers)
        with self.assertRaises(aiohttp.ProxyConnectionError):
            self.loop.run_until_complete(connector.connect(req))
        self.assertEqual(req.path, '/')
        self.assertEqual(dict(req.headers), expected_headers)

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_auth(self, ClientRequestMock):
        proxy_req = ClientRequest(
            'GET', 'http://proxy.example.com',
            auth=aiohttp.helpers.BasicAuth('user', 'pass'),
            loop=self.loop
        )
        ClientRequestMock.return_value = proxy_req
        self.assertIn('AUTHORIZATION', proxy_req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)

        loop_mock = _create_mocked_loop()
        connector = aiohttp.TCPConnector(loop=loop_mock)
        connector._resolve_host = resolve_mock = unittest.mock.Mock()
        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'http://www.python.org',
            proxy='http://proxy.example.com',
            proxy_auth=aiohttp.helpers.BasicAuth('user', 'pass'),
            loop=self.loop,
        )
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)
        conn = self.loop.run_until_complete(connector.connect(req))

        self.assertEqual(req.path, 'http://www.python.org/')
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertIn('PROXY-AUTHORIZATION', req.headers)
        self.assertNotIn('AUTHORIZATION', proxy_req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)

        ClientRequestMock.assert_called_with(
            'GET', 'http://proxy.example.com',
            auth=aiohttp.helpers.BasicAuth('user', 'pass'),
            loop=unittest.mock.ANY, headers=unittest.mock.ANY)
        conn.close()

    def test_auth_utf8(self):
        proxy_req = ClientRequest(
            'GET', 'http://proxy.example.com',
            auth=aiohttp.helpers.BasicAuth('юзер', 'пасс', 'utf-8'),
            loop=self.loop)
        self.assertIn('AUTHORIZATION', proxy_req.headers)

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_auth_from_url(self, ClientRequestMock):
        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com',
                                  loop=self.loop)
        ClientRequestMock.return_value = proxy_req
        self.assertIn('AUTHORIZATION', proxy_req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)

        loop_mock = _create_mocked_loop()
        connector = aiohttp.TCPConnector(loop=loop_mock)
        connector._resolve_host = resolve_mock = unittest.mock.Mock()
        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'http://www.python.org',
            proxy='http://user:pass@proxy.example.com',
            loop=self.loop,
        )
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)
        conn = self.loop.run_until_complete(connector.connect(req))

        self.assertEqual(req.path, 'http://www.python.org/')
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertIn('PROXY-AUTHORIZATION', req.headers)
        self.assertNotIn('AUTHORIZATION', proxy_req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)

        ClientRequestMock.assert_called_with(
            'GET', 'http://user:pass@proxy.example.com',
            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)
        conn.close()

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_auth__not_modifying_request(self, ClientRequestMock):
        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com',
                                  loop=self.loop)
        ClientRequestMock.return_value = proxy_req
        proxy_req_headers = dict(proxy_req.headers)

        loop_mock = _create_mocked_loop()
        connector = aiohttp.TCPConnector(loop=loop_mock)
        connector._resolve_host = resolve_mock = unittest.mock.Mock()
        self._fake_coroutine(resolve_mock, OSError('nothing personal'))

        req = ClientRequest(
            'GET', 'http://www.python.org',
            proxy='http://user:pass@proxy.example.com',
            loop=self.loop,
        )
        req_headers = dict(req.headers)
        with self.assertRaises(aiohttp.ProxyConnectionError):
            self.loop.run_until_complete(connector.connect(req))
        self.assertEqual(req.headers, req_headers)
        self.assertEqual(req.path, '/')
        self.assertEqual(proxy_req.headers, proxy_req_headers)

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_connect(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        self.loop.run_until_complete(connector._create_connection(req))

        self.assertEqual(req.path, '/')
        self.assertEqual(proxy_req.method, 'CONNECT')
        self.assertEqual(proxy_req.path, 'www.python.org:443')
        tr.pause_reading.assert_called_once_with()
        tr.get_extra_info.assert_called_with('socket', default=None)

        self.loop.run_until_complete(proxy_req.close())
        proxy_resp.close()
        self.loop.run_until_complete(req.close())

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_connect_runtime_error(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        tr.get_extra_info.return_value = None
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        with self.assertRaisesRegex(
                RuntimeError, "Transport does not expose socket instance"):
            self.loop.run_until_complete(connector._create_connection(req))

        self.loop.run_until_complete(proxy_req.close())
        proxy_resp.close()
        self.loop.run_until_complete(req.close())

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_connect_http_proxy_error(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(
            start_mock, unittest.mock.Mock(status=400, reason='bad request'))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        tr.get_extra_info.return_value = None
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        with self.assertRaisesRegex(
                aiohttp.HttpProxyError, "400, message='bad request'"):
            self.loop.run_until_complete(connector._create_connection(req))

        self.loop.run_until_complete(proxy_req.close())
        proxy_resp.close()
        self.loop.run_until_complete(req.close())

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_connect_resp_start_error(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(start_mock, OSError("error message"))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        tr.get_extra_info.return_value = None
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        with self.assertRaisesRegex(OSError, "error message"):
            self.loop.run_until_complete(connector._create_connection(req))

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_request_port(self, ClientRequestMock):
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=self.loop)
        ClientRequestMock.return_value = proxy_req

        loop_mock = _create_mocked_loop()
        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        tr.get_extra_info.return_value = None
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'http://localhost:1234/path',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        self.loop.run_until_complete(connector._create_connection(req))
        self.assertEqual(req.path, 'http://localhost:1234/path')

    def test_proxy_auth_property(self):
        req = aiohttp.ClientRequest(
            'GET', 'http://localhost:1234/path',
            proxy='http://proxy.example.com',
            proxy_auth=aiohttp.helpers.BasicAuth('user', 'pass'),
            loop=self.loop)
        self.assertEqual(('user', 'pass', 'latin1'), req.proxy_auth)

    def test_proxy_auth_property_default(self):
        req = aiohttp.ClientRequest(
            'GET', 'http://localhost:1234/path',
            proxy='http://proxy.example.com',
            loop=self.loop)
        self.assertIsNone(req.proxy_auth)

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_connect_pass_ssl_context(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop,
        )
        self.loop.run_until_complete(connector._create_connection(req))

        loop_mock.create_connection.assert_called_with(
            mock.ANY,
            ssl=connector.ssl_context,
            sock=mock.ANY,
            server_hostname='www.python.org')

        self.assertEqual(req.path, '/')
        self.assertEqual(proxy_req.method, 'CONNECT')
        self.assertEqual(proxy_req.path, 'www.python.org:443')
        tr.pause_reading.assert_called_once_with()
        tr.get_extra_info.assert_called_with('socket', default=None)

        self.loop.run_until_complete(proxy_req.close())
        proxy_resp.close()
        self.loop.run_until_complete(req.close())

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_https_auth(self, ClientRequestMock):
        loop_mock = _create_mocked_loop()
        proxy_req = ClientRequest('GET', 'http://proxy.example.com',
                                  auth=aiohttp.helpers.BasicAuth('user',
                                                                 'pass'),
                                  loop=loop_mock)
        ClientRequestMock.return_value = proxy_req

        proxy_resp = ClientResponse('get', 'http://proxy.example.com')
        proxy_resp._loop = loop_mock
        proxy_req.send = send_mock = unittest.mock.Mock()
        send_mock.return_value = proxy_resp
        proxy_resp.start = start_mock = unittest.mock.Mock()
        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))

        connector = aiohttp.TCPConnector(loop=loop_mock)

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))

        self.assertIn('AUTHORIZATION', proxy_req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)

        req = ClientRequest(
            'GET', 'https://www.python.org',
            proxy='http://proxy.example.com',
            loop=self.loop
        )
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)
        self.loop.run_until_complete(connector._create_connection(req))

        self.assertEqual(req.path, '/')
        self.assertNotIn('AUTHORIZATION', req.headers)
        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)
        self.assertNotIn('AUTHORIZATION', proxy_req.headers)
        self.assertIn('PROXY-AUTHORIZATION', proxy_req.headers)

        self.loop.run_until_complete(proxy_req.close())
        proxy_resp.close()
        self.loop.run_until_complete(req.close())

class TestProxyConnector(unittest.TestCase):

    """
    Backward compatibility simple test. Most testing happens in TextProxy.
    """

    def setUp(self):
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

    def tearDown(self):
        # just in case if we have transport close callbacks
        self.loop.stop()
        self.loop.run_forever()
        self.loop.close()
        gc.collect()

    def _fake_coroutine(self, mock, return_value):

        def coro(*args, **kw):
            if isinstance(return_value, Exception):
                raise return_value
            return return_value
            yield  # pragma: no cover
        mock.side_effect = coro

    def test_ctor(self):
        connector = aiohttp.ProxyConnector(
            'http://localhost:8118',
            proxy_auth=aiohttp.helpers.BasicAuth('user', 'pass'),
            loop=self.loop,
        )

        self.assertEqual('http://localhost:8118', connector.proxy)
        self.assertEqual(
            aiohttp.helpers.BasicAuth('user', 'pass'),
            connector.proxy_auth
        )
        self.assertTrue(connector.force_close)

    @unittest.mock.patch('aiohttp.connector.ClientRequest')
    def test_connect(self, ClientRequestMock):
        req = ClientRequest('GET', 'http://www.python.org', loop=self.loop)
        self.assertEqual(req.path, '/')

        loop_mock = _create_mocked_loop()
        connector = aiohttp.ProxyConnector('http://proxy.example.com',
                                           loop=loop_mock)
        self.assertIs(loop_mock, connector._loop)

        resolve_host = unittest.mock.Mock()
        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])
        connector._resolve_host = resolve_host

        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
        self._fake_coroutine(loop_mock.create_connection, (tr, proto))
        conn = self.loop.run_until_complete(connector.connect(req))
        self.assertEqual(req.path, 'http://www.python.org/')
        self.assertIs(conn._transport, tr)
        self.assertIs(conn._protocol, proto)

        # resolve_host.assert_called_once_with('proxy.example.com', 80)
        tr.get_extra_info.assert_called_once_with('sslcontext')

        ClientRequestMock.assert_called_with(
            'GET', 'http://proxy.example.com',
            auth=None,
            headers={'Host': 'www.python.org'},
            loop=loop_mock)
        conn.close()


text: Tests that 'skip all pauses' mode blocks breakpoint and gets cancelled right at page reload.


text:
import Ember from 'ember';
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';

export function instrument(method) {
  return method();
}

/*
  Assert that `addedRecord` has a valid type so it can be added to the
  relationship of the `record`.

  The assert basically checks if the `addedRecord` can be added to the
  relationship (specified via `relationshipMeta`) of the `record`.

  This utility should only be used internally, as both record parameters must
  be an InternalModel and the `relationshipMeta` needs to be the meta
  information about the relationship, retrieved via
  `record.relationshipFor(key)`.

  @method assertPolymorphicType
  @param {InternalModel} internalModel
  @param {RelationshipMeta} relationshipMeta retrieved via
         `record.relationshipFor(key)`
  @param {InternalModel} addedRecord record which
         should be added/set for the relationship
*/
let assertPolymorphicType;

if (DEBUG) {
  let checkPolymorphic = function checkPolymorphic(modelClass, addedModelClass) {
    if (modelClass.__isMixin) {
      //TODO Need to do this in order to support mixins, should convert to public api
      //once it exists in Ember
      return modelClass.__mixin.detect(addedModelClass.PrototypeMixin);
    }
    if (Ember.MODEL_FACTORY_INJECTIONS) {
      modelClass = modelClass.superclass;
    }
    return modelClass.detect(addedModelClass);
  };

  assertPolymorphicType = function assertPolymorphicType(parentInternalModel, relationshipMeta, addedInternalModel) {
    let addedModelName = addedInternalModel.modelName;
    let parentModelName = parentInternalModel.modelName;
    let key = relationshipMeta.key;
    let relationshipModelName = relationshipMeta.type;
    let relationshipClass = parentInternalModel.store.modelFor(relationshipModelName);
    let assertionMessage = `You cannot add a record of modelClass '${addedModelName}' to the '${parentModelName}.${key}' relationship (only '${relationshipModelName}' allowed)`;

    assert(assertionMessage, checkPolymorphic(relationshipClass, addedInternalModel.modelClass));
  };
}

export { assertPolymorphicType }


text:
package info.rmapproject.core.model.event;

/**
 * Interface for Events that involve creating a new RMap object e.g. Create DiSCO, Update DiSCO, Create Agent etc.
 * @author smorrissey
 *
 */
public interface RMapEventCreation extends RMapEventWithNewObjects {

}


text:
package main

import (
  "bufio"
  "fmt"
  "io"
  "net/http"
  "os"
  "strings"
  "time"
)

func main() {
  urls, err := readLines(os.Args[1])
  if err != nil {
    fmt.Printf("reading url list from %s: %v", os.Args[1], err)
    os.Exit(1)
  }

  start := time.Now()
  ch := make(chan string)
  for _, url := range urls {
    go fetech(url, ch) // start a gorountine
  }
  for range urls {
    fmt.Println(<-ch) // receive from channel ch
  }
  fmt.Printf("%.2fs elapsed\n", time.Since(start).Seconds())
}

func readLines(filepath string) ([]string, error) {
  file, err := os.Open(filepath)
  if err != nil {
    return nil, err
  }
  defer file.Close()

  var lines []string
  scanner := bufio.NewScanner(file)
  for scanner.Scan() {
    lines = append(lines, scanner.Text())
  }
  return lines, scanner.Err()
}

func fetech(url string, ch chan<-string) {
  start := time.Now()
  resp, err := http.Get(url)
  if err != nil {
    ch <- fmt.Sprint(err) // send to channel ch
    return
  }

  filename := generateFilename(url)
  f, err := os.Create(filename)
  if err != nil {
    ch <- fmt.Sprintf("while creating file %s: %v", filename, err)
    return
  }

  nbytes, err := io.Copy(f, resp.Body)
  resp.Body.Close()
  f.Close()
  if err != nil {
    ch <- fmt.Sprintf("while reading %s: %v", url, err)
    return
  }
  secs := time.Since(start).Seconds()
  ch <- fmt.Sprintf("%.2fs    %7d    %s", secs, nbytes, url)
}

func generateFilename(url string) string {
  filename := strings.Replace(url, "http://", "", -1)
  filename = strings.Replace(filename, ".", "_", -1)
  filename = strings.Replace(filename, "/", "_", -1)
  return filename
}


text:
import React, { Component ,PropTypes} from 'react';
import Node from './Node.js';

export default class extends Component{
    static defaultProps={
        idKey:'typeId',
        contentKey:'typeName',
        expandNodes:''
    };

    reassign(children,resetValue){
        let {treeWeightMap,curTreeWeightMap}=this,
            {idKey}=this.props,
            _this=this;
        if(children&&children.length){
            children.forEach(node=>{
                let nodeId=node[idKey];
                if(resetValue!==undefined){
                    curTreeWeightMap[nodeId]=resetValue
                }else{
                    curTreeWeightMap[nodeId]=treeWeightMap[nodeId]
                }
                if(node.children&&node.children.length){
                    _this.reassign(node.children,resetValue)
                }
            })
        }
    }
    recalculateWeightMap(nodeId,node){
        let {pathMap,treeWeightMap,curTreeWeightMap}=this,
            isAdded=false;
        if(treeWeightMap[nodeId]>curTreeWeightMap[nodeId]){
            isAdded=true
        }
        if(isAdded){
            //计算出增加值
            let origiWeight=curTreeWeightMap[nodeId],
                fullWeight=treeWeightMap[nodeId],
                increment=fullWeight-origiWeight,
                curKey=nodeId;
            //所有父节点加上increment
            do{
                curTreeWeightMap[curKey]+=increment;
                curKey=pathMap[curKey];
            }while(curKey!=undefined)

            //当前节点和子节点直接copy treeWeightMap上的原始值
            this.reassign(node.children)
            //console.log(curTreeWeightMap)
        }else{
            //计算出减少值
            let origiWeight=curTreeWeightMap[nodeId],
                decrement=origiWeight,
                curKey=nodeId;
            //所有父节点减去decrement
            do{
                curTreeWeightMap[curKey]-=decrement;
                curKey=pathMap[curKey];
            }while(curKey!=undefined)

            //子节点为0
            this.reassign(node.children,0)
            //console.log(curTreeWeightMap)
        }
    }
    calculateTreeWeight(node,treeWeightMap){
        let {children}=node,
            _this=this,
            {idKey}=this.props;
        this.curTreeWeightMap[node[idKey]]=0;
        if(children&&children.length){
            var total=0;
            children.forEach(node=>{
                total+=_this.calculateTreeWeight(node,treeWeightMap)
            })
            treeWeightMap[node[idKey]]=total
            return total;
        }else{
            treeWeightMap[node[idKey]]=1
            return 1;
        }
    }
    constructor(props,context){
        super(props,context);
        let expandNodes=props.expandNodes||{},
            data=props.data||[],
            _this=this,
            {idKey}=this.props;
        this.state={
            expandNodes,
            clickNodeId:-1
        };
        this.pathMap={};
        this.leafMap={};
        this.treeWeightMap={};
        this.curTreeWeightMap={};
        this.climbTree(data,null,this.pathMap,this.leafMap);
        data.forEach(node=>{
            _this.treeWeightMap[node[idKey]]=_this.calculateTreeWeight(node,_this.treeWeightMap)
        })
    }
    getExpandNodes(){
        return this.state.expandNodes;
    }
    getSelectedNodes(){
        let {leafMap,curTreeWeightMap}=this,
            idArray=[];
        for(let key in curTreeWeightMap){
            if(curTreeWeightMap[key]==1&&leafMap[key]){
                idArray.push(key)
            }
        }
        return idArray;
    }
    componentWillReceiveProps(nextProps) {
        this.leafMap={};
        this.pathMap={};
        let expandNodes=nextProps.expandNodes||{},
            data=nextProps.data||[],
            {pathMap,leafMap}=this,
            _this=this,
            {idKey}=this.props;
        this.climbTree(data,null,pathMap,leafMap);
        data.forEach(node=>{
            _this.treeWeightMap[node[idKey]]=_this.calculateTreeWeight(node,_this.treeWeightMap)
        })

        //console.log(this.treeWeightMap)
        this.setState({
            expandNodes
        });
    }
    climbTree(nodes,parent,pathMap,leafMap){
        let _this=this,
            {idKey}=this.props;
        nodes.forEach((node)=>{
            let nodeId=node[idKey],
                children=node.children;
            if(parent){
                pathMap[nodeId]=parent[idKey];
            }
            if(children&&children.length){
                _this.climbTree(children,node,pathMap,leafMap)
            }else{
                leafMap[nodeId]=true
            }
        })
    }
    renderTree(){
        let data=this.props.data,
            expandNodes=this.recalculateExpands(this.state.expandNodes||{});
        return this.renderNode(data,expandNodes);
    }
    nodeClickCallback(nodeId,type,node){
        this.recalculateWeightMap(nodeId,node,false)
        this.setState({
            clickNodeId:nodeId
        })
        let {clickCallback}=this.props;
        clickCallback&&clickCallback(nodeId,type,node);
    }
    getIds(list, idArray) {
        let {idKey}=this.props,
            _this=this;
        list.forEach((item)=>{
            idArray.push(item[idKey])
            item.children&&item.children.length && _this.getIds(item.children, idArray)
        })
    }
    getChild(node) {
        let children = node.children||[],
            idArray = []
        this.getIds(children,idArray)
        return idArray;
    }
    toggleCallback(nodeId,node){
        let {expandNodes}=this.state;
        if(expandNodes[nodeId]){
            let childIds = this.getChild(node);
            delete expandNodes[nodeId]
            // 同时删除该节点children的nodeId对应元素
            for(let item in expandNodes){
                childIds.indexOf(parseInt(item))>=0 && delete expandNodes[item]
            }
        }else{
            expandNodes[nodeId]=true;
        }
        this.setState({
            expandNodes
        })
    }
    recalculateExpands(expandNodes){
        let result={},
            {pathMap}=this;
        for(let key in expandNodes){
            let curKey=key;
            do{
                result[curKey]=true;
                curKey=pathMap[curKey];
            }while(curKey!=undefined)
        }
        return result;
    }
    renderNode(data,expandNodes){
        let self=this,
            {idKey,contentKey}=self.props,
            {treeWeightMap,curTreeWeightMap}=this;
        return data.map(function(item,index){
            let children=null,
                itemKey=item[idKey],
                multiSelectStatus='';
            if(item.children&&item.children.length){
                children=self.renderNode(item.children,expandNodes);
            }
            if(treeWeightMap[itemKey]>curTreeWeightMap[itemKey]){
                if(curTreeWeightMap[itemKey]>0){
                    multiSelectStatus='part-select'
                }
            }else{
                multiSelectStatus='active'
            }
            return (

                <Node toggleCallback={::self.toggleCallback}
                      clickCallback={::self.nodeClickCallback}
                      type={children?'branch':'leaf'}
                      nodeId={itemKey}
                      node={item}
                      multiSelectStatus={multiSelectStatus}
                      expand={expandNodes[itemKey]}
                      nodeContent={item[contentKey]}>
                </Node>
                {expandNodes[itemKey]?(

                    {children}

):null}

)
        })
    }
    render(){
        let tree=this.renderTree();
        return(

            {tree}

)
    }
}