static void Instance_RemoveTargetsFilter(System.Collections.Generic.List<WoWObject> units) { for (int i = units.Count - 1; i >= 0; i--) { WoWUnit unit = units[i].ToUnit(); if (unit == null || !unit.IsValid || unit.IsFriendly ) { units.RemoveAt(i); continue; } } }
private void FilterUnknownFrames(System.Collections.Generic.List<ThreadContext> stackFrames) { bool lastWasQuestion = false; for (int i = 0; i < stackFrames.Count;) { // replace sequences of "??" with one UnknownCode frame if (stackFrames[i].Function == null || stackFrames[i].Function.Equals("??", StringComparison.Ordinal)) { if (lastWasQuestion) { stackFrames.RemoveAt(i); continue; } lastWasQuestion = true; stackFrames[i] = new ThreadContext(stackFrames[i].pc, stackFrames[i].TextPosition, ResourceStrings.UnknownCode, stackFrames[i].Level, null); } else { lastWasQuestion = false; } i++; } }
/* public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool updatenow) { UpdateCurrentSettings(bs, false, MainV2.comPort); } */ public void UpdateCurrentSettings(System.Windows.Forms.BindingSource bs, bool updatenow, MAVLinkInterface mavinterface) { lock (this) { if (DateTime.Now > lastupdate.AddMilliseconds(50) || updatenow) // 20 hz { lastupdate = DateTime.Now; //check if valid mavinterface if (mavinterface != null && mavinterface.packetsnotlost != 0) linkqualitygcs = (ushort)((mavinterface.packetsnotlost / (mavinterface.packetsnotlost + mavinterface.packetslost)) * 100.0); if (DateTime.Now.Second != lastsecondcounter.Second) { lastsecondcounter = DateTime.Now; if (lastpos.Lat != 0 && lastpos.Lng != 0 && armed) { if (!MainV2.comPort.BaseStream.IsOpen && !MainV2.comPort.logreadmode) distTraveled = 0; distTraveled += (float)lastpos.GetDistance(new PointLatLngAlt(lat, lng, 0, "")) * multiplierdist; lastpos = new PointLatLngAlt(lat, lng, 0, ""); } else { lastpos = new PointLatLngAlt(lat, lng, 0, ""); } // throttle is up, or groundspeed is > 3 m/s if (ch3percent > 12 || _groundspeed > 3.0) timeInAir++; if (!gotwind) dowindcalc(); } if (mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.STATUSTEXT] != null) // status text { var msg = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.STATUSTEXT].ByteArrayToStructure<MAVLink.mavlink_statustext_t>(6); /* enum gcs_severity { SEVERITY_LOW=1, SEVERITY_MEDIUM, SEVERITY_HIGH, SEVERITY_CRITICAL }; */ byte sev = msg.severity; string logdata = Encoding.ASCII.GetString(mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.STATUSTEXT], 6, mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.STATUSTEXT].Length - 6); int ind = logdata.IndexOf('\0'); if (ind != -1) logdata = logdata.Substring(0, ind); if (sev >= 3) { messageHigh = logdata; messageHighTime = DateTime.Now; } try { while (messages.Count > 50) { messages.RemoveAt(0); } messages.Add(logdata + "\n"); } catch { } mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.STATUSTEXT] = null; } byte[] bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RC_CHANNELS_SCALED]; if (bytearray != null) // hil mavlink 0.9 { var hil = bytearray.ByteArrayToStructure<MAVLink.mavlink_rc_channels_scaled_t>(6); hilch1 = hil.chan1_scaled; hilch2 = hil.chan2_scaled; hilch3 = hil.chan3_scaled; hilch4 = hil.chan4_scaled; hilch5 = hil.chan5_scaled; hilch6 = hil.chan6_scaled; hilch7 = hil.chan7_scaled; hilch8 = hil.chan8_scaled; // Console.WriteLine("RC_CHANNELS_SCALED Packet"); mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RC_CHANNELS_SCALED] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.FENCE_STATUS]; if (bytearray != null) { var fence = bytearray.ByteArrayToStructure<MAVLink.mavlink_fence_status_t>(6); if (fence.breach_status != (byte)MAVLink.FENCE_BREACH.NONE) { // fence breached messageHigh = "Fence Breach"; messageHighTime = DateTime.Now; } mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.FENCE_STATUS] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.HIL_CONTROLS]; if (bytearray != null) // hil mavlink 0.9 and 1.0 { var hil = bytearray.ByteArrayToStructure<MAVLink.mavlink_hil_controls_t>(6); hilch1 = (int)(hil.roll_ailerons * 10000); hilch2 = (int)(hil.pitch_elevator * 10000); hilch3 = (int)(hil.throttle * 10000); hilch4 = (int)(hil.yaw_rudder * 10000); //MAVLink.packets[(byte)MAVLink.MSG_NAMES.HIL_CONTROLS] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SYSTEM_TIME]; if (bytearray != null) { var systime = bytearray.ByteArrayToStructure<MAVLink.mavlink_system_time_t>(6); DateTime newtime = DateTime.Now; //UInt64 ms_per_week = 7000ULL*86400ULL; //UInt64 unix_offset = 17000ULL*86400ULL + 52*10*7000ULL*86400ULL - 15000ULL; //UInt64 fix_time_ms = unix_offset + time_week*ms_per_week + time_week_ms; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.HWSTATUS]; if (bytearray != null) { var hwstatus = bytearray.ByteArrayToStructure<MAVLink.mavlink_hwstatus_t>(6); hwvoltage = hwstatus.Vcc / 1000.0f; i2cerrors = hwstatus.I2Cerr; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.HWSTATUS] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RANGEFINDER]; if (bytearray != null) { var sonar = bytearray.ByteArrayToStructure<MAVLink.mavlink_rangefinder_t>(6); sonarrange = sonar.distance; sonarvoltage = sonar.voltage; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.WIND]; if (bytearray != null) { var wind = bytearray.ByteArrayToStructure<MAVLink.mavlink_wind_t>(6); gotwind = true; wind_dir = (wind.direction + 360) % 360; wind_vel = wind.speed * multiplierspeed; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.HEARTBEAT]; if (bytearray != null) { var hb = bytearray.ByteArrayToStructure<MAVLink.mavlink_heartbeat_t>(6); if (hb.type == (byte)MAVLink.MAV_TYPE.GCS) { // skip gcs hb's // only happens on log playback - and shouldnt get them here } else { armed = (hb.base_mode & (byte)MAVLink.MAV_MODE_FLAG.SAFETY_ARMED) == (byte)MAVLink.MAV_MODE_FLAG.SAFETY_ARMED; // for future use bool landed = hb.system_status == (byte)MAVLink.MAV_STATE.STANDBY; failsafe = hb.system_status == (byte)MAVLink.MAV_STATE.CRITICAL; string oldmode = mode; if ((hb.base_mode & (byte)MAVLink.MAV_MODE_FLAG.CUSTOM_MODE_ENABLED) != 0) { // prevent running thsi unless we have to if (_mode != hb.custom_mode) { List<KeyValuePair<int, string>> modelist = Common.getModesList(this); bool found = false; foreach (KeyValuePair<int, string> pair in modelist) { if (pair.Key == hb.custom_mode) { mode = pair.Value.ToString(); _mode = hb.custom_mode; found = true; break; } } if (!found) { log.Warn("Mode not found bm:" + hb.base_mode + " cm:" + hb.custom_mode); _mode = hb.custom_mode; } } } if (oldmode != mode && MainV2.speechEnable && MainV2.getConfig("speechmodeenabled") == "True") { MainV2.speechEngine.SpeakAsync(Common.speechConversion(MainV2.getConfig("speechmode"))); } } } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SYS_STATUS]; if (bytearray != null) { var sysstatus = bytearray.ByteArrayToStructure<MAVLink.mavlink_sys_status_t>(6); load = (float)sysstatus.load / 10.0f; battery_voltage = (float)sysstatus.voltage_battery / 1000.0f; battery_remaining = (float)sysstatus.battery_remaining; current = (float)sysstatus.current_battery / 100.0f; packetdropremote = sysstatus.drop_rate_comm; Mavlink_Sensors sensors_enabled = new Mavlink_Sensors(sysstatus.onboard_control_sensors_enabled); Mavlink_Sensors sensors_health = new Mavlink_Sensors(sysstatus.onboard_control_sensors_health); Mavlink_Sensors sensors_present = new Mavlink_Sensors(sysstatus.onboard_control_sensors_present); if (sensors_health.gps != sensors_enabled.gps) { messageHigh = "Bad GPS Health"; messageHighTime = DateTime.Now; } else if (sensors_health.gyro != sensors_enabled.gyro) { messageHigh = "Bad Gyro Health"; messageHighTime = DateTime.Now; } else if (sensors_health.accelerometer != sensors_enabled.accelerometer) { messageHigh = "Bad Accel Health"; messageHighTime = DateTime.Now; } else if (sensors_health.compass != sensors_enabled.compass) { messageHigh = "Bad Compass Health"; messageHighTime = DateTime.Now; } else if (sensors_health.barometer != sensors_enabled.barometer) { messageHigh = "Bad Baro Health"; messageHighTime = DateTime.Now; } else if (sensors_health.optical_flow != sensors_enabled.optical_flow) { messageHigh = "Bad OptFlow Health"; messageHighTime = DateTime.Now; } else if (sensors_present.rc_receiver != sensors_enabled.rc_receiver) { messageHigh = "NO RC Receiver"; messageHighTime = DateTime.Now; } mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SYS_STATUS] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SCALED_PRESSURE]; if (bytearray != null) { var pres = bytearray.ByteArrayToStructure<MAVLink.mavlink_scaled_pressure_t>(6); press_abs = pres.press_abs; press_temp = pres.temperature; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SENSOR_OFFSETS]; if (bytearray != null) { var sensofs = bytearray.ByteArrayToStructure<MAVLink.mavlink_sensor_offsets_t>(6); mag_ofs_x = sensofs.mag_ofs_x; mag_ofs_y = sensofs.mag_ofs_y; mag_ofs_z = sensofs.mag_ofs_z; mag_declination = sensofs.mag_declination; raw_press = sensofs.raw_press; raw_temp = sensofs.raw_temp; gyro_cal_x = sensofs.gyro_cal_x; gyro_cal_y = sensofs.gyro_cal_y; gyro_cal_z = sensofs.gyro_cal_z; accel_cal_x = sensofs.accel_cal_x; accel_cal_y = sensofs.accel_cal_y; accel_cal_z = sensofs.accel_cal_z; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.ATTITUDE]; if (bytearray != null) { var att = bytearray.ByteArrayToStructure<MAVLink.mavlink_attitude_t>(6); roll = att.roll * rad2deg; pitch = att.pitch * rad2deg; yaw = att.yaw * rad2deg; // Console.WriteLine(roll + " " + pitch + " " + yaw); //MAVLink.packets[(byte)MAVLink.MSG_NAMES.ATTITUDE] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.GPS_RAW_INT]; if (bytearray != null) { var gps = bytearray.ByteArrayToStructure<MAVLink.mavlink_gps_raw_int_t>(6); if (!useLocation) { lat = gps.lat * 1.0e-7f; lng = gps.lon * 1.0e-7f; // alt = gps.alt; // using vfr as includes baro calc } altasl = gps.alt / 1000.0f; gpsstatus = gps.fix_type; // Console.WriteLine("gpsfix {0}",gpsstatus); gpshdop = (float)Math.Round((double)gps.eph / 100.0,2); satcount = gps.satellites_visible; groundspeed = gps.vel * 1.0e-2f; groundcourse = gps.cog * 1.0e-2f; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.GPS_RAW] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.GPS_STATUS]; if (bytearray != null) { var gps = bytearray.ByteArrayToStructure<MAVLink.mavlink_gps_status_t>(6); satcount = gps.satellites_visible; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RADIO]; if (bytearray != null) { var radio = bytearray.ByteArrayToStructure<MAVLink.mavlink_radio_t>(6); rssi = radio.rssi; remrssi = radio.remrssi; txbuffer = radio.txbuf; rxerrors = radio.rxerrors; noise = radio.noise; remnoise = radio.remnoise; fixedp = radio.@fixed; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RADIO_STATUS]; if (bytearray != null) { var radio = bytearray.ByteArrayToStructure<MAVLink.mavlink_radio_status_t>(6); rssi = radio.rssi; remrssi = radio.remrssi; txbuffer = radio.txbuf; rxerrors = radio.rxerrors; noise = radio.noise; remnoise = radio.remnoise; fixedp = radio.@fixed; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.GLOBAL_POSITION_INT]; if (bytearray != null) { var loc = bytearray.ByteArrayToStructure<MAVLink.mavlink_global_position_int_t>(6); // the new arhs deadreckoning may send 0 alt and 0 long. check for and undo alt = loc.relative_alt / 1000.0f; useLocation = true; if (loc.lat == 0 && loc.lon == 0) { useLocation = false; } else { lat = loc.lat / 10000000.0f; lng = loc.lon / 10000000.0f; } } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.MISSION_CURRENT]; if (bytearray != null) { var wpcur = bytearray.ByteArrayToStructure<MAVLink.mavlink_mission_current_t>(6); int oldwp = (int)wpno; wpno = wpcur.seq; if (oldwp != wpno && MainV2.speechEnable && MainV2.getConfig("speechwaypointenabled") == "True") { MainV2.speechEngine.SpeakAsync(Common.speechConversion(MainV2.getConfig("speechwaypoint"))); } //MAVLink.packets[(byte)MAVLink.MSG_NAMES.WAYPOINT_CURRENT] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.NAV_CONTROLLER_OUTPUT]; if (bytearray != null) { var nav = bytearray.ByteArrayToStructure<MAVLink.mavlink_nav_controller_output_t>(6); nav_roll = nav.nav_roll; nav_pitch = nav.nav_pitch; nav_bearing = nav.nav_bearing; target_bearing = nav.target_bearing; wp_dist = nav.wp_dist; alt_error = nav.alt_error; aspd_error = nav.aspd_error / 100.0f; xtrack_error = nav.xtrack_error; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.NAV_CONTROLLER_OUTPUT] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RC_CHANNELS_RAW]; if (bytearray != null) { var rcin = bytearray.ByteArrayToStructure<MAVLink.mavlink_rc_channels_raw_t>(6); ch1in = rcin.chan1_raw; ch2in = rcin.chan2_raw; ch3in = rcin.chan3_raw; ch4in = rcin.chan4_raw; ch5in = rcin.chan5_raw; ch6in = rcin.chan6_raw; ch7in = rcin.chan7_raw; ch8in = rcin.chan8_raw; //percent rxrssi = (float)((rcin.rssi / 255.0) * 100.0); //MAVLink.packets[(byte)MAVLink.MSG_NAMES.RC_CHANNELS_RAW] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SERVO_OUTPUT_RAW]; if (bytearray != null) { var servoout = bytearray.ByteArrayToStructure<MAVLink.mavlink_servo_output_raw_t>(6); ch1out = servoout.servo1_raw; ch2out = servoout.servo2_raw; ch3out = servoout.servo3_raw; ch4out = servoout.servo4_raw; ch5out = servoout.servo5_raw; ch6out = servoout.servo6_raw; ch7out = servoout.servo7_raw; ch8out = servoout.servo8_raw; mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SERVO_OUTPUT_RAW] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.RAW_IMU]; if (bytearray != null) { var imu = bytearray.ByteArrayToStructure<MAVLink.mavlink_raw_imu_t>(6); gx = imu.xgyro; gy = imu.ygyro; gz = imu.zgyro; ax = imu.xacc; ay = imu.yacc; az = imu.zacc; mx = imu.xmag; my = imu.ymag; mz = imu.zmag; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.RAW_IMU] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.SCALED_IMU]; if (bytearray != null) { var imu = bytearray.ByteArrayToStructure<MAVLink.mavlink_scaled_imu_t>(6); gx = imu.xgyro; gy = imu.ygyro; gz = imu.zgyro; ax = imu.xacc; ay = imu.yacc; az = imu.zacc; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.RAW_IMU] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.VFR_HUD]; if (bytearray != null) { var vfr = bytearray.ByteArrayToStructure<MAVLink.mavlink_vfr_hud_t>(6); //groundspeed = vfr.groundspeed; airspeed = vfr.airspeed; //alt = vfr.alt; // this might include baro ch3percent = vfr.throttle; //Console.WriteLine(alt); //climbrate = vfr.climb; //MAVLink.packets[(byte)MAVLink.MSG_NAMES.VFR_HUD] = null; } bytearray = mavinterface.MAV.packets[(byte)MAVLink.MAVLINK_MSG_ID.MEMINFO]; if (bytearray != null) { var mem = bytearray.ByteArrayToStructure<MAVLink.mavlink_meminfo_t>(6); freemem = mem.freemem; brklevel = mem.brkval; } } //Console.Write(DateTime.Now.Millisecond + " start "); // update form try { if (bs != null) { if (bs.Count > 200) { while (bs.Count > 3) bs.RemoveAt(1); //bs.Clear(); } bs.Add(this); return; bs.DataSource = this; bs.ResetBindings(false); return; hires.Stopwatch sw = new hires.Stopwatch(); sw.Start(); bs.DataSource = this; bs.ResetBindings(false); sw.Stop(); var elaps = sw.Elapsed; Console.WriteLine("1 " + elaps.ToString("0.#####") + " done "); sw.Start(); bs.SuspendBinding(); bs.Clear(); bs.ResumeBinding(); bs.Add(this); sw.Stop(); elaps = sw.Elapsed; Console.WriteLine("2 " + elaps.ToString("0.#####") + " done "); sw.Start(); if (bs.Count > 100) bs.Clear(); bs.Add(this); sw.Stop(); elaps = sw.Elapsed; Console.WriteLine("3 " + elaps.ToString("0.#####") + " done "); } } catch { log.InfoFormat("CurrentState Binding error"); } } }
private int MathParserLogic(System.Collections.Generic.List<string> _tokens) { // CALCULATING THE EXPRESSIONS INSIDE THE BRACKETS // IF NEEDED, EXECUTE A FUNCTION while (_tokens.IndexOf("(") != -1) { // getting data between "(", ")" int open = _tokens.LastIndexOf("("); int close = _tokens.IndexOf(")", open); // in case open is -1, i.e. no "(" // , open == 0 ? 0 : open - 1 if (open >= close) { // if there is no closing bracket, throw a new exception throw new ArithmeticException("No closing bracket/parenthesis! tkn: " + open); } var roughExpr = new System.Collections.Generic.List<string>(); for (int i = open + 1; i < close; i++) { roughExpr.Add(_tokens[i]); } int result; // the temporary result is stored here string functioName = _tokens[open == 0 ? 0 : open - 1]; var _args = new int[0]; if (this.LocalFunctions.Keys.Contains(functioName)) { if (roughExpr.Contains(",")) { // converting all arguments into a int array for (int i = 0; i < roughExpr.Count; i++) { int firstCommaOrEndOfExpression = roughExpr.IndexOf(",", i) != -1 ? roughExpr.IndexOf(",", i) : roughExpr.Count; var defaultExpr = new System.Collections.Generic.List<string>(); while (i < firstCommaOrEndOfExpression) { defaultExpr.Add(roughExpr[i]); i++; } // changing the size of the array of arguments Array.Resize(ref _args, _args.Length + 1); if (defaultExpr.Count == 0) { _args[_args.Length - 1] = 0; } else { _args[_args.Length - 1] = this.BasicArithmeticalExpression(defaultExpr); } } // finnaly, passing the arguments to the given function result = int.Parse( this.LocalFunctions[functioName](_args).ToString(this.CULTURE_INFO), this.CULTURE_INFO); } else { // but if we only have one argument, then we pass it directly to the function result = int.Parse( this.LocalFunctions[functioName](new[] { this.BasicArithmeticalExpression(roughExpr) }) .ToString(this.CULTURE_INFO), this.CULTURE_INFO); } } else { // if no function is need to execute following expression, pass it // to the "BasicArithmeticalExpression" method. result = this.BasicArithmeticalExpression(roughExpr); } // when all the calculations have been done // we replace the "opening bracket with the result" // and removing the rest. _tokens[open] = result.ToString(this.CULTURE_INFO); _tokens.RemoveRange(open + 1, close - open); if (this.LocalFunctions.Keys.Contains(functioName)) { // if we also executed a function, removing // the function name as well. _tokens.RemoveAt(open - 1); } } // at this point, we should have replaced all brackets // with the appropriate values, so we can simply // calculate the expression. it's not so complex // any more! return this.BasicArithmeticalExpression(_tokens); }
/* * Release connections acquired by following referrals * * @param list the list of the connections */ /* package */ internal virtual void releaseReferralConnections(System.Collections.ArrayList list) { if (list == null) { return ; } // Release referral connections for (int i = list.Count - 1; i >= 0; i--) { LdapConnection rconn = null; try { rconn=(LdapConnection)list[i]; list.RemoveAt(i); // rconn = (LdapConnection) list.RemoveAt(i); rconn.Disconnect(); } catch (System.IndexOutOfRangeException ex) { continue; } catch (LdapException lex) { continue; } } return ; }
private void EliminarRegistrosConDuracionMenorAUmbral(System.Collections.Generic.List<ReportElement> lista) { System.Collections.Generic.List<int> IDsARemover = new List<int>(); for (int i = 0; i < lista.Count; i++) { ReportElement rpt = lista[i]; int Umbral = int.MaxValue; switch (rpt.EstadoInterno) { case ReportElement.EstadosPosibles.Carga: Umbral = UmbralCarga; break; case ReportElement.EstadosPosibles.Detenido: Umbral = UmbralDetenido; break; case ReportElement.EstadosPosibles.Transito: Umbral = UmbralTransito; break; default: break; } if (rpt.Duracion.Value < Umbral) { IDsARemover.Add(i); if (i > 0) lista[i - 1].Finalizar(rpt.DIA_HORA_Final); } } for (int i = IDsARemover.Count - 1; i >= 0; i--) { lista.RemoveAt(IDsARemover[i]); } }
public void LoadFromIntList(System.Collections.Generic.List<int> list, bool[] arrayOfTypes) { if (list[0] != -1) //if solid node { type = list[0]; exists = arrayOfTypes[type]; list.RemoveAt(0); } else { list.RemoveAt(0); nodes = new VoxelOctNode[8]; for (int n=0;n<8;n++) { nodes[n] = new VoxelOctNode(); nodes[n].LoadFromIntList(list, arrayOfTypes); } } }
private static void deepToString(System.Object[] a, System.Text.StringBuilder buf, System.Collections.IList seen) { seen.Add(a); buf.Append('['); for (int i = 0; i < a.Length; i++) { if (i > 0) buf.Append(", "); System.Object e = a[i]; if (e == null) { buf.Append("null"); } else if (!e.GetType().IsArray) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" buf.Append(e.ToString()); } else if (e is System.Object[]) { if (seen.Contains(e)) buf.Append("[...]"); else deepToString((System.Object[])e, buf, seen); } else { // primitive arr buf.Append((e is sbyte[]) ? toString((sbyte[])e) : ((e is short[]) ? toString((short[])e) : ((e is int[]) ? toString((int[])e) : ((e is long[]) ? toString((long[])e) : ((e is char[]) ? toString((char[])e) : ((e is bool[]) ? toString((bool[])e) : ((e is float[]) ? toString((float[])e) : ((e is double[]) ? toString((double[])e) : "")))))))); } } buf.Append(']'); seen.RemoveAt(seen.Count - 1); }
/// <summary> Parse a branch /// /// </summary> /// <param name="v"> Description of Parameter /// </param> /// <param name="buffer"> Description of Parameter /// </param> /// <param name="container"> Description of Parameter /// </param> /// <param name="parent"> Description of Parameter /// </param> /// <param name="chiral"> Description of Parameter /// </param> /// <param name="doubleBondConfiguration"> Description of Parameter /// </param> /// <param name="atomsInOrderOfSmiles"> Description of Parameter /// </param> private void parseChain(System.Collections.ArrayList v, System.Text.StringBuilder buffer, IAtomContainer container, IAtom parent, bool chiral, bool[] doubleBondConfiguration, System.Collections.ArrayList atomsInOrderOfSmiles) { int positionInVector = 0; IAtom atom; //System.out.println("in parse chain. Size of tree: " + v.size()); for (int h = 0; h < v.Count; h++) { System.Object o = v[h]; if (o is IAtom) { atom = (IAtom)o; if (parent != null) { parseBond(buffer, atom, parent, container); } else { if (chiral && BondTools.isStereo(container, atom)) { parent = (IAtom)((System.Collections.ArrayList)v[1])[0]; } } parseAtom(atom, buffer, container, chiral, doubleBondConfiguration, parent, atomsInOrderOfSmiles, v); //System.out.println("in parseChain after parseAtom()"); /* * The principle of making chiral smiles is quite simple, although the code is * pretty uggly. The Atoms connected to the chiral center are put in sorted[] in the * order they have to appear in the smiles. Then the Vector v is rearranged according * to sorted[] */ if (chiral && BondTools.isStereo(container, atom) && container.getBond(parent, atom) != null) { //System.out.println("in parseChain in isChiral"); IAtom[] sorted = null; System.Collections.IList chiralNeighbours = container.getConnectedAtomsVector(atom); if (BondTools.isTetrahedral(container, atom, false) > 0) { sorted = new IAtom[3]; } if (BondTools.isTetrahedral(container, atom, false) == 1) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { bool normalBindingIsLeft = false; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { if (BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom)) { normalBindingIsLeft = true; break; } } } } for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (normalBindingIsLeft) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } else { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[2] = (IAtom)chiralNeighbours[i]; } } } } } } if (BondTools.isTetrahedral(container, atom, false) == 2) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[0] = atom2; sorted[2] = atom1; } else { sorted[0] = atom1; sorted[2] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 3) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = ohere.Length - 1; i > -1; i--) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[1] = atom2; sorted[2] = atom1; } else { sorted[1] = atom1; sorted[2] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 4) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = ohere.Length - 1; i > -1; i--) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[1] = atom2; sorted[0] = atom1; } else { sorted[1] = atom1; sorted[0] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 5) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } } if (BondTools.isTetrahedral(container, atom, false) == 6) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } } if (BondTools.isSquarePlanar(container, atom)) { sorted = new IAtom[3]; //This produces a U=SP1 order in every case //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (BondTools.isTrigonalBipyramidalOrOctahedral(container, atom) != 0) { sorted = new IAtom[container.getConnectedAtoms(atom).Length - 1]; //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[sorted.Length - 1] = (IAtom)chiralNeighbours[i]; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[sorted.Length - 1] = (IAtom)chiralNeighbours[i]; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)(BondTools.giveAngleFromMiddle(atom, parent, ((IAtom)chiralNeighbours[i])))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[sorted.Length - 2] = (IAtom)chiralNeighbours[i]; } } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); sorted[sorted.Length - 1] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 1])]); if (ohere.Length == 2) { sorted[sorted.Length - 3] = ((IAtom)chiralNeighbours[((System.Int32)ohere[0])]); if (BondTools.giveAngleFromMiddle(atom, parent, ((IAtom)chiralNeighbours[((System.Int32)ohere[1])])) < 0) { IAtom dummy = sorted[sorted.Length - 2]; sorted[sorted.Length - 2] = sorted[0]; sorted[0] = dummy; } } if (ohere.Length == 3) { sorted[sorted.Length - 3] = sorted[sorted.Length - 2]; sorted[sorted.Length - 2] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 2])]); sorted[sorted.Length - 4] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 3])]); } } } //This builds an onew[] containing the objects after the center of the chirality in the order given by sorted[] if (sorted != null) { int numberOfAtoms = 3; if (BondTools.isTrigonalBipyramidalOrOctahedral(container, atom) != 0) { numberOfAtoms = container.getConnectedAtoms(atom).Length - 1; } System.Object[] omy = new System.Object[numberOfAtoms]; System.Object[] onew = new System.Object[numberOfAtoms]; for (int k = getRingOpenings(atom, null).Count; k < numberOfAtoms; k++) { if (positionInVector + 1 + k - getRingOpenings(atom, null).Count < v.Count) { omy[k] = v[positionInVector + 1 + k - getRingOpenings(atom, null).Count]; } } for (int k = 0; k < sorted.Length; k++) { if (sorted[k] != null) { for (int m = 0; m < omy.Length; m++) { if (omy[m] is IAtom) { if (omy[m] == sorted[k]) { onew[k] = omy[m]; } } else { if (omy[m] == null) { onew[k] = null; } else { if (((System.Collections.ArrayList)omy[m])[0] == sorted[k]) { onew[k] = omy[m]; } } } } } else { onew[k] = null; } } //This is a workaround for 3624.MOL.2 I don't have a better solution currently bool doubleentry = false; for (int m = 0; m < onew.Length; m++) { for (int k = 0; k < onew.Length; k++) { if (m != k && onew[k] == onew[m]) { doubleentry = true; } } } if (!doubleentry) { //Make sure that the first atom in onew is the first one in the original smiles order. This is important to have a canonical smiles. if (positionInVector + 1 < v.Count) { System.Object atomAfterCenterInOriginalSmiles = v[positionInVector + 1]; int l = 0; while (onew[0] != atomAfterCenterInOriginalSmiles) { System.Object placeholder = onew[onew.Length - 1]; for (int k = onew.Length - 2; k > -1; k--) { onew[k + 1] = onew[k]; } onew[0] = placeholder; l++; if (l > onew.Length) { break; } } } //This cares about ring openings. Here the ring closure (represendted by a figure) must be the first atom. In onew the closure is null. if (getRingOpenings(atom, null).Count > 0) { int l = 0; while (onew[0] != null) { System.Object placeholder = onew[0]; for (int k = 1; k < onew.Length; k++) { onew[k - 1] = onew[k]; } onew[onew.Length - 1] = placeholder; l++; if (l > onew.Length) { break; } } } //The last in onew is a vector: This means we need to exchange the rest of the original smiles with the rest of this vector. if (onew[numberOfAtoms - 1] is System.Collections.ArrayList) { for (int i = 0; i < numberOfAtoms; i++) { if (onew[i] is IAtom) { System.Collections.ArrayList vtemp = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); vtemp.Add(onew[i]); for (int k = positionInVector + 1 + numberOfAtoms; k < v.Count; k++) { vtemp.Add(v[k]); } onew[i] = vtemp; for (int k = v.Count - 1; k > positionInVector + 1 + numberOfAtoms - 1; k--) { v.RemoveAt(k); } for (int k = 1; k < ((System.Collections.ArrayList)onew[numberOfAtoms - 1]).Count; k++) { v.Add(((System.Collections.ArrayList)onew[numberOfAtoms - 1])[k]); } onew[numberOfAtoms - 1] = ((System.Collections.ArrayList)onew[numberOfAtoms - 1])[0]; break; } } } //Put the onew objects in the original Vector int k2 = 0; for (int m = 0; m < onew.Length; m++) { if (onew[m] != null) { v[positionInVector + 1 + k2] = onew[m]; k2++; } } } } } parent = atom; } else { //Have Vector //System.out.println("in parseChain after else"); bool brackets = true; System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); addAtoms((System.Collections.ArrayList)o, result); if (isRingOpening(parent, result) && container.getBondCount(parent) < 4) { brackets = false; } if (brackets) { buffer.Append('('); } parseChain((System.Collections.ArrayList)o, buffer, container, parent, chiral, doubleBondConfiguration, atomsInOrderOfSmiles); if (brackets) { buffer.Append(')'); } } positionInVector++; //System.out.println("in parseChain after positionVector++"); } }
// use selection sort to return a sort list of the pull forces // sorted from smallest to largest System.Collections.Generic.List<PullForce> sortForces(System.Collections.Generic.List<PullForce> a) { //remove any null entries for(int k = 0; k< a.Count; k++) { if(a[k].force == new Vector3(float.MaxValue, float.MaxValue, float.MaxValue)) { a.RemoveAt(k); k--; } } //sort list int i,j; int iMin; for (j = 0; j < a.Count - 1; j++) { iMin = j; for ( i = j+1; i < a.Count; i++) { if (a[i].dist < a[iMin].dist) { iMin = i; } } if ( iMin != j ) { PullForce temp = a[j]; a[j] = a[iMin]; a[iMin] = temp; } } return a; }
private void MapSubclasses(System.Collections.ArrayList subclasses, System.Collections.Specialized.StringCollection extendedClassesNames, System.Collections.ArrayList mappedClassesNames, System.Xml.XmlTextWriter writer) { System.Collections.ArrayList mappedSubclassesNames = new System.Collections.ArrayList(); // Map each subclass after the class it extends while(subclasses.Count > 0) for(int i=subclasses.Count-1; i>=0; i--) { System.Type type = subclasses[i] as System.Type; string extendedClassName = extendedClassesNames[i]; if(extendedClassName==null) throw new MappingException("You must specify the Extends attribute of the Subclass: " + type.FullName); if( ! mappedClassesNames.Contains(extendedClassName) && ! mappedSubclassesNames.Contains(extendedClassName) ) { bool extendedClassFoundButNotMappedYet = false; // Make sure that the extended class is mapped (in this assembly) foreach(System.Type subclass in subclasses) { if( HbmWriterHelper.GetNameWithAssembly(subclass) == extendedClassName ) { if(subclass==type) throw new MappingException("The Subclass " + type.FullName + " extends itself."); else { extendedClassFoundButNotMappedYet = true; break; } } } if (extendedClassFoundButNotMappedYet) continue; // Map this one later // Else unknown extended class: // Assume it is mapped somewhere else and map this subclass } if( IsSubclass(type, typeof(SubclassAttribute)) ) HbmWriter.WriteSubclass(writer, type); else if( IsSubclass(type, typeof(JoinedSubclassAttribute)) ) HbmWriter.WriteJoinedSubclass(writer, type); else if( IsSubclass(type, typeof(UnionSubclassAttribute)) ) HbmWriter.WriteUnionSubclass(writer, type); // Note: Do not add to mappedClassesNames because it is for x-subclasses (and a x-subclasses shouldn't extend another x-subclasses) mappedSubclassesNames.Add(HbmWriterHelper.GetNameWithAssembly(type)); subclasses.RemoveAt(i); extendedClassesNames.RemoveAt(i); } }
/// <summary> /// /// </summary> /// <param name="curve"></param> /// <param name="barType"></param> /// <param name="barStyle"></param> /// <param name="host"></param> /// <param name="startHook"></param> /// <param name="endHook"></param> /// <param name="startHookOrientation"></param> /// <param name="endHookOrientation"></param> /// <param name="normal"></param> /// <param name="useExistingShape"></param> /// <param name="createNewShape"></param> private void InitRebarContainer(System.Collections.Generic.List<object> curves, Autodesk.Revit.DB.Structure.RebarBarType barType, Autodesk.Revit.DB.Structure.RebarStyle barStyle, Autodesk.Revit.DB.Element host, Autodesk.Revit.DB.Structure.RebarHookType startHook, Autodesk.Revit.DB.Structure.RebarHookType endHook, Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation, Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation, System.Collections.Generic.List<Autodesk.Revit.DB.XYZ> normals, bool useExistingShape, bool createNewShape) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); var rebarElem = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.Structure.RebarContainer>(document); // Parse Geometry List<List<Curve>> curvature = new List<List<Curve>>(); foreach (object curve in curves) { List<Curve> geometry = new List<Curve>(); if (curve.GetType() == typeof(DynamoRebar.RevitPolyCurve)) { DynamoRebar.RevitPolyCurve polycurve = (DynamoRebar.RevitPolyCurve)curve; geometry = polycurve.Curves; } else geometry.Add((Curve)curve); curvature.Add(geometry); } if (rebarElem == null) { ElementId stdC = Autodesk.Revit.DB.Structure.RebarContainerType.CreateDefaultRebarContainerType(DocumentManager.Instance.CurrentDBDocument); rebarElem = Autodesk.Revit.DB.Structure.RebarContainer.Create(DocumentManager.Instance.CurrentDBDocument, host, stdC); } else { //rebarElem.ClearItems(); rebarElem.SetHostId(document, host.Id); } int counter = rebarElem.ItemsCount; for (int i = 0; i < counter; i++) { Autodesk.Revit.DB.Structure.RebarContainerItem item = rebarElem.GetItem(i); int index = GeometryMatches(item.ComputeDrivingCurves(), curvature); if (index == -1) rebarElem.RemoveItem(item); else { item.SetHookOrientation(0, startHookOrientation); item.SetHookOrientation(1, endHookOrientation); item.SetHookTypeId(0, startHook.Id); item.SetHookTypeId(1, endHook.Id); curvature.RemoveAt(index); if (normals.Count > 1) normals.RemoveAt(index); } } for (int i = 0; i < curvature.Count; i++) { // If there is only one normal in the list use this one for all curves XYZ normal = (normals.Count == 1) ? normals[0] : normals[i]; List<Curve> geometry = curvature[i]; rebarElem.AppendItemFromCurves(barStyle, barType, startHook, endHook, normal, geometry, startHookOrientation, endHookOrientation, useExistingShape, createNewShape); } // Update Quantity Parameter Autodesk.Revit.DB.Parameter quantityParameter = rebarElem.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS); Autodesk.Revit.DB.Structure.RebarContainerParameterManager containerParameters = rebarElem.GetParametersManager(); containerParameters.AddOverride(quantityParameter.Id, curves.Count); InternalSetRebarContainer(rebarElem); TransactionManager.Instance.TransactionTaskDone(); if (rebarElem != null) { ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement); } else { ElementBinder.SetElementForTrace(this.InternalElement); } }
private void DeleteObjects(System.Collections.ArrayList objectNames, bool doingFiles) { // Indices of successfully deleted objects (so we can remove their names in reverse order) System.Collections.ArrayList deletedIndices = new System.Collections.ArrayList(objectNames.Count); int index = 0; foreach (string objectName in objectNames) { bool exists = (doingFiles ? File.Exists(objectName) : Directory.Exists(objectName)); if (!exists) { // It's already gone: remove its name deletedIndices.Insert(0, index); } else { try { if (doingFiles) { ForceDeleteFile(objectName); } else { // Delete the files in the directory DirectoryInfo dirInfo = new DirectoryInfo(objectName); foreach (FileInfo file in dirInfo.GetFiles()) { ForceDeleteFile(file.FullName); } Directory.Delete(objectName); } deletedIndices.Insert(0, index); } catch { } } ++index; } foreach (int i in deletedIndices) { objectNames.RemoveAt(i); } }
public void TrySCIList(System.Collections.IList list) { // Should be called with a C5.IList<B> which is not a WrappedArray Assert.AreEqual(0, list.Count); list.CopyTo(new A[0], 0); list.CopyTo(new B[0], 0); list.CopyTo(new C[0], 0); Assert.IsTrue(!list.IsFixedSize); Assert.IsFalse(list.IsReadOnly); Assert.IsFalse(list.IsSynchronized); Assert.AreNotEqual(null, list.SyncRoot); Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C(); Assert.AreEqual(0, list.Add(b1)); Assert.AreEqual(1, list.Add(c1)); Assert.AreEqual(2, list.Count); Assert.IsTrue(list.Contains(c1)); Assert.IsFalse(list.Contains(b2)); list[0] = b2; Assert.AreEqual(b2, list[0]); list[1] = c2; Assert.AreEqual(c2, list[1]); Assert.IsTrue(list.Contains(b2)); Assert.IsTrue(list.Contains(c2)); Array arrA = new A[2], arrB = new B[2]; list.CopyTo(arrA, 0); list.CopyTo(arrB, 0); Assert.AreEqual(b2, arrA.GetValue(0)); Assert.AreEqual(b2, arrB.GetValue(0)); Assert.AreEqual(c2, arrA.GetValue(1)); Assert.AreEqual(c2, arrB.GetValue(1)); Assert.AreEqual(0, list.IndexOf(b2)); Assert.AreEqual(-1, list.IndexOf(b1)); list.Remove(b1); list.Remove(b2); Assert.IsFalse(list.Contains(b2)); Assert.AreEqual(1, list.Count); // Contains c2 only list.Insert(0, b2); list.Insert(2, b1); Assert.AreEqual(b2, list[0]); Assert.AreEqual(c2, list[1]); Assert.AreEqual(b1, list[2]); list.Remove(c2); Assert.AreEqual(b2, list[0]); Assert.AreEqual(b1, list[1]); list.RemoveAt(1); Assert.AreEqual(b2, list[0]); list.Clear(); Assert.AreEqual(0, list.Count); list.Remove(b1); }
/// <summary> /// Removes the element at the top of the stack and returns it. /// </summary> /// <param name="stack">The stack where the element at the top will be returned and removed.</param> /// <returns>The element at the top of the stack.</returns> public static System.Object Pop(System.Collections.ArrayList stack) { System.Object obj = stack[stack.Count - 1]; stack.RemoveAt(stack.Count - 1); return obj; }
public void IListRemoveAtWorks() { IList<string> l = new[] { "x", "y", "z" }; l.RemoveAt(1); Assert.AreEqual(l, new[] { "x", "z" }); }
private static void findPathBetween(IAtomContainer atomContainer, IAtom start, IAtom end, System.Collections.IList path) { if (start == end) { path.Add(start); allPaths.Add(new System.Collections.ArrayList(path)); path.RemoveAt(path.Count - 1); return; } if (path.Contains(start)) return; path.Add(start); System.Collections.IList nbrs = atomContainer.getConnectedAtomsVector(start); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" for (System.Collections.IEnumerator i = nbrs.GetEnumerator(); i.MoveNext(); ) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" findPathBetween(atomContainer, (IAtom)i.Current, end, path); } path.RemoveAt(path.Count - 1); }