static void Main(string[] args) { // Read the count of the commands that will follow. int commandCount = int.Parse(Console.ReadLine()); // Get the start position of the robot. Vector2 startPosition = Vector2.PositionFromString(Console.ReadLine()); // Create the robot and the tracker. Robot robot = new Robot(startPosition); PositionTracker tracker = new PositionTracker(robot); // Loop until we have read all commands. for (int i = 0; i < commandCount; i++) { // Read the line and create a movement vector. var line = Console.ReadLine(); Vector2 movement = Vector2.MoveDirectionFromString(line); // Move the robot. robot.Move(movement); } // Calculate and display the unique positions visited by the robot. Console.WriteLine($"=> Cleaned: {tracker.CalculatePositionsVisited()}"); }
public void TestPositionTrackerCreation() { Robot robot = new Robot(new Vector2(10, 10)); PositionTracker tracker = new PositionTracker(robot); Assert.AreEqual(1, tracker.CalculatePositionsVisited()); }
public void TestRetraceSteps() { Robot robot = new Robot(new Vector2(-10, -10)); PositionTracker tracker = new PositionTracker(robot); robot.Move(new Vector2(10, 0)); robot.Move(new Vector2(-11, 0)); Assert.AreEqual(12, tracker.CalculatePositionsVisited()); }
public Form1() { this.Show(); this.Location = Screen.AllScreens[0].WorkingArea.Location; InitializeComponent(); positionTracker = new PositionTracker(); positionTracker.Init(); starteStreetFighter(); startJavaServer(); }
public void TestPositionTrackerCalculationNegativeStart() { Robot robot = new Robot(new Vector2(-10, -10)); PositionTracker tracker = new PositionTracker(robot); robot.Move(new Vector2(2, 0)); robot.Move(new Vector2(0, 2)); robot.Move(new Vector2(-2, 0)); robot.Move(new Vector2(0, -2)); Assert.AreEqual(8, tracker.CalculatePositionsVisited()); }
/// <summary> /// Initializes a new instance of the <see cref="BrokerAccount"/> class. /// </summary> /// <param name="accountid">The accountid.</param> /// <param name="cashmanager">The cashmanager.</param> /// <param name="securitytracker">The securitytracker.</param> /// <param name="accountcurrency">The accountcurrency.</param> /// <param name="leverage">The leverage.</param> /// <param name="displaycurrency">The display currency.</param> public BrokerAccount( string accountid, CashManager cashmanager, SecurityTracker securitytracker, CurrencyType accountcurrency, CurrencyType displaycurrency, int leverage) { Cash = cashmanager; Securities = securitytracker; Positions = new PositionTracker(this); Currency = accountcurrency; Leverage = leverage; Id = accountid; DisplayCurrency = displaycurrency; }
public void When() { // given var tagger = new TransactionFilePositionTagger(0); var positionTracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromPosition(0, 100, 50); positionTracker.UpdateByCheckpointTagInitial(newTag); _tag = positionTracker.LastTag; _tagger = new TransactionFilePositionTagger(0); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }
public void When() { // given var tagger = new PreparePositionTagger(); var positionTracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromPreparePosition(50); positionTracker.UpdateByCheckpointTagInitial(newTag); _tag = positionTracker.LastTag; _tagger = new PreparePositionTagger(); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }
public void When() { // given var tagger = new StreamPositionTagger(0, "stream1"); var tracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromStreamPosition(0, "stream1", 1); tracker.UpdateByCheckpointTagInitial(newTag); _tag = tracker.LastTag; _tagger = new StreamPositionTagger(0, "stream1"); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }
/// <summary> /// flat a symbol and flag it to allow prevention of future trading with status and supplied reason /// </summary> /// <param name="sym"></param> /// <param name="activesym"></param> /// <param name="_pt"></param> /// <param name="sendorder"></param> /// <param name="D"></param> /// <param name="reason"></param> public static void shutdown(string sym, GenericTracker <bool> activesym, PositionTracker _pt, OrderDelegate sendorder, DebugDelegate D, string reason) { if (!activesym[sym]) { return; } Order o = new MarketOrderFlat(_pt[sym]); if (D != null) { string r = reason == string.Empty ? string.Empty : " (" + reason + ")"; D("symbol shutdown" + r + ", flat order: " + o.ToString()); } sendorder(o); activesym[sym] = false; }
public void ClosedPL() { const string sym = "RYN"; PositionTracker pt = new PositionTracker(); Position p = new PositionImpl(sym, 44.39m, 800, 0); pt.Adjust(p); System.IO.StreamReader sr = new System.IO.StreamReader("TestPositionClosedPL.txt"); string[] file = sr.ReadToEnd().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string line in file) { Trade t = TradeImpl.FromString(line); pt.Adjust(t); } Assert.AreEqual(-66, pt[sym].ClosedPL); }
public void When() { // given var tracker = new PositionTracker(new StreamPositionTagger("stream1")); tracker.Update( new ProjectionMessage.Projections.CommittedEventReceived( Guid.NewGuid(), new EventPosition(100, 50), "stream1", 1, false, new Event(Guid.NewGuid(), "eventtype", false, new byte[0], new byte[0]))); _tag = tracker.LastTag; _tagger = new StreamPositionTagger("stream1"); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTag(_tag); }
/// <summary> /// Initialize this agent, should be runned only once when booting up the agent /// </summary> public virtual void Initialize() { LocalLog(LogLevel.Debug, "Initializing agent with id {0}, symbol {1} and timeframe {2}", AgentId, Symbol, TimeFrame); //Check for previous initialization if (_initialized) { LocalLog(LogLevel.Warn, "Failed to initialize agent with id {0}, already initialized", AgentId); return; } //Set standard indicators IndicatorManagement = new IndicatorManager(this); StandardIndicators = new Indicators.StandardIndicators(IndicatorManagement); //Subscribe for new data entries foreach (var stream in Portfolio.Streams.Values) { stream.GotNewBar += Stream_GotNewBar; } //Associate agent _templates.ForEach(x => x.Agent = this); //init all templates _templates.ForEach(x => x.Initialize()); //Set all events _templates.ForEach(AddEvent); //Set current decisions CurrentState = new Dictionary <string, List <AgentState> >(); foreach (var stream in Portfolio.Streams) { CurrentState.Add(stream.Key, new List <AgentState>()); } //Set empty objects CurrentBar = new Dictionary <string, Bar>(); CurrentTick = new Dictionary <string, Tick>(); Bars = new Data.Bars.BarIndexerImpl(_portfolio); _results = new Results(0, Portfolio.Account, AgentId); Positions = new PositionTracker(_portfolio.Account); //Set current initialization point _initialized = true; LocalLog(LogLevel.Debug, "Initializing agent with id {0}, symbol {1} and timeframe {2}. Succeeded!", AgentId, Symbol, TimeFrame); }
public void ClosedPL() { const string sym = "RYN"; ForexSecurity ts = new ForexSecurity(sym); IAccount acc = new SimAccount("TST"); acc.Securities.AddSecurity(ts); PositionTracker pt = new PositionTracker(acc); Position p = new PositionImpl(ts, 44.39m, 800, 0, acc); pt.Adjust(p); Position p2 = new PositionImpl(ts, 44.39m, -800, 0, acc); pt.Adjust(p2); Assert.Equal(0, pt[sym].GrossPnL); }
public void When() { // given _tagger = new MultiStreamPositionTagger(0, new[] { "stream1", "stream2" }); _positionTracker = new PositionTracker(_tagger); var newTag = CheckpointTag.FromStreamPositions(0, new Dictionary <string, long> { { "stream1", 1 }, { "stream2", 2 } }); var newTag2 = CheckpointTag.FromStreamPositions(0, new Dictionary <string, long> { { "stream1", 1 }, { "stream2", 3 } }); _positionTracker.UpdateByCheckpointTagInitial(newTag); _positionTracker.UpdateByCheckpointTagForward(newTag2); }
public void When() { // given _tagger = new EventByTypeIndexPositionTagger(0, new[] { "type1", "type2" }); _positionTracker = new PositionTracker(_tagger); var newTag = CheckpointTag.FromEventTypeIndexPositions(0, new TFPos(10, 5), new Dictionary <string, long> { { "type1", 1 }, { "type2", 2 } }); var newTag2 = CheckpointTag.FromEventTypeIndexPositions(0, new TFPos(20, 15), new Dictionary <string, long> { { "type1", 1 }, { "type2", 3 } }); _positionTracker.UpdateByCheckpointTagInitial(newTag); _positionTracker.UpdateByCheckpointTagForward(newTag2); }
public void When() { // given var tagger = new MultiStreamPositionTagger(0, new [] { "stream1", "stream2" }); var tracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromStreamPositions(0, new Dictionary <string, long> { { "stream1", 1 }, { "stream2", 2 } }); tracker.UpdateByCheckpointTagInitial(newTag); _tag = tracker.LastTag; _tagger = new MultiStreamPositionTagger(0, new [] { "stream1", "stream2" }); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }
public void When() { // given var tagger = new EventByTypeIndexPositionTagger(0, new[] { "type1", "type2" }); var tracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromEventTypeIndexPositions(0, new TFPos(10, 5), new Dictionary <string, int> { { "type1", 1 }, { "type2", 2 } }); tracker.UpdateByCheckpointTagInitial(newTag); _tag = tracker.LastTag; _tagger = new EventByTypeIndexPositionTagger(0, new[] { "type1", "type2" }); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }
public ThrustManager(IMU440 nav, Microcontroller u, PositionTracker p, log loger) { //Purpose: Constructor for thrustManager //Inputs: the IMU object, and the microcontroller object, which each have the serial communication functions within. lg = loger; navigation = nav; position = p; uCon = u; desiredPitch = 0; desiredRoll = 0; desiredDepth = -0.5; desiredYaw = 0; desiredSurge = 0; desiredSway = 0; Tp = 0; //pitch Tr = 0; //roll Ty = 0; //yaw Td = 0; //depth Tsu = 0; //surge Tsw = 0; //sway uCon.sensorRequest(); //gots to tune these pids ptch = new PID(0, 0, 0, 60.0, -60.0, 40, -40, getActualPitch, getDesiredPitch, computeTp); rll = new PID(.5, 0, .4, 60.0, -60.0, 40, -40, getActualRoll, getDesiredRoll, computeTr); surge = new PID(0.6, 0, 0, 3, -3, 75, -75, getActualSurge, getDesiredSurge, computeTsu); sway = new PID(0.6, 0, 0, 3, -3, 75, -75, getActualSway, getDesiredSway, computeTsw); depth = new PID(0.8, 0.1, .8, 0, -9, 75, -75, getActualDepth, getDesiredDepth, computeTd); yaw = new PID(0, 0, 0, 180, -180, 40, -40, getActualYaw, getDesiredYaw, computeTy); ptch.Enable(); rll.Enable(); //commented cause we dont have everything worked out for yaw, and i haven't written something to calculate velocity surge.Enable(); sway.Enable(); depth.Enable(); yaw.Enable(); backgroundThrustManager = new Thread(new ThreadStart(levelingTask)); backgroundThrustManager.IsBackground = true; backgroundThrustManager.Start(); }
/* * // these variables "hold" the parameters set by the user above * // also they are the defaults that show up first * int _barsback = 2; * BarInterval _barinterval = BarInterval.FiveMin; * int _entrysize = 100; * decimal _totalprofit = 200; * int _shutdowntime = 155000; */ void initialize() { // wait for fill _wait = new GenericTracker <bool>(); // track whether shutdown _active = new GenericTracker <bool>(); // hold last ma _sma = new GenericTracker <decimal>(); // turn on bar tracking blt = new BarListTracker(Interval); blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); // turn on position tracking pt = new PositionTracker(); // keep track of time for use in other functions time = 0; _active.NewTxt += new TextIdxDelegate(_active_NewTxt); }
public OrderAndPositionViewModel() { _eventaggregator = ServiceLocator.Current.GetInstance<EventAggregator>(); _logger = ServiceLocator.Current.GetInstance<ILoggerFacade>(); _configmanager = ServiceLocator.Current.GetInstance<IConfigManager>() as ConfigManager; _ordertracker = new OrderTracker(_configmanager.DailyOrderCapacity); _ordertracker.SendDebugEvent += OnDebug; _positiontracker = new PositionTracker(_configmanager.DailyOrderCapacity); _eventaggregator.GetEvent<InitialPositionEvent>().Subscribe(ClientGotInitialPosition); //_eventaggregator.GetEvent<SendOrderEvent>().Subscribe(ClientGotOrder); _eventaggregator.GetEvent<OrderConfirmationEvent>().Subscribe(ClientGotOrder); _eventaggregator.GetEvent<OrderCancelConfirmationEvent>().Subscribe(ClientGotOrderCancelConfirmation); _eventaggregator.GetEvent<OrderFillEvent>().Subscribe(ClientGotOrderFilled); _eventaggregator.GetEvent<GenerateReportEvent>().Subscribe(GeneratePerformanceReport); _resultstable.Columns.Add("Statistics"); _resultstable.Columns.Add("Result"); }
public OrderAndPositionViewModel() { _eventaggregator = ServiceLocator.Current.GetInstance <EventAggregator>(); _logger = ServiceLocator.Current.GetInstance <ILoggerFacade>(); _configmanager = ServiceLocator.Current.GetInstance <IConfigManager>() as ConfigManager; _ordertracker = new OrderTracker(_configmanager.DailyOrderCapacity); _ordertracker.SendDebugEvent += OnDebug; _positiontracker = new PositionTracker(_configmanager.DailyOrderCapacity); _eventaggregator.GetEvent <InitialPositionEvent>().Subscribe(ClientGotInitialPosition); //_eventaggregator.GetEvent<SendOrderEvent>().Subscribe(ClientGotOrder); _eventaggregator.GetEvent <OrderConfirmationEvent>().Subscribe(ClientGotOrder); _eventaggregator.GetEvent <OrderCancelConfirmationEvent>().Subscribe(ClientGotOrderCancelConfirmation); _eventaggregator.GetEvent <OrderFillEvent>().Subscribe(ClientGotOrderFilled); _eventaggregator.GetEvent <GenerateReportEvent>().Subscribe(GeneratePerformanceReport); _resultstable.Columns.Add("Statistics"); _resultstable.Columns.Add("Result"); }
public void BlankPositionReq() { string sym = "IBM"; ForexSecurity ts = new ForexSecurity(sym); IAccount account = new SimAccount("TEST"); account.Securities.AddSecurity(ts); PositionTracker pt = new PositionTracker(account); bool except = false; int s = 100; try { s = pt[sym].Size; } catch { except = true; } Assert.Equal(0, s); Assert.False(except); }
public void TestTradeFill() { ptt = new PapertradeTracker(); ptt.SendDebugEvent += new DebugDelegate(debug); ptt.UseBidAskFills = false; fills = 0; pt = new PositionTracker(); const string SYM = "TST"; ptt.GotFillEvent += new FillDelegate(ptt_GotFillEvent); ptt.GotOrderEvent += new OrderDelegate(ptt_GotOrderEvent); // send an order ptt.sendorder(new BuyMarket(SYM, 1000)); // verify it did not fill Assert.AreEqual(0, pt[SYM].Size); // send a tick ptt.newTick(TickImpl.NewTrade(SYM, 10, 100)); // verify it fills Assert.AreEqual(100, pt[SYM].Size); }
public void InitAndAdjust() { const string sym = "IBM"; // startup position tracker PositionTracker pt = new PositionTracker(); PositionTracker pt2 = new PositionTracker(); // give pt our initial position Position init = new PositionImpl(sym, 0, 0); pt.Adjust(init); pt2.Adjust(init); // fill a trade in both places Trade fill = new TradeImpl(sym, 100, 100); pt.Adjust(fill); pt2.Adjust(fill); // make sure it's only 100 in both places Assert.AreEqual(100, pt[sym].Size); Assert.AreEqual(100, pt2[sym].Size); }
public void Adjust() { const string s = "IBM"; TradeImpl t1 = new TradeImpl(s, 100, 100); PositionTracker pt = new PositionTracker(); // make we have no position yet Assert.IsTrue(pt[t1.symbol].isFlat); // send some adjustments decimal cpl = 0; cpl += pt.Adjust(t1); cpl += pt.Adjust(t1); // verify that adjustments took hold Assert.AreEqual(0, cpl); Assert.AreEqual(200, pt[t1.symbol].Size); }
/// <summary> /// Initializes a new instance of the <see cref="QuantFund"/> class. /// </summary> /// <param name="portfolio">The portfolio.</param> /// <param name="benchmark">The benchmark.</param> /// <param name="fundid"></param> /// <param name="allocatedcapital">The allocatedcapital.</param> /// <param name="isForceTick"></param> /// <param name="name"></param> public QuantFund(IPortfolio portfolio, Benchmark benchmark, string fundid, decimal allocatedcapital, bool isForceTick, string name) { //Set references Portfolio = portfolio; Benchmark = benchmark; FundId = fundid; IsForceTick = isForceTick; Name = name; //Set objects StartedDTUtc = DateTime.MinValue; Positions = new PositionTracker(portfolio.BrokerAccount, FundId, benchmark, allocatedcapital); Results = new Result(allocatedcapital, benchmark); //Initial state State = FundState.Stopped; BackFillingPeriod = TimeSpan.Zero; MaxOrdersPerDay = Config.GlobalConfig.MaxOrdersPerDay; //Initialize and allocate funds to this quant fund portfolio.CashManager.AddQuantFund(this, portfolio.BrokerAccount.Currency, allocatedcapital); }
/// <summary> /// Converts a list of trades to an array of delimited string data also containing closedPL, /// suitable for output to file for reading by excel, R, matlab, etc. /// </summary> /// <param name="tradelist"></param> /// <param name="delimiter"></param> /// <returns></returns> public static string[] TradesToClosedPL(List <Trade> tradelist, char delimiter) { List <string> rowoutput = new List <string>(); PositionTracker pt = new PositionTracker(null); foreach (TradeImpl t in tradelist) { string r = t.ToString(delimiter, false) + delimiter; string s = t.Symbol; int csize = 0; var cpl = pt.Adjust(t); var opl = Calc.OpenPL(t.Xprice, pt[s]); if (cpl != 0) { csize = t.Xsize; // if we closed any pl, get the size } string[] pl = { opl.ToString("0.00#####", CultureInfo.InvariantCulture), cpl.ToString("0.00#####", CultureInfo.InvariantCulture), pt[s].Size.ToString(CultureInfo.InvariantCulture), csize.ToString(CultureInfo.InvariantCulture), pt[s].AvgPrice.ToString("0.00#####", CultureInfo.InvariantCulture) }; r += string.Join(delimiter.ToString(), pl); rowoutput.Add(r); } return(rowoutput.ToArray()); }
public override void Reset(bool popup = true) { _positiontracker = new PositionTracker(_symbols.Count); _barlisttracker = new BarListTracker(_symbols.ToArray(), new int[] { _higherbarinterval, _lowerbarinterval }); _barlisttracker.GotNewBar += _barlisttracker_GotNewBar; _ordertracker = new OrderTracker(10000); // in the none zone _isOBOSZone = Enumerable.Repeat <OBOSZone>(OBOSZone.None, _symbols.Count).ToArray(); // neither bull or bear _isHigherTimeFrameBullBear = Enumerable.Repeat <BullBearTrend>(BullBearTrend.None, _symbols.Count).ToArray(); // all are active _issymbolactive = Enumerable.Repeat <bool>(true, _symbols.Count).ToArray(); // none are filled _waittobefilled = Enumerable.Repeat <bool>(false, _symbols.Count).ToArray(); _currentorderids = Enumerable.Repeat <long>(0L, _symbols.Count).ToArray(); _entrylevel = Enumerable.Repeat <decimal>(0m, _symbols.Count).ToArray(); _exitlevel = Enumerable.Repeat <decimal>(0m, _symbols.Count).ToArray(); _transactions = 0; _currenttime = 0; }
public void FillBidAskPartial() { PapertradeTracker ptt = new PapertradeTracker(); PositionTracker pt = new PositionTracker(); ptt.UseBidAskFills = true; ptt.GotFillEvent += new FillDelegate(pt.GotFill); foreach (bool side in new bool[] { true, false }) { pt.Clear(); Order o = new MarketOrder("IBM", side, 1000); int size = o.size; o.id = 1; ptt.sendorder(o); Tick k = TickImpl.NewQuote("IBM", 100, 101, 400, 400, "", ""); ptt.newTick(k); // partial fill ptt.newTick(k); // partial fill ptt.newTick(k); // partial fill, completed Expect(pt["IBM"].Size, Is.EqualTo(size)); } }
protected override void OnDeath() { PositionTracker.StopTracking(this); _collider.OnDamageTaken -= ApplyDamage; _collider.OnItemsCollected -= AddCollectedItems; _hands.OnPowerGained -= FillSegment; _hands.OnPowerLost -= EmptySegment; var spawnedItem = ItemLoader.CreateItem(Items.ItemActors.ItemActorTypes.HealthPack, Position); var chunk = GameManager.World.ChunkArchitect.GetContainingChunk(Position); chunk.Register(spawnedItem); if (_regenerationCoroutine != null) { StopCoroutine(_regenerationCoroutine); _regenerationCoroutine = null; } Destroy(_collider); }
public override void Reset(bool popup = true) { _positiontracker = new PositionTracker(_symbols.Count); _barlisttracker = new BarListTracker(_symbols.ToArray(), new int[] { _higherbarinterval, _lowerbarinterval }); _barlisttracker.GotNewBar += _barlisttracker_GotNewBar; _ordertracker = new OrderTracker(10000); // in the none zone _isOBOSZone = Enumerable.Repeat<OBOSZone>(OBOSZone.None, _symbols.Count).ToArray(); // neither bull or bear _isHigherTimeFrameBullBear = Enumerable.Repeat<BullBearTrend>(BullBearTrend.None, _symbols.Count).ToArray(); // all are active _issymbolactive = Enumerable.Repeat<bool>(true, _symbols.Count).ToArray(); // none are filled _waittobefilled = Enumerable.Repeat<bool>(false, _symbols.Count).ToArray(); _currentorderids = Enumerable.Repeat<long>(0L, _symbols.Count).ToArray(); _entrylevel = Enumerable.Repeat<decimal>(0m, _symbols.Count).ToArray(); _exitlevel = Enumerable.Repeat<decimal>(0m, _symbols.Count).ToArray(); _transactions = 0; _currenttime = 0; }
public void when() { _tagger = new EventByTypeIndexPositionTagger(0, new[] { "type1", "type2" }); _positionTracker = new PositionTracker(_tagger); }
public void when() { _tagger = new PreparePositionTagger(); _positionTracker = new PositionTracker(_tagger); }
public void when() { _tagger = new MultiStreamPositionTagger(0, new [] { "stream1", "stream2" }); _positionTracker = new PositionTracker(_tagger); }
public void when() { _tagger = new TransactionFilePositionTagger(0); _positionTracker = new PositionTracker(_tagger); }
/// <summary> /// This is called after StrategySetter updates _symbol list /// </summary> /// <param name="popup"></param> public override void Reset(bool popup = true) { _positiontracker = new PositionTracker(_symbols.Count); _barlisttracker = new BarListTracker(_symbols.ToArray(), _barinterval); _barlisttracker.GotNewBar += _barlisttracker_GotNewBar; // all are active _issymbolactive = Enumerable.Repeat<bool>(true, _symbols.Count).ToArray(); // none are filled _waittobefilled = Enumerable.Repeat<bool>(false, _symbols.Count).ToArray(); _transactions = 0; }
public OffsetTracker(IdTracker tracker, int capacity) { _ids = tracker; _pt = new PositionTracker(capacity); }
public static void LayoutComponent(CyPhy.Component c) { PositionTracker pt = new PositionTracker(); Dictionary<string, bool> d_IsPositioned = new Dictionary<string, bool>(); foreach (CyPhy.Connector conn in c.Children.ConnectorCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(conn); SetCoordinates(conn, s_Coord); d_IsPositioned[conn.ID] = true; } foreach (CyPhy.Port p in c.Children.PortCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(p); SetCoordinates(p, s_Coord); d_IsPositioned[p.ID] = true; } foreach (CyPhy.Parameter p in c.Children.ParameterCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(p); SetCoordinates(p, s_Coord); d_IsPositioned[p.ID] = true; } foreach (CyPhy.Property p in c.Children.PropertyCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(p); SetCoordinates(p, s_Coord); d_IsPositioned[p.ID] = true; } foreach (CyPhy.CustomFormula cf in c.Children.CustomFormulaCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(cf); SetCoordinates(cf, s_Coord); d_IsPositioned[cf.ID] = true; } foreach (CyPhy.Resource r in c.Children.ResourceCollection) { String s_Coord = pt.GetCoordinatesAndIncrement(r); SetCoordinates(r, s_Coord); d_IsPositioned[r.ID] = true; } pt.NextLine(); pt.Increment(null); foreach (ISIS.GME.Common.Interfaces.FCO fco in c.AllChildren.Where(fco => fco is CyPhy.ModelicaModel || fco is CyPhy.CADModel || fco is CyPhy.ManufacturingModel)) { Boolean b; d_IsPositioned.TryGetValue(fco.ID, out b); if (!b) { String s_Coord = pt.GetCoordinatesAndIncrement(fco); SetCoordinates(fco, s_Coord); d_IsPositioned[fco.ID] = true; } pt.Increment(null); pt.Increment(null); } foreach (ISIS.GME.Common.Interfaces.FCO fco in c.AllChildren.Where(fco => fco is ISIS.GME.Common.Interfaces.Atom || fco is ISIS.GME.Common.Interfaces.Model || fco is ISIS.GME.Common.Interfaces.Reference || fco is ISIS.GME.Common.Interfaces.Set)) { Boolean b; d_IsPositioned.TryGetValue(fco.ID,out b); if ( !b ) { String s_Coord = pt.GetCoordinatesAndIncrement(fco); SetCoordinates(fco, s_Coord); d_IsPositioned[fco.ID] = true; } } /*foreach (KeyValuePair<String, ArrayList> kvp in d_ClassPrioritiesByAspect) { String s_CurrentAspect = kvp.Key; foreach (var t in kvp.Value) { } }*/ }
public static void LayoutChildrenByName(ISIS.GME.Common.Interfaces.Model parent) { PositionTracker pt = new PositionTracker(); foreach (ISIS.GME.Common.Interfaces.FCO child in parent.AllChildren.OrderBy(child => child.Name)) { String s_Coord = pt.GetCoordinatesAndIncrement(child); SetCoordinates(child, s_Coord); } }
/// <summary> /// creates trail tracker (with it's own position tracker) /// </summary> //public TrailTracker() : this(new PositionTracker(), new IdTracker()) { } /// <summary> /// creates a trail tracker from an existing position tracker component /// </summary> /// <param name="pt"></param> public TrailTracker(PositionTracker pt, IdTracker id) { _pt = pt; _id = id; }
public void when() { _tagger = new StreamPositionTagger(0, "stream1"); _positionTracker = new PositionTracker(_tagger); }
/// <summary> /// Compare two PositionTracker structures /// </summary> /// <param name="operand1">Left operand</param> /// <param name="operand2">Right operand</param> /// <returns>true if operands are equal</returns> public static bool Compare(PositionTracker operand1, PositionTracker operand2) { return operand1.myColumn == operand2.myColumn && operand1.myStartRow == operand2.myStartRow && operand1.myEndRow == operand2.myEndRow && operand1.myUserData == operand2.myUserData; }