Beispiel #1
0
bool
SbAccessFilterPolicy::setPath(wxString path)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if ((rule == NULL) || path.IsEmpty()){
		return (false);
	}

	startChange();
	if (rule->rule.sbaccess.path != NULL) {
		free(rule->rule.sbaccess.path);
		rule->rule.sbaccess.path = NULL;
		setModified();
	}

	if (path.Cmp(wxT("any")) != 0) {
		rule->rule.sbaccess.path = strdup(path.fn_str());
		setModified();
	}

	finishChange();
	return (true);
}
Beispiel #2
0
bool
SbAccessFilterPolicy::setAccessMask(unsigned int mask)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	rule->rule.sbaccess.amask = mask;
	setModified();
	finishChange();

	return (true);
}
Beispiel #3
0
bool
SbAccessFilterPolicy::setSubjectNone(void)
{
	struct apn_rule		*rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	PolicyUtils::cleanSubject(&rule->rule.sbaccess.cs);
	setModified();
	finishChange();

	return (true);
}
Beispiel #4
0
bool
SbAccessFilterPolicy::setLogNo(int log)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	rule->rule.sbaccess.log = log;
	setModified();
	finishChange();

	return (true);
}
Beispiel #5
0
bool
SbAccessFilterPolicy::setActionNo(int action)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	rule->rule.sbaccess.action = action;
	setModified();
	finishChange();

	return (true);
}
Beispiel #6
0
bool
SbAccessFilterPolicy::setSubjectKey(wxString key)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	PolicyUtils::cleanSubject(&rule->rule.sbaccess.cs);

	rule->rule.sbaccess.cs.type = APN_CS_KEY;
	rule->rule.sbaccess.cs.value.keyid = strdup(key.fn_str());

	setModified();
	finishChange();

	return (true);
}
Beispiel #7
0
bool
SbAccessFilterPolicy::setSubjectUid(uid_t uid)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	PolicyUtils::cleanSubject(&rule->rule.sbaccess.cs);

	rule->rule.sbaccess.cs.type = APN_CS_UID;
	rule->rule.sbaccess.cs.value.uid = uid;

	setModified();
	finishChange();

	return (true);
}
Beispiel #8
0
void
AnPickFromFs::adoptFileName(const wxString &fileName)
{
	char		 resolve[PATH_MAX];
	char		*resolved;
	wxString	 msg;
	wxString	 trimmedFileName;

	startChange();
	if (fileName.IsEmpty() || fileName == wxT("any")
	    || (pickerMode_ & MODE_NORESOLVE)) {
		fileName_ = fileName;
	} else {
		trimmedFileName = trimFileName(fileName);
		resolved = realpath(trimmedFileName.fn_str(), resolve);
		if (resolved != NULL) {
			fileName_ = wxString::From8BitData(resolved);
			if (fileName_ != trimmedFileName) {
				msg = _("Symbolic link was resolved");
			} else {
				msg = wxEmptyString;
			}
		} else {
			msg = wxString::From8BitData(anoubis_strerror(errno));
			msg.Prepend(_("Failure to resolve: "));
			fileName_ = trimmedFileName;
		}
		/* XXX ch: depending on the mode we could do furter checks */
		showInfo(msg);
	}
	if (inputTextCtrl_->GetValue() != fileName_) {
		inputTextCtrl_->ChangeValue(fileName_);
	}

	inputTextCtrl_->DiscardEdits();

	finishChange();
}
Beispiel #9
0
bool
SbAccessFilterPolicy::setSubjectSelf(bool selfSigned)
{
	struct apn_rule *rule;

	rule = getApnRule();
	if (rule == NULL) {
		return (false);
	}

	startChange();
	PolicyUtils::cleanSubject(&rule->rule.sbaccess.cs);

	if (selfSigned) {
		rule->rule.sbaccess.cs.type = APN_CS_KEY_SELF;
	} else {
		rule->rule.sbaccess.cs.type = APN_CS_UID_SELF;
	}

	setModified();
	finishChange();

	return (true);
}
Beispiel #10
0
bool
MSLaneChanger::change() {
    // Find change-candidate. If it is on an allowed lane, try to change
    // to the right (there is a rule in Germany that you have to change
    // to the right, unless you are overtaking). If change to the right
    // isn't possible, check if there is a possibility to overtake (on the
    // left.
    // If candidate isn't on an allowed lane, changing to an allowed has
    // priority.
    myCandi = findCandidate();
    MSVehicle* vehicle = veh(myCandi);

#ifdef DEBUG_VEHICLE_GUI_SELECTION
    if (gDebugSelectedVehicle == vehicle->getID()) {
        int bla = 0;
    }
#endif
    if (vehicle->getLaneChangeModel().isChangingLanes()) {
        return continueChange(vehicle, myCandi);
    }
    if (!myAllowsChanging || vehicle->getLaneChangeModel().alreadyChanged()) {
        registerUnchanged(vehicle);
        return false;
    }
    std::pair<MSVehicle* const, SUMOReal> leader = getRealLeader(myCandi);
    if (myChanger.size() == 1 || vehicle->getLaneChangeModel().isOpposite()) {
        if (changeOpposite(leader)) {
            return true;
        }
        registerUnchanged(vehicle);
        return false;
    }

#ifndef NO_TRACI
    if (vehicle->isRemoteControlled()) {
        return false; // !!! temporary; just because it broke, here
    }
#endif
    vehicle->updateBestLanes(); // needed?
    for (int i = 0; i < (int) myChanger.size(); ++i) {
        vehicle->adaptBestLanesOccupation(i, myChanger[i].dens);
    }
    const std::vector<MSVehicle::LaneQ>& preb = vehicle->getBestLanes();
    // check whether the vehicle wants and is able to change to right lane
    int state1 = 0;
    if (mayChange(-1)) {
        state1 = checkChangeWithinEdge(-1, leader, preb);
        bool changingAllowed1 = (state1 & LCA_BLOCKED) == 0;
        // change if the vehicle wants to and is allowed to change
        if ((state1 & LCA_RIGHT) != 0 && changingAllowed1) {
            vehicle->getLaneChangeModel().setOwnState(state1);
            startChange(vehicle, myCandi, -1);
            return true;
        }
        if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
            (myCandi - 1)->lastBlocked = vehicle;
            if ((myCandi - 1)->firstBlocked == 0) {
                (myCandi - 1)->firstBlocked = vehicle;
            }
        }
    }



    // check whether the vehicle wants and is able to change to left lane
    int state2 = 0;
    if (mayChange(1)) {
        state2 = checkChangeWithinEdge(1, leader, preb);
        bool changingAllowed2 = (state2 & LCA_BLOCKED) == 0;
        // change if the vehicle wants to and is allowed to change
        if ((state2 & LCA_LEFT) != 0 && changingAllowed2) {
            vehicle->getLaneChangeModel().setOwnState(state2);
            startChange(vehicle, myCandi, 1);
            return true;
        }
        if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
            (myCandi + 1)->lastBlocked = vehicle;
            if ((myCandi + 1)->firstBlocked == 0) {
                (myCandi + 1)->firstBlocked = vehicle;
            }
        }
    }

    if ((state1 & (LCA_URGENT)) != 0 && (state2 & (LCA_URGENT)) != 0) {
        // ... wants to go to the left AND to the right
        // just let them go to the right lane...
        state2 = 0;
    }
    vehicle->getLaneChangeModel().setOwnState(state2 | state1);

    // only emergency vehicles should change to the opposite side on a
    // multi-lane road
    if (vehicle->getVehicleType().getVehicleClass() == SVC_EMERGENCY
            && changeOpposite(leader)) {
        return true;
    } else {
        registerUnchanged(vehicle);
        return false;
    }
}
MainInterface::MainInterface(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainInterface)
{
    ui->setupUi(this);

    key_pressed = false;
    start_or_end = true;

    target = 0;

    FPGA_Init();

    XYZ_Update(L_X_CURRENT);
    XYZ_Update(L_Y_CURRENT);
    XYZ_Update(L_Z_CURRENT);

    XYZ_Update(L_X_ABSOLUTE);
    XYZ_Update(L_Y_ABSOLUTE);
    XYZ_Update(L_Z_ABSOLUTE);

    XYZ_Update(L_X_REMAIN);
    XYZ_Update(L_Y_REMAIN);
    XYZ_Update(L_Z_REMAIN);

    axisIndexUpdate();

    connect(spark_info ,SIGNAL(xyzChange(int)) ,this ,SLOT(XYZ_Update(int)));
    connect(spark_info ,SIGNAL(coorIndexChange()) ,this ,SLOT(axisIndexUpdate()));

    model = new QStandardItemModel;
    /*数据表索引发生改变*/
    connect(spark_info ,SIGNAL(tableChange()) ,this ,SLOT(tableDataUpdate()));
    /*数据表的加工段和当前加工行发生改变*/
    connect(spark_info ,SIGNAL(tableRowChange()),this ,SLOT(tableRollUpdate()));

    /*初始化功能栏*/
    initFuncBar();

    /*初始化为显示态*/
    tableStateUpdate(TABLE_SHOW);

    spark = new SparkThread();
    connect(spark_info ,SIGNAL(startChange()) ,spark ,SLOT(sparkChange()));

    scan = new ScanThread();
    scan->start();
    connect(this ,SIGNAL(keyPress(int)) ,scan ,SLOT(keyPress(int)));
    connect(this ,SIGNAL(keyRelease(int)) ,scan ,SLOT(keyRelease(int)));

    mesg = new MesgBox(this);
    mesg ->setHidden(false);

    menu = new StartMenu(this);
    menu ->setHidden(true);
    connect(menu ,SIGNAL(finish(bool)) ,this ,SLOT(menuShow(bool)));

    timer = new QTimer(this);
    timer->setInterval(300);
    connect(timer ,SIGNAL(timeout()) ,this ,SLOT(menuTimeout()));

    ui->verticalLayout->addWidget(mesg);
    ui->verticalLayout->addWidget(menu);

    command = new QCommand(this);
    command->setHidden(false);
    /*命令行输入结束时的信号连接*/
    connect(command ,SIGNAL(finish()) ,this ,SLOT(commandFinish()));

    alerts = new QAlerts(this);
    alerts->setHidden(false);
    connect(spark_info ,SIGNAL(boolChange()) ,alerts ,SLOT(alertCheck()));

    clear = new ClearScreen(parent);
    clear->setHidden(true);

#ifndef Q_WS_X11
    QRect screen_size = qApp->desktop()->screenGeometry();
    clear->setGeometry(0, 0, screen_size.width(), screen_size.height());
    clear->setCursor(QCursor(Qt::BlankCursor));

    watcher = new QFileSystemWatcher(this);
    watcher->addPath(DEV_DIR);
    connect(watcher ,SIGNAL(directoryChanged(QString)) ,this ,SLOT(mouseChange(QString)));

    if(!QFile::exists(USB_MOUSE)){
        setCursor(QCursor(Qt::BlankCursor));
        is_usb = false;
    }else{
        setCursor(QCursor(Qt::ArrowCursor));
        is_usb = true;
    }
#else
    clear->setGeometry(0 ,0 ,1024 ,768);
#endif
    connect(scan ,SIGNAL(clear()) ,clear ,SLOT(show()));

    ui->horizontalLayout_3->addWidget(command);
    ui->horizontalLayout_4->addWidget(alerts);
}
Beispiel #12
0
bool
MSLaneChanger::change() {
    // Find change-candidate. If it is on an allowed lane, try to change
    // to the right (there is a rule in Germany that you have to change
    // to the right, unless you are overtaking). If change to the right
    // isn't possible, check if there is a possibility to overtake (on the
    // left.
    // If candidate isn't on an allowed lane, changing to an allowed has
    // priority.
    myCandi = findCandidate();
    MSVehicle* vehicle = veh(myCandi);

#ifdef DEBUG_VEHICLE_GUI_SELECTION
    if (gDebugSelectedVehicle == vehicle->getID()) {
        int bla = 0;
    }
#endif
    if (vehicle->getLaneChangeModel().isChangingLanes()) {
        return continueChange(vehicle, myCandi);
    }
    if (!myAllowsChanging || vehicle->getLaneChangeModel().alreadyChanged()) {
        registerUnchanged(vehicle);
        return false;
    }
    std::pair<MSVehicle* const, SUMOReal> leader = getRealLeader(myCandi);
    if (myChanger.size() == 1) {
        if (changeOpposite(leader)) {
            return true;
        }
        registerUnchanged(vehicle);
        return false;
    }

#ifndef NO_TRACI
    if (vehicle->isRemoteControlled()) {
        return false; // !!! temporary; just because it broke, here
    }
#endif
    vehicle->updateBestLanes(); // needed?
    for (int i = 0; i < (int) myChanger.size(); ++i) {
        vehicle->adaptBestLanesOccupation(i, myChanger[i].dens);
    }
    const std::vector<MSVehicle::LaneQ>& preb = vehicle->getBestLanes();
    // check whether the vehicle wants and is able to change to right lane
    int state1 = 0;
    if (mayChange(-1)) {
        state1 = checkChangeWithinEdge(-1, leader, preb);
        bool changingAllowed1 = (state1 & LCA_BLOCKED) == 0;
        // change if the vehicle wants to and is allowed to change
        if ((state1 & LCA_RIGHT) != 0 && changingAllowed1) {
            vehicle->getLaneChangeModel().setOwnState(state1);
            startChange(vehicle, myCandi, -1);
            return true;
        }
        if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
            (myCandi - 1)->lastBlocked = vehicle;
            if ((myCandi - 1)->firstBlocked == 0) {
                (myCandi - 1)->firstBlocked = vehicle;
            }
        }
    }



    // check whether the vehicle wants and is able to change to left lane
    int state2 = 0;
    if (mayChange(1)) {
        state2 = checkChangeWithinEdge(1, leader, preb);
        bool changingAllowed2 = (state2 & LCA_BLOCKED) == 0;
        // change if the vehicle wants to and is allowed to change
        if ((state2 & LCA_LEFT) != 0 && changingAllowed2) {
            vehicle->getLaneChangeModel().setOwnState(state2);
            startChange(vehicle, myCandi, 1);
            return true;
        }
        if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
            (myCandi + 1)->lastBlocked = vehicle;
            if ((myCandi + 1)->firstBlocked == 0) {
                (myCandi + 1)->firstBlocked = vehicle;
            }
        }
    }

    if ((state1 & (LCA_URGENT)) != 0 && (state2 & (LCA_URGENT)) != 0) {
        // ... wants to go to the left AND to the right
        // just let them go to the right lane...
        state2 = 0;
    }
    vehicle->getLaneChangeModel().setOwnState(state2 | state1);

    // check whether the vehicles should be swapped
    if (myAllowsSwap && ((state1 & (LCA_URGENT)) != 0 || (state2 & (LCA_URGENT)) != 0)) {
        // get the direction ...
        ChangerIt target;
        int direction = 0;
        if ((state1 & (LCA_URGENT)) != 0) {
            // ... wants to go right
            target = myCandi - 1;
            direction = -1;
        }
        if ((state2 & (LCA_URGENT)) != 0) {
            // ... wants to go left
            target = myCandi + 1;
            direction = 1;
        }
        MSVehicle* prohibitor = target->lead;
        if (target->hoppedVeh != 0) {
            SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
            if (prohibitor == 0 || (hoppedPos > vehicle->getPositionOnLane() && prohibitor->getPositionOnLane() > hoppedPos)) {
                prohibitor = 0;// !!! vehicles should not jump over more than one lanetarget->hoppedVeh;
            }
        }
        if (prohibitor != 0
                &&
                ((prohibitor->getLaneChangeModel().getOwnState() & (LCA_URGENT/*|LCA_SPEEDGAIN*/)) != 0
                 &&
                 (prohibitor->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
                 !=
                 (vehicle->getLaneChangeModel().getOwnState() & (LCA_LEFT | LCA_RIGHT))
                )
           ) {

            // check for position and speed
            if (prohibitor->getVehicleType().getLengthWithGap() == vehicle->getVehicleType().getLengthWithGap()) {
                // ok, may be swapped
                // remove vehicle to swap with
                MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
                if (i != target->lane->myTmpVehicles.end()) {
                    assert(*i == prohibitor);
                    target->lane->myTmpVehicles.erase(i);
                    startChange(vehicle, myCandi, direction);
                    startChange(prohibitor, target, -direction);
                    std::swap(vehicle->myState, prohibitor->myState);
                    myCandi->lead = prohibitor;
                    target->lead = vehicle;
                    return true;
                }
            }
        }
    }
    if (!changeOpposite(leader)) {
        registerUnchanged(vehicle);
        return false;
    } else {
        return true;
    }
}