Beispiel #1
0
void RouteFinder::runProcess() {
	cv::Mat grayImg, image;
	ushort imgCntBendCrossing = 0;
	ushort imgCntDone = 0;
	ushort setSpeedCnt = 0;
	m_Running = true;

	m_Controller->printString("Start", me, 1);
    while(m_Running) {
        image = m_PicCreator->GetImage();
        if (!image.empty()) {
			cv::cvtColor(image,grayImg,CV_BGR2GRAY);
			cv::Mat fltImg = cv::Mat::zeros(grayImg.rows, grayImg.cols, CV_8UC1);
			if (m_Rows == 0) {
				m_Rows = grayImg.rows;
				m_Cols = grayImg.cols;
			}
			edgeDetection(&grayImg, &fltImg);
			m_GrayImg = grayImg.clone();
			m_FinalFltImg = fltImg.clone();
			outPutNrOfIms(imgCntDone);
			setDriveState(setSpeedCnt);
			checkLaneLost();
			setBendCheck(imgCntBendCrossing);
			setCrossingSearchState(imgCntBendCrossing);
			checkCrossingPriorityLane();
			checkTargetFieldFound();
			checkMaxNrOfImgsReached(imgCntDone);
        }
    }
    m_Controller->printString("Stop", me, 1);
}
Beispiel #2
0
/*
 * Return TRUE if any drives are available
 * in any of the libraries.
 */
int
IfDrivesAvail(void)
{
    int i;
    int avail;
    LibraryInfo_t *lib;

    ReconfigLock();		/* wait on reconfig */

    (void) setDriveState(B_TRUE);

    avail = 0;
    for (i = 0; i < libraryTable.entries; i++) {
        lib = &libraryTable.data[i];

        /*
         * If not historian or third party, add number of
         * drives available.
         */
        if (!IS_LIB_HISTORIAN(lib) && !IS_LIB_THIRDPARTY(lib)) {
            avail += lib->li_numAvailDrives;
        }
    }
    ReconfigUnlock();		/* allow reconfig */

    return (avail != 0);
}
Beispiel #3
0
/*
 * Check if specified drive is free.
 */
int
IsDriveFree(
    int drive)
{
    DriveInfo_t *entry;

    (void) setDriveState(B_TRUE);

    entry = &driveTable.data[drive];
    return (IS_DRIVE_AVAIL(entry) && (IS_DRIVE_BUSY(entry) == 0));
}
Beispiel #4
0
/*
 * Initialize table of media libraries for stager.  This function
 * builds tables for the libraries, removable media drives and manual
 * drives from shared memory.
 */
static void
initLibraryTable(void)
{
    extern char *program_name;
    int jmap;
    dev_ent_t *dev;
    size_t size;
    LibraryInfo_t *lib;
    DriveInfo_t *drive;
    int ldx;
    int ddx;
    dev_ent_t *dev_head;
    int numDiskVols;
    int numHoneycombVols;
    DiskVolsDictionary_t *diskvols;
    boolean_t found_historian = B_FALSE;

    /*
     * If table already exists, free current table
     * and re-initialize.
     */
    if (libraryTable.data != NULL) {
        SamFree(libraryTable.data);
        SamFree(driveTable.data);

        libraryTable.data = NULL;
        driveTable.data = NULL;
    }

    if (vsnTable.data != NULL) {
        SamFree(vsnTable.data);

        vsnTable.data = NULL;
        if (vsnTable.catalog == B_TRUE) {
            CatalogTerm();
            vsnTable.catalog = B_FALSE;
        }
    }

    libraryTable.entries = 0;
    driveTable.entries = 0;
    vsnTable.entries = 0;

    dev_head = GetDevices(B_FALSE);

    for (dev = dev_head; dev != NULL;
            dev = (struct dev_ent *)SHM_REF_ADDR(dev->next)) {

        if (dev->equ_type == DT_HISTORIAN) {
            libraryTable.entries++;
            found_historian = B_TRUE;

        } else if (IS_THIRD_PARTY(dev)) {
            libraryTable.entries++;
            foundThirdParty = B_TRUE;

        } else if (IS_ROBOT(dev) || dev->equ_type == DT_PSEUDO_SC) {
            dev_ent_t *find;

            libraryTable.entries++;

            /*
             * Find all drives belonging to this library.
             */
            for (find = dev_head; find != NULL;
                    find = (struct dev_ent *)SHM_REF_ADDR(find->next)) {
                if (find->eq != dev->eq) {
                    if (find->fseq == dev->eq) {
                        driveTable.entries++;
                    }
                }
            }

        } else if (dev->fseq == 0) {
            /*
             * Manual drive.
             */
            libraryTable.entries++;
            driveTable.entries++;
            manualDrives++;
        }
    }

    Trace(TR_MISC, "Removable media libraries: %d drives: %d",
          found_historian ? libraryTable.entries - 1 : libraryTable.entries,
          driveTable.entries);

    /*
     * If defined, allocate a library table for disk archiving.
     * The disk archiving library will have a disk drive defined
     * for each vsn.
     */
    numDiskVols = 0;
    numHoneycombVols = 0;

    diskvols = DiskVolsNewHandle(program_name, DISKVOLS_VSN_DICT, 0400);
    if (diskvols != NULL) {
        (void) diskvols->Numof(diskvols, &numDiskVols, DV_numof_disk);
        (void) diskvols->Numof(diskvols, &numHoneycombVols,
                               DV_numof_honeycomb);
        (void) DiskVolsDeleteHandle(DISKVOLS_VSN_DICT);
    }

    if (numDiskVols > 0) {
        libraryTable.entries++;
        driveTable.entries += numDiskVols * STREAMS_PER_DISKVOL;
        Trace(TR_MISC, "Disk volumes: %d", numDiskVols);
    }

    if (numHoneycombVols > 0) {
        libraryTable.entries++;
        driveTable.entries += numHoneycombVols;
        Trace(TR_MISC, "Stk5800 volumes: %d", numHoneycombVols);
    }

    /*
     * Issue message if no removable media or disk archive volumes
     * were found.
     */
    if (libraryTable.entries == 0 ||
            (found_historian && libraryTable.entries == 1)) {
        SendCustMsg(HERE, 19007);
    }


    /*
     * Allocate library and drive tables and enter data.  If the
     * table count is zero, allocate one table entry anyway.
     */

    size = (libraryTable.entries ? libraryTable.entries : 1)
           * sizeof (LibraryInfo_t);
    SamMalloc(libraryTable.data, size);
    (void) memset(libraryTable.data, 0, size);

    size = (driveTable.entries ? driveTable.entries : 1)
           * sizeof (DriveInfo_t);
    SamMalloc(driveTable.data, size);
    (void) memset(driveTable.data, 0, size);

    lib = libraryTable.data;
    drive = driveTable.data;
    ldx = 0;
    ddx = 0;

    for (dev = dev_head; dev != NULL;
            dev = (struct dev_ent *)SHM_REF_ADDR(dev->next)) {

        lib->li_flags = 0;
        lib->li_device = dev;

        if (dev->type == DT_HISTORIAN) {
            (void) strncpy(lib->li_name, "Historian",
                           sizeof (lib->li_name));
            SET_LIB_HISTORIAN(lib);
            lib->li_eq = dev->eq;
            lib->li_numDrives = manualDrives;

        } else if (IS_THIRD_PARTY(dev)) {
            (void) strncpy(lib->li_name, "ThirdParty",
                           sizeof (lib->li_name));
            SET_LIB_THIRDPARTY(lib);
            lib->li_eq = dev->eq;
            (void) InitMigration(dev);

        } else if (IS_ROBOT(dev) || dev->equ_type == DT_PSEUDO_SC) {
            dev_ent_t *find;

            memcpy(lib->li_name, dev->set, sizeof (lib->li_name));
            lib->li_eq = dev->eq;

            /* Check if remote sam client */
            if (dev->equ_type == DT_PSEUDO_SC) {
                SET_LIB_REMOTE(lib);
            }

            /*
             * Find all drives belonging to this library.
             */
            find = dev_head;	/* Head of dev entries */
            for (find = dev_head; find != NULL;
                    find = (struct dev_ent *)SHM_REF_ADDR(find->next)) {
                if (find->eq != dev->eq) {
                    if (find->fseq == dev->eq) {
                        lib->li_numDrives++;

                        sprintf(drive->dr_name, "%s%d",
                                sam_mediatoa(find->type),
                                find->eq);
                        drive->dr_device = find;
                        drive->dr_lib = ldx;

                        /*
                         * Increment to next drive
                         * table entry.
                         */
                        drive++;
                        ddx++;
                    }
                }
            }

        } else if (dev->fseq == 0) {
            /*
             * Manual drive.
             */
            sprintf(lib->li_name, "%s%d", sam_mediatoa(dev->type),
                    dev->eq);
            SET_LIB_MANUAL(lib);
            lib->li_numDrives = 1;
            lib->li_manual = ddx;
            lib->li_eq = dev->eq;

            sprintf(drive->dr_name, "%s%d", sam_mediatoa(dev->type),
                    dev->eq);
            drive->dr_device = dev;
            drive->dr_lib = ldx;

            /* Increment to next drive table entry. */
            drive++;
            ddx++;

        } else {
            /* Not a library, continue to next dev entry. */
            continue;
        }

        /*
         * Set number of drives allowed.  Increment to next
         * library table entry.
         */
        lib->li_numAllowedDrives = lib->li_numDrives;
        lib++;
        ldx++;
    }

    if (numDiskVols > 0) {
        char *mtype;

        mtype = sam_mediatoa(DT_DISK);
        (void) strncpy(lib->li_name, mtype, sizeof (lib->li_name));
        SET_LIB_DISK(lib);
        SET_LIB_AVAIL(lib);
        lib->li_numDrives = numDiskVols * STREAMS_PER_DISKVOL;
        lib->li_numAllowedDrives = numDiskVols * STREAMS_PER_DISKVOL;
        lib->li_numAvailDrives = numDiskVols * STREAMS_PER_DISKVOL;

        /*
         * Define drives belonging to disk archive library.
         */
        for (jmap = 0; jmap < numDiskVols * STREAMS_PER_DISKVOL;
                jmap++) {

            sprintf(drive->dr_name, "%s%d", mtype, jmap);
            drive->dr_lib = ldx;
            SET_DRIVE_AVAIL(drive);

            /* Increment to next drive table entry. */
            drive++;
            ddx++;
        }

        lib++;
        ldx++;
    }

    if (numHoneycombVols > 0) {
        char *mtype;

        mtype = sam_mediatoa(DT_STK5800);
        (void) strncpy(lib->li_name, mtype, sizeof (lib->li_name));
        SET_LIB_HONEYCOMB(lib);
        SET_LIB_AVAIL(lib);
        lib->li_numDrives = numHoneycombVols;
        lib->li_numAllowedDrives = numHoneycombVols;
        lib->li_numAvailDrives = numHoneycombVols;

        /*
         * Define drives belonging to honeycomb archive library.
         */
        for (jmap = 0; jmap < numHoneycombVols; jmap++) {

            sprintf(drive->dr_name, "%s%d", mtype, jmap);
            drive->dr_lib = ldx;
            SET_DRIVE_AVAIL(drive);

            /* Increment to next drive table entry. */
            drive++;
            ddx++;
        }
    }

    (void) setDriveState(B_FALSE);		/* get current drive state */
}