• 大小: 996KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-05-14
  • 语言: Matlab
  • 标签: 未分类  

资源简介

matlab开发-TraCI4Matlab。一个用于matlab的traci接口的实现。

资源截图

代码片段和文件信息

function addSubscriptionFilter(filterType params)
%addSubscriptionFilter An internal function to add subscription filters.

%   Copyright 2019 Universidad Nacional de Colombia
%   Politecnico Jaime Isaza Cadavid.
%   Authors: Andres Acosta Jairo Espinosa Jorge Espinosa.
%   $Id$

import traci.constants
global message

if nargin < 2
    params = [];
end

command = constants.CMD_ADD_SUBscriptION_FILTER;
message.queue = [message.queue uint8(sscanf(command‘%x‘))];

if ismember(filterType {constants.FILTER_TYPE_NONE...
        constants.FILTER_TYPE_NOOPPOSITEconstants.FILTER_TYPE_TURN...
        constants.FILTER_TYPE_LEAD_FOLLOW})
    assert(isempty(params));
    len = 1+1+1;
    message.string = [message.string uint8([lensscanf(command‘%x‘)...
        sscanf(filterType‘%x‘)])];
elseif ismember(filterType{constants.FILTER_TYPE_DOWNSTREAM_DIST...
        constants.FILTER_TYPE_UPSTREAM_DIST})
    assert(isnumeric(params))
    len = 1+1+1+1+8;
    message.string = [message.string uint8([len sscanf(command‘%x‘)...
        sscanf(filterType‘%x‘)sscanf(constants.TYPE_DOUBLE‘%x‘)]) ...
        traci.packInt64(params)];
elseif ismember(filterType {constants.FILTER_TYPE_VCLASS...
        constants.FILTER_TYPE_VTYPE})
    len = 1+1+1+1+4;
    try
        for i = 1:length(params)
            len = len + 4 + length(params{i});
        end
    catch e
        throw(MException(‘TraCI4Matlab:InvalidArgument‘...
            sprintf(‘Filter type %s requires identifier list as parameter.‘...
            filterType)))
    end
    
    if len <= 255
        message.string = [message.string uint8([len sscanf(command‘%x‘) ...
            sscanf(filterType‘%x‘)])];
    else
        len = len + 4;
        message.string = [message.string uint8(0) traci.packInt32(len) ...
            uint8([sscanf(command‘%x‘) sscanf(filterType‘%x‘)])];
    end
    message.string = [message.string uint8(sscanf(...
        constants.TYPE_STRINGLIST‘%x‘)) traci.packInt32(length(params))];
    for i = 1:length(params)
        message.string = [message.string traci.packInt32(length(params{1})) ...
            uint8(params{i})];
    end
elseif strcmp(filterType constants.FILTER_TYPE_LANES)
    lanes = unique(params);
    if length(lanes) ~= length(params)
        warning(‘Ignoring duplicate lane specification for subscription filter.‘);
    end
    len = 1+1+1+1+length(lanes);
    message.string = [message.string uint8([len sscanf(command‘%x‘) ...
        sscanf(filterType‘%x‘) length(lanes)])];
    for i = 1:length(lanes)
        if lanes(i) <= -128 && lanes{i} >= 128
            throw(MException(‘TraCI4Matlab:InvalidArgument‘...
                ‘Filter type lanes requires numeric index list as parameter.‘));
        end
        if lanes(i) < 0
            lanes(i) = lanes(i) + 256;
        end
        message.string = [message.string uint8(lanes(i))];
    end
end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         797  2019-01-03 12:05  traci4matlab\+traci\+edge\adaptTraveltime.m
     文件         866  2019-01-03 12:05  traci4matlab\+traci\+edge\getAdaptedTraveltime.m
     文件         547  2019-01-03 12:05  traci4matlab\+traci\+edge\getCO2Emission.m
     文件         536  2019-01-03 12:05  traci4matlab\+traci\+edge\getCOEmission.m
     文件        1187  2019-01-03 12:05  traci4matlab\+traci\+edge\getContextSubscriptionResults.m
     文件         828  2019-01-03 12:05  traci4matlab\+traci\+edge\getEffort.m
     文件         639  2019-01-03 12:05  traci4matlab\+traci\+edge\getElectricityConsumption.m
     文件         576  2019-01-03 12:05  traci4matlab\+traci\+edge\getFuelConsumption.m
     文件         536  2019-01-03 12:05  traci4matlab\+traci\+edge\getHCEmission.m
     文件         391  2019-01-03 12:05  traci4matlab\+traci\+edge\getIDCount.m
     文件         495  2019-01-03 12:05  traci4matlab\+traci\+edge\getIDList.m
     文件         513  2019-01-03 12:05  traci4matlab\+traci\+edge\getLaneNumber.m
     文件         696  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepHaltingNumber.m
     文件         571  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepLength.m
     文件         586  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepMeanSpeed.m
     文件         599  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepOccupancy.m
     文件         585  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepPersonIDs.m
     文件         642  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepVehicleIDs.m
     文件         633  2019-01-03 12:05  traci4matlab\+traci\+edge\getLastStepVehicleNumber.m
     文件         556  2019-01-03 12:05  traci4matlab\+traci\+edge\getNoiseEmission.m
     文件         535  2019-01-03 12:05  traci4matlab\+traci\+edge\getNOxEmission.m
     文件         564  2019-01-03 12:05  traci4matlab\+traci\+edge\getPmxEmission.m
     文件         495  2019-01-03 12:05  traci4matlab\+traci\+edge\getStreetName.m
     文件        1117  2019-01-03 12:05  traci4matlab\+traci\+edge\getSubscriptionResults.m
     文件         554  2019-01-03 12:05  traci4matlab\+traci\+edge\getTraveltime.m
     文件         950  2019-01-03 12:05  traci4matlab\+traci\+edge\getUniversal.m
     文件         587  2019-01-03 12:05  traci4matlab\+traci\+edge\getWaitingTime.m
     文件         737  2019-01-03 12:05  traci4matlab\+traci\+edge\setEffort.m
     文件         515  2019-01-03 12:05  traci4matlab\+traci\+edge\setMaxSpeed.m
     文件        1810  2019-01-03 12:05  traci4matlab\+traci\+edge\subscribe.m
     文件        2311  2019-01-03 12:05  traci4matlab\+traci\+edge\subscribeContext.m
............此处省略515个文件信息

评论

共有 条评论