/// <summary> /// Creates data with data type pre-ended to byte list. Only implemented for string at this time /// </summary> /// <param name="dataType">Traci data type</param> /// <param name="data">data to be turned into bytes</param> /// <returns>data(in bytes) with data type pre-ended</returns> public static List <byte> CreateTraciData(TraciConstants.DataType dataType, object data) { try { List <byte> dataBytes = new List <byte>(); dataBytes.Add((byte)dataType); if (dataType == TraciConstants.DataType.TYPE_STRING) { dataBytes = AddToByteList(dataBytes, CreateTraciString((string)data)); } return(dataBytes); } catch (Exception ex) { throw new SumoControllerException("Error Creating Traci Data", ex); } }
/// <summary> /// Class for initialising a Change State message /// </summary> /// <param name="connection">the Sumo/Traci connection</param> /// <param name="command">Traci Command</param> /// <param name="variableName">Traci variable command (sub command)</param> /// <param name="variableValue">Valueassociated with variable, normally identifier of Sumo object</param> /// <param name="dataType">traci data type</param> /// <param name="newData">Value to set</param> public TraciChangeState(Connection connection, TraciConstants.Command command, TraciConstants.Variable variableName, string variableValue, TraciConstants.DataType dataType, object newData) : base(connection) { try { _command = command; _variableName = variableName; _variableValue = variableValue; _dataType = dataType; _newData = newData; SendMessage(); } catch (Exception ex) { throw new SumoControllerException("Error Initialising Traci Change State class", ex); } }