public virtual SumoGeometry GetPolygon(System.Object obj) { SumoGeometry output = new SumoGeometry(); try { if (obj.GetType().Equals(typeof(SumoGeometry))) { output = (SumoGeometry)obj; } } catch (Exception ex) { MonoBehaviour.print(ex.GetBaseException()); } return(output); }
void ReadLanes() { linkIds = (SumoStringList)conn.do_job_get(Lane.getIDList()); int z = 0; foreach (string id in linkIds) { //z++; //Debug.Log("id:" + id); SumoGeometry centers = (SumoGeometry)conn.do_job_get(Lane.getShape(id)); double width = ((java.lang.Double)conn.do_job_get(Lane.getWidth(id))).doubleValue(); double length = ((java.lang.Double)conn.do_job_get(Lane.getLength(id))).doubleValue(); //Debug.Log("Coords: " + centers.coords + "// Width" + width + "// Length" + length); linkList.Add(new Link(centers.coords, width, length, id)); //foreach (SumoPosition2D d2 in obj.coords) //{ // Debug.Log("Z= " + z+ "// x= "+d2.x + "// y= " + d2.y); //} //Debug.Log(obj); //if (z >= 15) { break; } } }
private void Add_variable(Object input) { if (input.GetType().Equals(typeof(int))) { this.cmd.Content().WriteInt((int)input); } else if (input.GetType().Equals(typeof(string))) { this.cmd.Content().WriteStringASCII((string)input); } else if (input.GetType().Equals(typeof(Double))) { this.cmd.Content().WriteDouble((Double)input); } else if (input.GetType().Equals(typeof(Byte))) { this.cmd.Content().WriteByte((Byte)input); } else if (input.GetType().Equals(typeof(bool))) { bool b = (bool)input; cmd.Content().WriteUnsignedByte(b ? 1 : 0); } else if (input.GetType().Equals(typeof(SumoColor))) { SumoColor sc = (SumoColor)input; this.cmd.Content().WriteByte(sc.r); this.cmd.Content().WriteByte(sc.g); this.cmd.Content().WriteByte(sc.b); this.cmd.Content().WriteByte(sc.a); } else if (input.GetType().Equals(typeof(SumoGeometry))) { SumoGeometry sg = (SumoGeometry)input; cmd.Content().WriteUnsignedByte(sg.coords.Count()); foreach (SumoPosition2D pos in sg.coords) { cmd.Content().WriteDouble(pos.x); cmd.Content().WriteDouble(pos.y); } } else if (input.GetType().Equals(typeof(SumoPosition2D))) { SumoPosition2D pos = (SumoPosition2D)input; cmd.Content().WriteDouble(pos.x); cmd.Content().WriteDouble(pos.y); } else if (input.GetType().Equals(typeof(SumoTLSPhase))) { SumoTLSPhase stp = (SumoTLSPhase)input; this.cmd.Content().WriteUnsignedByte(Constants.TYPE_INTEGER); cmd.Content().WriteInt(stp.duration); this.cmd.Content().WriteUnsignedByte(Constants.TYPE_INTEGER); cmd.Content().WriteInt(stp.duration1); this.cmd.Content().WriteUnsignedByte(Constants.TYPE_INTEGER); cmd.Content().WriteInt(stp.duration2); this.cmd.Content().WriteUnsignedByte(Constants.TYPE_STRING); cmd.Content().WriteStringASCII(stp.phasedef); } else if (input.GetType().Equals(typeof(SumoStringList))) { SumoStringList sl = (SumoStringList)input; cmd.Content().WriteInt(sl.getList().Count()); foreach (string s in sl.getList()) { cmd.Content().WriteStringASCII(s); } } }
public /*synchronized*/ Object do_job_get(SumoCommand sc) { Object localObject1 = null; ResponseContainer localResponseContainer = queryAndVerifySingle(sc.cmd); Command localCommand = localResponseContainer.getResponse(); verifyGetVarResponse(localCommand, sc.response, sc.input2, sc.input3); verify("", Convert.ToInt32(sc.output_type), Convert.ToInt32(localCommand.Content().readUnsignedByte())); if (sc.output_type == 9) { localObject1 = Convert.ToInt32(localCommand.Content().readInt()); } else if (sc.output_type == 11) { localObject1 = Convert.ToDouble(localCommand.Content().readDouble()); } else if (sc.output_type == 12) { localObject1 = localCommand.Content().readStringUTF8(); } else { double d1; double d3; if (sc.output_type == 1) { d1 = localCommand.Content().readDouble(); d3 = localCommand.Content().readDouble(); localObject1 = new SumoPosition2D(d1, d3); } else { double d6; if (sc.output_type == 3) { d1 = localCommand.Content().readDouble(); d3 = localCommand.Content().readDouble(); d6 = localCommand.Content().readDouble(); localObject1 = new SumoPosition3D(d1, d3, d6); } else if (sc.output_type == 14) { SumoStringList localSumoStringList = new SumoStringList(); int k = localCommand.Content().readInt(); for (int i1 = 0; i1 < k; i1++) { localSumoStringList.add(localCommand.Content().readStringASCII()); } localObject1 = localSumoStringList; } else if (sc.output_type == 5) { double d2 = localCommand.Content().readDouble(); double d4 = localCommand.Content().readDouble(); d6 = localCommand.Content().readDouble(); double d8 = localCommand.Content().readDouble(); localObject1 = new SumoBoundingBox(d2, d4, d6, d8); } else { Object localObject3; if (sc.input2 == 181) { int i = localCommand.Content().readByte(); localObject3 = new SumoStopFlags((byte)i); localObject1 = localObject3; if (sc.info.Equals("isStopped")) { localObject1 = Convert.ToBoolean(((SumoStopFlags)localObject3).stopped); } if (sc.info.Equals("isStoppedTriggered")) { localObject1 = Convert.ToBoolean(((SumoStopFlags)localObject3).triggered); } if (sc.info.Equals("isAtContainerStop")) { localObject1 = Convert.ToBoolean(((SumoStopFlags)localObject3).isContainerStop); } if (sc.info.Equals("isStoppedParking")) { localObject1 = Convert.ToBoolean(((SumoStopFlags)localObject3).getID() == 12); } if (sc.info.Equals("isAtBusStop")) { localObject1 = Convert.ToBoolean(((SumoStopFlags)localObject3).isBusStop); } } else { int i3; if (sc.output_type == 15) { Object localObject2 = null; int i2; int i7; int i8; Object localObject4; if (sc.input2 == 39) { localObject3 = new SumoLinkList(); localCommand.Content().readUnsignedByte(); localCommand.Content().readInt(); i2 = localCommand.Content().readInt(); localObject2 = new StringList[i2]; for (int i4 = 0; i4 < i2; i4++) { localCommand.Content().readUnsignedByte(); i7 = localCommand.Content().readInt(); for (i8 = 0; i8 < i7; i8++) { localCommand.Content().readUnsignedByte(); localCommand.Content().readInt(); String str4 = localCommand.Content().readStringASCII(); localObject4 = localCommand.Content().readStringASCII(); String str5 = localCommand.Content().readStringASCII(); ((SumoLinkList)localObject3).add(new SumoLink(str4, (String)localObject4, str5)); } } localObject1 = localObject3; } else { int m; int i9; int i10; if (sc.input2 == 43) { localCommand.Content().readUnsignedByte(); localCommand.Content().readInt(); m = localCommand.Content().readInt(); for (i2 = 0; i2 < m; i2++) { localCommand.Content().readUnsignedByte(); String str1 = localCommand.Content().readStringASCII(); localCommand.Content().readUnsignedByte(); i7 = localCommand.Content().readInt(); localCommand.Content().readUnsignedByte(); i8 = localCommand.Content().readInt(); localCommand.Content().readUnsignedByte(); i9 = localCommand.Content().readInt(); localObject4 = new SumoTLSLogic(str1, i7, i8, i9); localCommand.Content().readUnsignedByte(); i10 = localCommand.Content().readInt(); for (int i11 = 0; i11 < i10; i11++) { localCommand.Content().readUnsignedByte(); int i12 = localCommand.Content().readInt(); localCommand.Content().readUnsignedByte(); int i13 = localCommand.Content().readInt(); localCommand.Content().readUnsignedByte(); int i14 = localCommand.Content().readInt(); localCommand.Content().readUnsignedByte(); String str8 = localCommand.Content().readStringASCII(); ((SumoTLSLogic)localObject4).add(new SumoTLSPhase(i12, i13, i14, str8)); } localObject1 = localObject4; } } else { int i5; if (sc.input2 == 51) { localCommand.Content().readUnsignedByte(); localCommand.Content().readInt(); m = localCommand.Content().readInt(); SumoLinkList localSumoLinkList = new SumoLinkList(); for (i5 = 0; i5 < m; i5++) { localCommand.Content().readUnsignedByte(); String str2 = localCommand.Content().readStringASCII(); localCommand.Content().readUnsignedByte(); String str3 = localCommand.Content().readStringASCII(); localCommand.Content().readUnsignedByte(); i9 = (byte)localCommand.Content().readUnsignedByte(); localCommand.Content().readUnsignedByte(); byte b = (byte)localCommand.Content().readUnsignedByte(); localCommand.Content().readUnsignedByte(); i10 = (byte)localCommand.Content().readUnsignedByte(); localCommand.Content().readUnsignedByte(); String str6 = localCommand.Content().readStringASCII(); localCommand.Content().readUnsignedByte(); String str7 = localCommand.Content().readStringASCII(); localCommand.Content().readUnsignedByte(); double d9 = localCommand.Content().readDouble(); localSumoLinkList.add(new SumoLink(str2, str3, (byte)i9, b, (byte)i10, d9, str6, str7)); //CUIDADO } localObject1 = localSumoLinkList; } else { m = localCommand.Content().readInt(); Object[] localObject5 = new Object[m]; for (i3 = 0; i3 < m; i3++) { i5 = localCommand.Content().readUnsignedByte(); localObject5[i3] = get_value(i5, localCommand); } localObject1 = localObject5; } } } } else { int j; if (sc.output_type == 6) { j = localCommand.Content().readUnsignedByte(); SumoGeometry localSumoGeometry = new SumoGeometry(); for (i3 = 0; i3 < j; i3++) { double d5 = Convert.ToDouble((Double)get_value(11, localCommand)); double d7 = Convert.ToDouble((Double)get_value(11, localCommand)); localSumoGeometry.add(new SumoPosition2D(d5, d7)); } localObject1 = localSumoGeometry; } else if (sc.output_type == 17) { j = localCommand.Content().readUnsignedByte(); int n = localCommand.Content().readUnsignedByte(); i3 = localCommand.Content().readUnsignedByte(); int i6 = localCommand.Content().readUnsignedByte(); localObject1 = new SumoColor(j, n, i3, i6); } else if (sc.output_type == 7) { localObject1 = Convert.ToInt16(localCommand.Content().readUnsignedByte()); } } } } } } return(localObject1); }
public static SumoCommand Add(string polygonID, SumoGeometry shape, SumoColor color, bool fill, string polygonType, int layer) { Object[] array = new Object[] { shape, color, fill, polygonType, layer }; return(new SumoCommand(Constants.CMD_SET_POLYGON_VARIABLE, Constants.ADD, polygonID, array)); }
public virtual Object Do_job_get(SumoCommand sc) { lock (this) { Object output = null; ResponseContainer rc = QueryAndVerifySingle(sc.cmd); Command resp = rc.GetResponse(); VerifyGetVarResponse(resp, sc.response, sc.input2, sc.input3); Verify("", sc.output_type, (int)resp.Content().ReadUnsignedByte()); if (sc.output_type == Constants.TYPE_INTEGER) { output = resp.Content().ReadInt(); } else if (sc.output_type == Constants.TYPE_DOUBLE) { output = resp.Content().ReadDouble(); } else if (sc.output_type == Constants.TYPE_STRING) { output = resp.Content().ReadStringUTF8(); } else if (sc.output_type == Constants.POSITION_2D) { double x = resp.Content().ReadDouble(); double y = resp.Content().ReadDouble(); output = new SumoPosition2D(x, y); } else if (sc.output_type == Constants.POSITION_3D) { double x = resp.Content().ReadDouble(); double y = resp.Content().ReadDouble(); double z = resp.Content().ReadDouble(); output = new SumoPosition3D(x, y, z); } else if (sc.output_type == Constants.TYPE_STRINGLIST) { SumoStringList ssl = new SumoStringList(); int laenge = resp.Content().ReadInt(); for (int i = 0; i < laenge; i++) { ssl.Add(resp.Content().ReadStringASCII()); } output = ssl; } else if (sc.output_type == Constants.TYPE_BOUNDINGBOX) { double min_x = resp.Content().ReadDouble(); double min_y = resp.Content().ReadDouble(); double max_x = resp.Content().ReadDouble(); double max_y = resp.Content().ReadDouble(); output = new SumoBoundingBox(min_x, min_y, max_x, max_y); } else if (sc.output_type == Constants.TYPE_COMPOUND) { Object[] obj = null; if (sc.input2 == Constants.TL_CONTROLLED_LINKS) { SumoLinkList sll = new SumoLinkList(); resp.Content().ReadUnsignedByte(); resp.Content().ReadInt(); int laenge = resp.Content().ReadInt(); obj = new StringList[laenge]; for (int i = 0; i < laenge; i++) { resp.Content().ReadUnsignedByte(); int anzahl = resp.Content().ReadInt(); for (int i1 = 0; i1 < anzahl; i1++) { resp.Content().ReadUnsignedByte(); resp.Content().ReadInt(); string from = resp.Content().ReadStringASCII(); string to = resp.Content().ReadStringASCII(); string over = resp.Content().ReadStringASCII(); sll.Add(new SumoLink(from, to, over)); } } output = sll; } else if (sc.input2 == Constants.TL_COMPLETE_DEFINITION_RYG) { resp.Content().ReadUnsignedByte(); resp.Content().ReadInt(); int length = resp.Content().ReadInt(); for (int i = 0; i < length; i++) { resp.Content().ReadUnsignedByte(); string subID = resp.Content().ReadStringASCII(); resp.Content().ReadUnsignedByte(); int type = resp.Content().ReadInt(); resp.Content().ReadUnsignedByte(); int subParameter = resp.Content().ReadInt(); resp.Content().ReadUnsignedByte(); int currentPhaseIndex = resp.Content().ReadInt(); SumoTLSLogic stl = new SumoTLSLogic(subID, type, subParameter, currentPhaseIndex); resp.Content().ReadUnsignedByte(); int nbPhases = resp.Content().ReadInt(); for (int i1 = 0; i1 < nbPhases; i1++) { resp.Content().ReadUnsignedByte(); int duration = resp.Content().ReadInt(); resp.Content().ReadUnsignedByte(); int duration1 = resp.Content().ReadInt(); resp.Content().ReadUnsignedByte(); int duration2 = resp.Content().ReadInt(); resp.Content().ReadUnsignedByte(); string phaseDef = resp.Content().ReadStringASCII(); stl.Add(new SumoTLSPhase(duration, duration1, duration2, phaseDef)); } output = stl; } } else if (sc.input2 == Constants.LANE_LINKS) { resp.Content().ReadUnsignedByte(); resp.Content().ReadInt(); int length = resp.Content().ReadInt(); SumoLinkList links = new SumoLinkList(); for (int i = 0; i < length; i++) { resp.Content().ReadUnsignedByte(); string notInternalLane = resp.Content().ReadStringASCII(); resp.Content().ReadUnsignedByte(); string internalLane = resp.Content().ReadStringASCII(); resp.Content().ReadUnsignedByte(); byte hasPriority = (byte)resp.Content().ReadUnsignedByte(); resp.Content().ReadUnsignedByte(); byte isOpened = (byte)resp.Content().ReadUnsignedByte(); resp.Content().ReadUnsignedByte(); byte hasFoes = (byte)resp.Content().ReadUnsignedByte(); resp.Content().ReadUnsignedByte(); string state = resp.Content().ReadStringASCII(); resp.Content().ReadUnsignedByte(); string direction = resp.Content().ReadStringASCII(); resp.Content().ReadUnsignedByte(); double laneLength = resp.Content().ReadDouble(); links.Add(new SumoLink(notInternalLane, internalLane, hasPriority, isOpened, hasFoes, laneLength, state, direction)); } output = links; } else { int laenge = resp.Content().ReadInt(); obj = new Object[laenge]; for (int i = 0; i < laenge; i++) { int k = resp.Content().ReadUnsignedByte(); obj[i] = this.Get_value(k, resp); } output = obj; } } else if (sc.output_type == Constants.TYPE_POLYGON) { int laenge = resp.Content().ReadUnsignedByte(); SumoGeometry sg = new SumoGeometry(); for (int i = 0; i < laenge; i++) { double x = (Double)this.Get_value(Constants.TYPE_DOUBLE, resp); double y = (Double)this.Get_value(Constants.TYPE_DOUBLE, resp); sg.Add(new SumoPosition2D(x, y)); } output = sg; } else if (sc.output_type == Constants.TYPE_COLOR) { int r = resp.Content().ReadUnsignedByte(); int g = resp.Content().ReadUnsignedByte(); int b = resp.Content().ReadUnsignedByte(); int a = resp.Content().ReadUnsignedByte(); output = new SumoColor(r, g, b, a); } else if (sc.output_type == Constants.TYPE_UBYTE) { output = resp.Content().ReadUnsignedByte(); } return(output); } }
public static SumoCommand add(String polyID, SumoGeometry shape, SumoColor color, bool fill, String polyType, int layer) { Object[] arrayOfObject = { shape, color, Convert.ToBoolean(fill), polyType, Convert.ToInt32(layer) }; return(new SumoCommand(Convert.ToInt32(200), Convert.ToInt32(128), polyID, arrayOfObject)); }