public static List<Split> GetSplitsForRunnerRaceRecord(long runnerRaceRecordId) { using (var db = new CCEntities()) { var rrrs = db.RunnerRaceRecordSegments.Where(r => r.RunnerRaceRecordId == runnerRaceRecordId) .OrderBy(rrs => rrs.ElapsedTimeInSeconds).ToArray(); var splits = new List<Split>(); for (int i = 0; i < rrrs.Length; i++) { var split = new Split { RunnerRaceRecordSegmentId = rrrs[i].RunnerRaceRecordSegmentId, ElapsedTimeInSeconds = rrrs[i].ElapsedTimeInSeconds, }; if (i == 0) split.IntervalFromPriorSplit = rrrs[i].ElapsedTimeInSeconds; else split.IntervalFromPriorSplit = rrrs[i].ElapsedTimeInSeconds - rrrs[i - 1].ElapsedTimeInSeconds; splits.Add(split); } return splits; } }
internal void SetSplit(Split split) { if (this.tLock != null) { this.tLock.Dispose(); this.tLock = null; this.split = null; this.otherSplit = null; this.transaction = null; this.originalTransaction = null; } if (split != null) { Debug.Assert( split.Transaction.Splits.Count == 2 && split.Transaction.Splits.All(s => s.Security == split.Transaction.BaseSecurity), "The transaction is too complex for the simple transaction editor."); this.originalTransaction = split.Transaction; this.transaction = split.Transaction.Copy(); this.split = this.transaction.Splits[this.originalTransaction.Splits.IndexOf(split)]; this.otherSplit = this.transaction.Splits.Where(s => s != this.split).Single(); this.tLock = this.transaction.Lock(); } ResetControls(); }
/// <summary> /// Adds the columns within a split. /// </summary> /// <param name="split"></param> /// <param name="trNode"></param> private void AddColumnList(Split split, TreeNode trNode) { for (int i = 0; i < split.Columns.Count; i++) { trNode.Nodes.Add(GetSplitColumnTextRepresentation(split.Columns[i])); } }
public DetailedView(Split useSplits, WSplit callingForm) { base.Paint += new PaintEventHandler(this.dviewPaint); base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); this.InitializeComponent(); this.parent = callingForm; this.menuItemShowSegs.Checked = Settings.Profile.DViewShowSegs; this.menuItemMarkSegments.Checked = Settings.Profile.DViewDeltaMarks; this.menuItemAlwaysOnTop.Checked = Settings.Profile.DViewOnTop; base.TopMost = Settings.Profile.DViewOnTop; this.updateColumns(); this.clockFont = this.displayTime.Font; }
public RunEditorDialog(Split splits) { this.xmlReader = new LiveSplitXMLReader(); this.InitializeComponent(); this.cellHeight = this.runView.RowTemplate.Height; this.windowHeight = (base.Height - (this.runView.Height - this.cellHeight)) - 2; this.MaximumSize = new Size(500, (15 * this.cellHeight) + this.windowHeight); foreach (Segment segment in splits.segments) this.editList.Add(segment); this.populateList(this.editList); this.runView.EditingControlShowing += this.runView_EditingControlShowing; }
public Compile_files(Crawl_directory_tree crawlDirTree) { var split = new Split<Tuple<string, string>, string, string>( t => t.Item2, t => t.Item1 ); var validatePath = new Validate<string>( Directory.Exists, path => string.Format("Diretory to be indexed not found: {0}", path) ); this.in_Process = _ => split.Input(_); split.Output1 += validatePath.In_Validate; validatePath.Out_ValidData += crawlDirTree.In_Process; validatePath.Out_InvalidData += _ => this.Out_ValidationError(_); split.Output0 += _ => this.Out_IndexFilename(_); crawlDirTree.Out_FileFound += _ => this.Out_FileFound(_); }
/// <summary> /// Add in approval steps to either the order or split, depending on what is provided /// </summary> /// <param name="order">The order</param> /// <param name="approvalInfo">list of approval people (or null) to route to</param> /// <param name="split">optional split to approve against instead of the order</param> /// <param name="minLevel">Min level only adds approvals at or above the provided level</param> private void AddApprovalSteps(Order order, ApprovalInfo approvalInfo, Split split, int minLevel = 0) { var approvals = new List<Approval> { new Approval { Completed = AutoApprovable(order, split, approvalInfo.Approver), //If this is auto approvable just include it but mark it as approval already User = approvalInfo.Approver, StatusCode = _repositoryFactory.OrderStatusCodeRepository.GetById(OrderStatusCode.Codes.Approver) }, new Approval { Completed = false, User = approvalInfo.AcctManager, StatusCode = _repositoryFactory.OrderStatusCodeRepository.GetById(OrderStatusCode.Codes.AccountManager), IsExternal = approvalInfo.IsExternal }, new Approval { Completed = false, User = approvalInfo.Purchaser, StatusCode = _repositoryFactory.OrderStatusCodeRepository.GetById(OrderStatusCode.Codes.Purchaser) } }; if (minLevel > 0) { approvals = approvals.Where(x => x.StatusCode.Level >= minLevel).ToList(); } foreach (var approval in approvals) { if (approval.StatusCode.Id == OrderStatusCode.Codes.Purchaser) { //Make sure to only add one purchaser approval if (order.Approvals.Any(x => x.StatusCode.Id == OrderStatusCode.Codes.Purchaser)) continue; } if (approval.StatusCode.Id == OrderStatusCode.Codes.Approver && approvalInfo.IsExternal) { continue; //Do not add approvals at the AP level for external accounts } split.AssociateApproval(approval); if (approval.Completed) { //already approved means auto approval, so send that specific event _eventService.OrderAutoApprovalAdded(order, approval); } else { _eventService.OrderApprovalAdded(order, approval); } } }
private void AddPageStartingDimension(Page page, Split split, double panelWidth, double splitWidth, double locationX) { DimensionItem item; if (split == Split.Start) { item = Util.eplan.AddDimension( page, null, splitWidth - 1000, locationX - 420, _origin.Y - _dimOffset[0], locationX, _origin.Y - _dimOffset[0], 20); if (item == null) { return; } item.ExtensionLineFirst = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = ""; item = Util.eplan.AddDimension( page, null, splitWidth, locationX - 210, _origin.Y - _dimOffset[1], locationX, _origin.Y - _dimOffset[1], 20); item.ExtensionLineFirst = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = ""; } else if (split == Split.End) { //API.Common.AddDimension( // page, // null, // splitWidth - 1000, // locationX - 420, // _origin.Y - _dimOffset1, // locationX + panelWidth - 500, // _origin.Y - _dimOffset1, // 20); //API.Common.AddDimension( // page, // null, // splitWidth, // locationX - 210, // _origin.Y - _dimOffset2, // locationX + panelWidth, // _origin.Y - _dimOffset2, // 20); } else { //API.Common.AddDimension( // page, // null, // splitWidth - 1000, // dimensionX1 + 500, // _origin.Y - _dimOffset1, // locationX + 420, // _origin.Y - _dimOffset1, // 20); //API.Common.AddDimension( // page, // null, // splitWidth, // dimensionX1, // _origin.Y - _dimOffset2, // locationX, // _origin.Y - _dimOffset2, // 20); //API.Common.AddDimension( // page, // null, // _TotalWidth, // _origin.X, // _origin.Y - _dimOffset3, // locationX, // _origin.Y - _dimOffset3, // 20); } }
public LiveSplitXMLReader() { this.split = new Split(); xmlDocument = new XmlDocument(); }
public override void AbcSampleUpdated(AbcAPI.aiSample sample, bool topologyChanged) { AlembicMaterial abcMaterials = m_trans.GetComponent <AlembicMaterial>(); if (abcMaterials != null) { if (abcMaterials.HasFacesetsChanged()) { AbcVerboseLog("AlembicMesh.AbcSampleUpdated: Facesets updated, force topology update"); topologyChanged = true; } hasFacesets = (abcMaterials.GetFacesetsCount() > 0); } else if (hasFacesets) { AbcVerboseLog("AlembicMesh.AbcSampleUpdated: Facesets cleared, force topology update"); topologyChanged = true; hasFacesets = false; } if (m_freshSetup) { topologyChanged = true; m_freshSetup = false; } AbcAPI.aiPolyMeshGetSampleSummary(sample, ref m_sampleSummary, topologyChanged); AbcAPI.aiPolyMeshData vertexData = default(AbcAPI.aiPolyMeshData); UpdateSplits(m_sampleSummary.splitCount); for (int s = 0; s < m_sampleSummary.splitCount; ++s) { Split split = m_splits[s]; split.clear = topologyChanged; split.active = true; int vertexCount = AbcAPI.aiPolyMeshGetVertexBufferLength(sample, s); Array.Resize(ref split.positionCache, vertexCount); vertexData.positions = GetArrayPtr(split.positionCache); if (m_sampleSummary.hasNormals) { Array.Resize(ref split.normalCache, vertexCount); vertexData.normals = GetArrayPtr(split.normalCache); } else { Array.Resize(ref split.normalCache, 0); vertexData.normals = IntPtr.Zero; } if (m_sampleSummary.hasUVs) { Array.Resize(ref split.uvCache, vertexCount); vertexData.uvs = GetArrayPtr(split.uvCache); } else { Array.Resize(ref split.uvCache, 0); vertexData.uvs = IntPtr.Zero; } if (m_sampleSummary.hasTangents) { Array.Resize(ref split.tangentCache, vertexCount); vertexData.tangents = GetArrayPtr(split.tangentCache); } else { Array.Resize(ref split.tangentCache, 0); vertexData.tangents = IntPtr.Zero; } AbcAPI.aiPolyMeshFillVertexBuffer(sample, s, ref vertexData); split.center = vertexData.center; split.size = vertexData.size; } if (topologyChanged) { AbcAPI.aiFacesets facesets = default(AbcAPI.aiFacesets); AbcAPI.aiSubmeshSummary submeshSummary = default(AbcAPI.aiSubmeshSummary); AbcAPI.aiSubmeshData submeshData = default(AbcAPI.aiSubmeshData); if (abcMaterials != null) { abcMaterials.GetFacesets(ref facesets); } int numSubmeshes = AbcAPI.aiPolyMeshPrepareSubmeshes(sample, ref facesets); if (m_submeshes.Count > numSubmeshes) { m_submeshes.RemoveRange(numSubmeshes, m_submeshes.Count - numSubmeshes); } for (int s = 0; s < m_sampleSummary.splitCount; ++s) { m_splits[s].submeshCount = AbcAPI.aiPolyMeshGetSplitSubmeshCount(sample, s); } while (AbcAPI.aiPolyMeshGetNextSubmesh(sample, ref submeshSummary)) { if (submeshSummary.splitIndex >= m_splits.Count) { Debug.Log("Invalid split index"); continue; } Submesh submesh = null; if (submeshSummary.index < m_submeshes.Count) { submesh = m_submeshes[submeshSummary.index]; } else { submesh = new Submesh { indexCache = new int[0], facesetIndex = -1, splitIndex = -1, index = -1, update = true }; m_submeshes.Add(submesh); } submesh.facesetIndex = submeshSummary.facesetIndex; submesh.splitIndex = submeshSummary.splitIndex; submesh.index = submeshSummary.splitSubmeshIndex; submesh.update = true; Array.Resize(ref submesh.indexCache, 3 * submeshSummary.triangleCount); submeshData.indices = GetArrayPtr(submesh.indexCache); AbcAPI.aiPolyMeshFillSubmeshIndices(sample, ref submeshSummary, ref submeshData); } if (abcMaterials != null) { abcMaterials.AknowledgeFacesetsChanges(); } } else { for (int i = 0; i < m_submeshes.Count; ++i) { m_submeshes[i].update = false; } } AbcDirty(); }
void UpdateSplits(int numSplits) { Split split = null; if (m_summary.topologyVariance == AbcAPI.aiTopologyVariance.Heterogeneous || numSplits > 1) { for (int i = 0; i < numSplits; ++i) { if (i >= m_splits.Count) { split = new Split { positionCache = new Vector3[0], normalCache = new Vector3[0], uvCache = new Vector2[0], tangentCache = new Vector4[0], mesh = null, host = null, clear = true, submeshCount = 0, active = true, center = Vector3.zero, size = Vector3.zero }; m_splits.Add(split); } else { m_splits[i].active = true; } } } else { if (m_splits.Count == 0) { split = new Split { positionCache = new Vector3[0], normalCache = new Vector3[0], uvCache = new Vector2[0], tangentCache = new Vector4[0], mesh = null, host = m_trans.gameObject, clear = true, submeshCount = 0, active = true, center = Vector3.zero, size = Vector3.zero }; m_splits.Add(split); } else { m_splits[0].active = true; } } for (int i = numSplits; i < m_splits.Count; ++i) { m_splits[i].active = false; } }
public static void MessageToBytes(Split split, Stream buffer) => BasicMessageToBytes(split, OperationalMessage.SPLIT, buffer);
/// <summary> /// Applies a split to the portfolio /// </summary> /// <param name="split">The split to be applied</param> public void ApplySplit(Split split) { ApplySplitToEquities(split); ApplySplitToOptions(split); }
public override IEnumerable <string> GetCandidateItems(Split split, User u) { //return _allCandidateItems.Select(i => int.Parse(i)).Except(_userPosFeedback[int.Parse(u.Id)]).Take(_maxNumCandidates) return(_userCandidates[int.Parse(u.Id)] .Select(i => i.ToString()).Take(1000)); }
private void DoSplit(Orientation orientation, double offset) { Split?.Invoke(this, new SplitEventArgs(orientation, offset)); }
/// <summary> /// Do the move of cars from next(s) split(s) to the 's' split. /// regads to the 'carsToUp' dictionnary /// </summary> /// <param name="s">the target split we want to fill</param> /// <param name="carsToUp">Cars we need to move up. /// KEY is classId /// VALUE is number of cars /// </param> internal static void UpCarsToSplit(List <int> carClassesIds, List <Split> splits, Split s, Dictionary <int, int> carsToUp) { // for each class foreach (int classId in carsToUp.Keys) { // get missing cars count and class Id int classMissing = carsToUp[classId]; int classIndex = carClassesIds.IndexOf(classId); // --> // foreach missing car for (int i = 0; i < classMissing; i++) { // find a lower split containig the same class var nextSplitContainingSameClassCars = (from r in splits where r.Number > s.Number && r.CountClassCars(classIndex) > 0 select r).FirstOrDefault(); // doest we got one ? if (nextSplitContainingSameClassCars != null) { // pick the top car of the next split (the highest IR of it) var pick = nextSplitContainingSameClassCars.PickClassCars(classIndex, 1, false); // doest the the target split 's' already contains this class ? if (s.GetClassId(classIndex) != classIndex) { // no, we will create id s.SetClass(classIndex, classId); } // append the car in the target split 's' s.AppendClassCars(classIndex, pick); } else { // no... // we can not to the move // never mind we will fix that later // :-D } } // end of foreach missing car } // end of foreach class }
public override IEnumerable <User> GetCandidateUsers(Split split) { return(_userItemsInTest.Select(ui => ui.Item1).Distinct().Select(u => new User(u.ToString()))); }
/// <summary> /// If there is split with more cars than field Size, fix it /// </summary> /// <param name="splitsDescriptions"></param> private void SolveSplitsExceedFieldSize(List <MultiClassChanges> splitsDescriptions) { // foreach split foreach (var splitDescription in splitsDescriptions) { // while the split is in excess while (splitDescription.CountTotalTargets() > fieldSize) { // get the class with more cars var excess = (from r in splitDescription.ClassCarsTarget orderby r.Value descending select r).FirstOrDefault(); int classid = excess.Key; // find the uppest split possible containing the same class // and a free avaiable slot var splitWithSameClassAndSlotAvailable = (from r in splitsDescriptions where r.ClassCarsTarget.ContainsKey(excess.Key) && r.CountTotalTargets() < fieldSize orderby r.ClassCarsTarget[excess.Key] ascending select r).FirstOrDefault(); // yes, found it if (splitWithSameClassAndSlotAvailable != null) { // move the car to it splitWithSameClassAndSlotAvailable.ClassCarsTarget[classid]++; splitDescription.ClassCarsTarget[classid]--; } // no, not any possible else { // get the classes id, from most populated to less List <int> mostpopulatedclassed = carClassesIds.ToList(); mostpopulatedclassed.Reverse(); mostpopulatedclassed.Remove(classid); // but remove the current class // --> // we will do a pool shot in two moves // foreach most populated class bool solutionfound = false; foreach (int mostpopulatedclass in mostpopulatedclassed) { // find the split having the less cars possible, the lowest possible // containing the mostpopulatedclass // and thecontaining current class 'classid' var othersplit1 = (from r in splitsDescriptions where r.ClassCarsTarget.ContainsKey(classid) && r.ClassCarsTarget.ContainsKey(mostpopulatedclass) && r.ClassCarsTarget[mostpopulatedclass] > 0 orderby r.CountTotalTargets() ascending, r.ToSplit descending select r).FirstOrDefault(); // find split containing the mostpopulatedclass, the uppest possible // with the lowest car possible var othersplit2 = (from r in splitsDescriptions where r.ClassCarsTarget.ContainsKey(mostpopulatedclass) && r.CountTotalTargets() < fieldSize && r.ClassCarsTarget[mostpopulatedclass] > 0 orderby r.CountTotalTargets() ascending, r.ToSplit descending select r).FirstOrDefault(); // it these 2 splits are found if (othersplit1 != null && othersplit2 != null) { // in otherslit1 : change a mostpopulatedclass slot with a classid slot othersplit1.ClassCarsTarget[mostpopulatedclass]--; othersplit1.ClassCarsTarget[classid]++; // in otherslit1 : finaly add the missing car othersplit2.ClassCarsTarget[mostpopulatedclass]++; // to end solving the problem, we can now remove the car in excess to our current split splitDescription.ClassCarsTarget[classid]--; // break the 'foreach most populated class' // we don't need to try with another class // we solved the problem solutionfound = true; break; } else { // not found too... // we will try with the next mostpopulatedclass } } if (!solutionfound) { var newsplit = new MultiClassChanges() { FromSplit = Splits.Count, ToSplit = Splits.Count, ClassCarsTarget = new Dictionary <int, int>() }; for (int i = 0; i < carClassesIds.Count; i++) { // algo.TakeCars(carClassesIds[i], carClassesIds, fieldSize) //int cars = 0; //if (carClassesIds[i] == excess.Key) cars = excess.Value; newsplit.ClassCarsTarget.Add(carClassesIds[i], 0); } splitsDescriptions.Add(newsplit); SolveSplitsExceedFieldSize(splitsDescriptions); Split newSplit = new Split(Splits.Count); Splits.Add(newSplit); solutionfound = true; return; } } } } // end of foreach split }
public Season(Split split) : this(split.Stat.Assists, split.Stat.Goals, split.Stat.Games, split.Season) { }
public void Compute(List <Line> data, int fieldSize) { // Split cars per class var carsListPerClass = Tools.SplitCarsPerClass(data); // Create two dictionnary (KEY for both is the CarClass Id) // classRemainingCars : VALUE is the number of remaining cars in the class // classSplitsCount : VALUE is a list containing the number of car split per split Dictionary <int, int> classRemainingCars = new Dictionary <int, int>(); Dictionary <int, List <int> > classSplitsCount = new Dictionary <int, List <int> >(); foreach (var carClass in carsListPerClass) { classRemainingCars.Add(carClass.CarClassId, carClass.Cars.Count); classSplitsCount.Add(carClass.CarClassId, new List <int>()); } // export classes id CarClassesId = new List <int>(); foreach (var carClass in carsListPerClass) { CarClassesId.Add(carClass.CarClassId); } // MultiClassMode records describes changes on split car classes compositions // - FromSplit and ToSplit describes the range of splits // - ClassesCount describes how many car classes can be part of the splits // (exemple: 3 first for LMP1/LMP2/GTE, then 2 when it become LMP1/GTE because not enought LMP2 are available, then 1 when single class)... List <MultiClassChanges> modes = new List <MultiClassChanges>(); MultiClassChanges currentMode = new MultiClassChanges(); currentMode.FromSplit = 1; currentMode.ToSplit = 1; currentMode.ClassesCount = classRemainingCars.Count; modes.Add(currentMode); int splitCounter = 1; while (SumValues(classRemainingCars) > 0) // when cars remaings { // count classes containing remaining cars int remCarClasses = (from r in classRemainingCars where r.Value > 0 select r).Count(); foreach (var carClass in carsListPerClass) { // count cars to take in this class int takeCars = fieldSize; takeCars = TakeClassCars(fieldSize, remCarClasses, classRemainingCars, carClass.CarClassId, carsListPerClass, splitCounter); // if not enought remianing cars than wanted, take what is possible int carClassSize = Math.Min(takeCars, classRemainingCars[carClass.CarClassId]); classSplitsCount[carClass.CarClassId].Add(carClassSize); // save the number of car in the class for this split classRemainingCars[carClass.CarClassId] -= carClassSize; // decrement reminaing cars in the class } var lastClass = carsListPerClass.LastOrDefault(); //get last class, which is the class with more cars then the other if (lastClass != null) { // sum cars in this split int carsInThisSplit = 0; foreach (var carClass in carsListPerClass) { carsInThisSplit += classSplitsCount[carClass.CarClassId].Last(); } // --> // available slots ? if (carsInThisSplit < fieldSize) { int availableSlots = fieldSize - carsInThisSplit; // fill this availableSlots with last class cars to match the maximum field size.. var splitclasslist = classSplitsCount[lastClass.CarClassId]; splitclasslist[splitclasslist.Count - 1] += availableSlots; // and decremement remaining cars if this last class classRemainingCars[lastClass.CarClassId] -= availableSlots; } } // is there always the same number of car class than the previous split ? if (remCarClasses == currentMode.ClassesCount) { // yes, just update the ToSplit number currentMode.ToSplit = splitCounter; } else { // no, save a change starting from this split currentMode = new MultiClassChanges(); currentMode.FromSplit = splitCounter; currentMode.ToSplit = splitCounter; currentMode.ClassesCount = remCarClasses; modes.Add(currentMode); } splitCounter++; } // create the array of splits Splits = new List <Split>(); int maxsplit = (from r in modes select r.ToSplit).Max(); for (int i = 1; i <= maxsplit; i++) { var split = new Split(); split.Number = i; Splits.Add(split); } // reset the classRemainingCars counts classRemainingCars.Clear(); foreach (var carClass in carsListPerClass) { classRemainingCars.Add(carClass.CarClassId, carClass.Cars.Count); } // for each car class foreach (var carClass in carsListPerClass) { // for each split for (int i = 1; i <= maxsplit; i++) { var split = Splits[i - 1]; // get the split record in the array of splits // get the MultiClassMode where this split is in, the target cars count for the classes var mode = (from r in modes where i >= r.FromSplit orderby r.ToSplit descending select r).First(); int take = fieldSize / mode.ClassesCount; // save the class target cars count in this class split.SetClassTarget(carsListPerClass.IndexOf(carClass), take); // .. and decrement the remaninng cars of this class classRemainingCars[carClass.CarClassId] -= take; } } // AT THIS POINT : // on the Splits array, all Class{i}Target values are up to date with // number of cars we want // for each split, and each class. // Implement car lists foreach (var split in Splits) // foreach each split { for (int i = 0; i < 4; i++) // for each car class { int carsToAddInClass = split.GetClassTarget(i); // get the cars count we want if (carsListPerClass.Count > i) { var cars = carsListPerClass[i].PickCars(carsToAddInClass); // pick up the cars in the ordered list by iRating DESC if (cars.Count > 0) { split.SetClass(i, cars, carsListPerClass[i].CarClassId); // set the class car list } } } } // manage the rest badly, very raw method var lastSplit = new Split(); lastSplit.Number = Splits.Last().Number + 1; bool includeLastSplit = false; for (int i = 0; i < 4; i++) // for each car class { int carsToAddInClass = Splits.Last().GetClassTarget(i); // get the cars count we want if (carsListPerClass.Count > i) { var cars = carsListPerClass[i].PickCars(carsToAddInClass); // pick up the cars in the ordered list by iRating DESC if (cars.Count > 0) { lastSplit.SetClass(i, cars, carsListPerClass[i].CarClassId); // set the class car list } } if (lastSplit.TotalCarsCount > 0) { includeLastSplit = true; } } if (includeLastSplit) { Splits.Add(lastSplit); } // done // :-) }
public static Split Split(int? counter) { var rtValue = new Split(); rtValue.Order = new Order(); rtValue.Project = "Project" + counter.Extra(); //Not Required, just for tests return rtValue; }
private void GetRealtiemeData() { byte[] ScanModeData = new byte[40960]; int nLen, NumLen; string temp1 = ""; string binarystr1 = ""; string binarystr2 = ""; string RSSI = ""; string AntStr = ""; string lenstr = ""; string EPCStr = ""; int ValidDatalength; string temp; ValidDatalength = 0; DataGridViewRow rows = new DataGridViewRow(); int xtime = System.Environment.TickCount; fCmdRet = RWDev.ReadActiveModeData(ScanModeData, ref ValidDatalength, frmcomportindex); if (fCmdRet == 0) { try { byte[] daw = new byte[ValidDatalength]; Array.Copy(ScanModeData, 0, daw, 0, ValidDatalength); temp = ByteArrayToHexString(daw); fInventory_EPC_List = fInventory_EPC_List + temp;//把字符串存进列表 nLen = fInventory_EPC_List.Length; while (fInventory_EPC_List.Length > 18) { string FlagStr = Convert.ToString(fComAdr, 16).PadLeft(2, '0') + "EE00";//查找头位置标志字符串 int nindex = fInventory_EPC_List.IndexOf(FlagStr); if (nindex > 1) { fInventory_EPC_List = fInventory_EPC_List.Substring(nindex - 2); } else { fInventory_EPC_List = fInventory_EPC_List.Substring(2); continue; } NumLen = Convert.ToInt32(fInventory_EPC_List.Substring(0, 2), 16) * 2 + 2;//取第一个帧的长度 if (fInventory_EPC_List.Length < NumLen) { break; } temp1 = fInventory_EPC_List.Substring(0, NumLen); fInventory_EPC_List = fInventory_EPC_List.Substring(NumLen); if (!CheckCRC(temp1)) { continue; } AntStr = Convert.ToString(Convert.ToInt32(temp1.Substring(8, 2), 16), 2).PadLeft(4, '0'); lenstr = Convert.ToString(Convert.ToInt32(temp1.Substring(10, 2), 16), 10); EPCStr = temp1.Substring(12, temp1.Length - 18); RSSI = temp1.Substring(temp1.Length - 6, 2); var readTime = DateTime.Now; var tag = new Split { DateTimeOfDay = readTime, TimeOfDay = readTime.ToString("hh.mm.ss.ff"), Epc = EPCStr, Rssi = int.Parse(RSSI), SplitName = _readerProfile.Name, SplitDeviceId = _readerProfile.Id, InventorySearchMode = _readerProfile.InventorySearchMode, Antenna = AntStr }; if (_readerProfile.ReadingMode == ReadingMode.Desktop) { onAssignTag(tag); continue; } onRecordTag(tag); } } catch (System.Exception ex) { ex.ToString(); } } }
public override IEnumerable <string> GetRelevantItems(Split split, User user) { //return _userPosFeedback[int.Parse(user.Id)].Select(i => i.ToString()); return(_userTestFeedback[int.Parse(user.Id)].Select(i => i.ToString())); }
public void SetSplit(Split split) { _split = split; UpdateControl(); }
private void flash_G2() { Session = Convert.ToByte((int)_readerProfile.InventorySearchMode); Qvalue = Convert.ToByte(4); byte Ant = 0x80; int CardNum = 0; int Totallen = 0; int EPClen, m; byte[] EPC = new byte[50000]; int CardIndex; string temps, temp; temp = ""; string sEPC; byte MaskMem = 0; byte[] MaskAdr = new byte[2]; byte MaskLen = 0; byte[] MaskData = new byte[100]; byte MaskFlag = 0; byte AdrTID = 0; byte LenTID = 0; AdrTID = 0; LenTID = 6; MaskFlag = 0; int cbtime = System.Environment.TickCount; CardNum = 0; fCmdRet = RWDev.Inventory_G2(ref fComAdr, Qvalue, Session, MaskMem, MaskAdr, MaskLen, MaskData, MaskFlag, AdrTID, LenTID, TIDFlag, Target, InAnt, Scantime, FastFlag, EPC, ref Ant, ref Totallen, ref CardNum, frmcomportindex); int cmdTime = System.Environment.TickCount - cbtime;//命令时间 if ((fCmdRet == 0x30) || (fCmdRet == 0x37)) { if (_readerProfile.ConnectionType == ConnectionType.Ethernet) { if (frmcomportindex > 1023) { fCmdRet = RWDev.CloseNetPort(frmcomportindex); if (fCmdRet == 0) { frmcomportindex = -1; } Thread.Sleep(1000); } fComAdr = 255; string ipAddress = _readerProfile.IpAddress; int nPort = Convert.ToInt32("27011"); fCmdRet = RWDev.OpenNetPort(nPort, ipAddress, ref fComAdr, ref frmcomportindex); } } if (CardNum == 0) { if (Session > 1) { AA_times = AA_times + 1;//没有得到标签只更新状态栏 } IntPtr ptrWnd = IntPtr.Zero; // ptrWnd = FindWindow(null, "UHFReader288 Demo V1.16"); if (ptrWnd != IntPtr.Zero) // 检查当前统计窗口是否打开 { string para = fCmdRet.ToString(); // SendMessage(ptrWnd, WM_SENDSTATU, IntPtr.Zero, para); } return; } AA_times = 0; if ((fCmdRet == 1) || (fCmdRet == 2) || (fCmdRet == 0x26)) //代表已查找结束, { byte[] daw = new byte[Totallen]; Array.Copy(EPC, daw, Totallen); temps = ByteArrayToHexString(daw); if (fCmdRet == 0x26) { string SDCMD = temps.Substring(0, 12); temps = temps.Substring(12); daw = HexStringToByteArray(temps); byte[] datas = new byte[6]; datas = HexStringToByteArray(SDCMD); int tagrate = datas[0] * 256 + datas[1]; int tagnum = datas[2] * 256 * 256 * 256 + datas[3] * 256 * 256 + datas[4] * 256 + datas[5]; total_tagnum = total_tagnum + tagnum; IntPtr ptrWnd = IntPtr.Zero; // ptrWnd = FindWindow(null, "UHFReader288 Demo V1.16"); if (ptrWnd != IntPtr.Zero) // 检查当前统计窗口是否打开 { string para = tagrate.ToString() + "," + total_tagnum.ToString() + "," + cmdTime.ToString(); // SendMessage(ptrWnd, WM_SENDTAGSTAT, IntPtr.Zero, para); } } m = 0; List <string> epsList = new List <string>(); for (CardIndex = 0; CardIndex < CardNum; CardIndex++) { EPClen = daw[m] + 1; temp = temps.Substring(m * 2 + 2, EPClen * 2); sEPC = temp.Substring(0, temp.Length - 2); int RSSI = Convert.ToInt32(temp.Substring(temp.Length - 2, 2), 16); m = m + EPClen + 1; if (sEPC.Length != (EPClen - 1) * 2) { return; } if (epsList.Contains(sEPC)) { continue; } epsList.Add(sEPC); IntPtr ptrWnd = IntPtr.Zero; // ptrWnd = FindWindow(null, "UHFReader288 Demo V1.16"); if (ptrWnd != IntPtr.Zero) // 检查当前统计窗口是否打开 { string para = sEPC + "," + RSSI.ToString() + " "; // SendMessage(ptrWnd, WM_SENDTAG, IntPtr.Zero, para); } var readTime = DateTime.Now; var tag = new Split { DateTimeOfDay = readTime, TimeOfDay = readTime.ToString("hh.mm.ss.ff"), Epc = sEPC, Rssi = RSSI, SplitName = _readerProfile.Name, SplitDeviceId = _readerProfile.Id, InventorySearchMode = _readerProfile.InventorySearchMode, Antenna = Ant.ToString() }; recordTag(tag); } } }
protected override IEnumerable <Tuple <string, float> > GetScoredRelevantItems(Model model, Split split, User user) { return (GetRelevantItems(split, user) .Select(i => new Tuple <string, float>(i, (float)_scores[int.Parse(user.Id), int.Parse(i)]))); }
private void ReadBufferData() { int Totallen = 0; int CardNum = 0; byte[] pEPCList = new byte[30000]; //lxLed_BNum.Text = "0"; //lxLed_Bcmdsud.Text = "0"; //lxLed_Btoltag.Text = "0"; //lxLed_Btoltime.Text = "0"; //lxLed_cmdTime.Text = "0"; string temp = ""; fCmdRet = RWDev.ReadBuffer_G2(ref fComAdr, ref Totallen, ref CardNum, pEPCList, frmcomportindex); if (fCmdRet == 1) { int m = 0; byte[] daw = new byte[Totallen]; Array.Copy(pEPCList, daw, Totallen); for (int i = 0; i < CardNum; i++) { string ant = Convert.ToString(daw[m], 2).PadLeft(4, '0'); int len = daw[m + 1]; byte[] EPC = new byte[len]; Array.Copy(daw, m + 2, EPC, 0, len); string sEPC = ByteArrayToHexString(EPC); int RSSI = daw[m + 2 + len]; string sCount = daw[m + 3 + len].ToString(); m = m + 4 + len; var readTime = DateTime.Now; var tag = new Split { DateTimeOfDay = readTime, TimeOfDay = readTime.ToString("hh.mm.ss.ff"), Epc = sEPC, Rssi = RSSI, SplitName = _readerProfile.Name, SplitDeviceId = _readerProfile.Id, InventorySearchMode = _readerProfile.InventorySearchMode, Antenna = ant }; if (_readerProfile.ReadingMode == ReadingMode.Desktop) { onAssignTag(tag); continue; } onRecordTag(tag); } string strLog = "Read buffer success "; // WriteLog(lrtxtLog, strLog, 0); } else { string strLog = "Read buffer failed!: " + GetReturnCodeDesc(fCmdRet); MessageBox.Show(strLog); } }
protected override IEnumerable <Tuple <string, float> > GetScoredCandidateItems(Model model, Split split, User user) { return (GetCandidateItems(split, user) .Select(i => { int uId = int.Parse(user.Id); int iId = int.Parse(i); //if (_scores.ContainsKey(uId, iId)) return new Tuple <string, float>(i, (float)_scores[uId, iId]); //return new Tuple<string, float>(i, -1f); })); }
/// <summary> /// Applies a split to the portfolio equity positions /// </summary> /// <param name="split">The split to be applied</param> private void ApplySplitToEquities(Split split) { var security = Securities[split.Symbol]; // only apply splits to equities if (security.Type != SecurityType.Equity) { return; } // only apply splits in raw data mode, var mode = security.DataNormalizationMode; if (mode != DataNormalizationMode.Raw) { return; } // we need to modify our holdings in lght of the split factor var quantity = security.Holdings.Quantity / split.SplitFactor; var avgPrice = security.Holdings.AveragePrice * split.SplitFactor; // we'll model this as a cash adjustment var leftOver = quantity - (int)quantity; var extraCash = leftOver * split.ReferencePrice; _baseCurrencyCash.AddAmount(extraCash); security.Holdings.SetHoldings(avgPrice, (int)quantity); // build a 'next' value to update the market prices in light of the split factor var next = security.GetLastData(); if (next == null) { // sometimes we can get splits before we receive data which // will cause this to return null, in this case we can't possibly // have any holdings or price to set since we haven't received // data yet, so just do nothing return; } next.Value *= split.SplitFactor; // make sure to modify open/high/low as well for tradebar data types var tradeBar = next as TradeBar; if (tradeBar != null) { tradeBar.Open *= split.SplitFactor; tradeBar.High *= split.SplitFactor; tradeBar.Low *= split.SplitFactor; } // make sure to modify bid/ask as well for tradebar data types var tick = next as Tick; if (tick != null) { tick.AskPrice *= split.SplitFactor; tick.BidPrice *= split.SplitFactor; } security.SetMarketPrice(next); }
protected override void Initialize(Split split) { var fr = new StreamReader(FeedbackFile); var pr = new StreamReader(PredFile); var tr = new StreamReader(TrainFile); _userItemsInTest = new List <Tuple <int, int> >(); _userItemsInTrain = new List <Tuple <int, int> >(); _scores = new MultiKeyDictionary <int, int, double>(); _userTestFeedback = new Dictionary <int, List <int> >(); _userCandidates = new Dictionary <int, List <int> >(); string fline, pline; while ((fline = fr.ReadLine()) != null) { pline = pr.ReadLine(); var fparts = fline.Split(','); int uId = int.Parse(fparts[0]); int iId = int.Parse(fparts[1]); if (fparts.Last() == "1") { _userItemsInTest.Add(new Tuple <int, int>(uId, iId)); } else { if (!_userCandidates.ContainsKey(uId)) { _userCandidates[uId] = new List <int>(); } _userCandidates[uId].Add(iId); } _scores.Add(uId, iId, double.Parse(pline)); } fr.Close(); pr.Close(); string tline; while ((tline = tr.ReadLine()) != null) { var tparts = tline.Split(','); int uId = int.Parse(tparts[0]); int iId = int.Parse(tparts[1]); if (tparts.Last() == "1") { _userItemsInTrain.Add(new Tuple <int, int>(uId, iId)); } //_scores.Add(uId, iId, 1f); } tr.Close(); _userPosFeedback = _userItemsInTest.Union(_userItemsInTrain).GroupBy(ui => ui.Item1).ToDictionary(g => g.Key, g => g.Select(ui => ui.Item2).ToList()); _allCandidateItems = _scores.SelectMany(kv => kv.Value.Keys).Select(i => i.ToString()).ToList(); _userTestFeedback = _userItemsInTest.GroupBy(ui => ui.Item1) .ToDictionary(g => g.Key, g => g.Select(ui => ui.Item2).ToList()); foreach (var kv in _userCandidates) { //if (kv.Value.Intersect(_userPosFeedback[kv.Key]).Any()) // throw new Exception("Should not be common items in both candidate and pos feedback!"); } }
public override void AbcUpdate() { if (!AbcIsDirty()) { return; } bool useSubObjects = (m_summary.topologyVariance == AbcAPI.aiTopologyVariance.Heterogeneous || m_sampleSummary.splitCount > 1); for (int s = 0; s < m_splits.Count; ++s) { Split split = m_splits[s]; if (split.active) { // Feshly created splits may not have their host set yet if (split.host == null) { if (useSubObjects) { string name = m_trans.gameObject.name + "_split_" + s; Transform trans = m_trans.FindChild(name); if (trans == null) { GameObject go = new GameObject(); go.name = name; trans = go.GetComponent <Transform>(); trans.parent = m_trans; trans.localPosition = Vector3.zero; trans.localEulerAngles = Vector3.zero; trans.localScale = Vector3.one; } split.host = trans.gameObject; } else { split.host = m_trans.gameObject; } } // Feshly created splits may not have their mesh set yet if (split.mesh == null) { split.mesh = AddMeshComponents(m_abcObj, split.host); split.mesh.name = split.host.name; } if (split.clear) { split.mesh.Clear(); } split.mesh.vertices = split.positionCache; split.mesh.normals = split.normalCache; split.mesh.tangents = split.tangentCache; split.mesh.uv = split.uvCache; // update the bounds split.mesh.bounds = new Bounds(split.center, split.size); if (split.clear) { split.mesh.subMeshCount = split.submeshCount; MeshRenderer renderer = split.host.GetComponent <MeshRenderer>(); Material[] currentMaterials = renderer.sharedMaterials; int nmat = currentMaterials.Length; if (nmat != split.submeshCount) { Material[] materials = new Material[split.submeshCount]; int copyTo = (nmat < split.submeshCount ? nmat : split.submeshCount); for (int i = 0; i < copyTo; ++i) { materials[i] = currentMaterials[i]; } #if UNITY_EDITOR for (int i = copyTo; i < split.submeshCount; ++i) { Material material = UnityEngine.Object.Instantiate(AbcUtils.GetDefaultMaterial()); material.name = "Material_" + Convert.ToString(i); materials[i] = material; } #endif renderer.sharedMaterials = materials; } } split.clear = false; split.host.SetActive(true); } else { split.host.SetActive(false); } } for (int s = 0; s < m_submeshes.Count; ++s) { Submesh submesh = m_submeshes[s]; if (submesh.update) { m_splits[submesh.splitIndex].mesh.SetIndices(submesh.indexCache, MeshTopology.Triangles, submesh.index); submesh.update = false; } } if (!m_sampleSummary.hasNormals && !m_sampleSummary.hasTangents) { for (int s = 0; s < m_sampleSummary.splitCount; ++s) { m_splits[s].mesh.RecalculateNormals(); } } AbcClean(); }
protected override IEnumerable <Tuple <string, float> > GetScoredCandidateItems(Model model, Split split, User user) { return(GetCandidateItems(split, user).Select(i => { var item = split.Container.AddItem(i); var feedback = new Feedback(user, item); return new Tuple <string, float>(i, model.Predict(feedback)); })); }
private void AddPageEndingDimension(Page page, Split split, double splitWidth, double locationX, double lastDimensionX, bool isFirstPage) { DimensionItem item; if (split == Split.Start) { item = Util.eplan.AddDimension( page, null, splitWidth - 1000, lastDimensionX + 500, _origin.Y - _dimOffset[0], locationX + 420, _origin.Y - _dimOffset[0], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = string.Format("{0:F0}", splitWidth - 1000); item = Util.eplan.AddDimension( page, null, splitWidth, lastDimensionX, _origin.Y - _dimOffset[1], locationX + 210, _origin.Y - _dimOffset[1], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = splitWidth.ToString("F0"); } else if (split == Split.End) { item = Util.eplan.AddDimension( page, null, 420, locationX, _origin.Y - _dimOffset[0], locationX + 420, _origin.Y - _dimOffset[0], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = ""; item = Util.eplan.AddDimension( page, null, 210, lastDimensionX, _origin.Y - _dimOffset[1], locationX + 210, _origin.Y - _dimOffset[1], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = ""; } else { item = Util.eplan.AddDimension( page, null, splitWidth - 1000, lastDimensionX + 500, _origin.Y - _dimOffset[0], locationX + 420, _origin.Y - _dimOffset[0], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = string.Format("{0:F0}", splitWidth - 1000); item = Util.eplan.AddDimension( page, null, splitWidth, lastDimensionX, _origin.Y - _dimOffset[1], locationX + 210, _origin.Y - _dimOffset[1], 20); item.ExtensionLineSecond = false; item.DimensionCalculated = false; item.DimensionLineTermination = DimensionItem.Enums.DimensionLineTermination.Without; item.DimensionText = splitWidth.ToString("F0"); } AddTotalDimension(page, locationX, !isFirstPage, true); }
protected override IEnumerable <Tuple <string, float> > GetScoredRelevantItems(Model model, Split split, User user) { return(user.Feedbacks.Where(f => f.SliceType == FeedbackSlice.TEST) .Select(f => new Tuple <string, float>(f.Item.Id, model.Predict(f)))); }
public LiveSplitXMLReader() { split = new Split(); xmlDocument = new XmlDocument(); }
private void SetStudsRegions() { var storyNo = WallPolygon.IfWall.Story.StoryNo; double height = 0; UnitName unit = WallPolygon.IfWall.IfModel.IfUnit.LengthUnit; height = WallPolygon.IfWall.IfDimension.ZDim.Feet; //switch (unit) //{ // case UnitName.MILLIMETRE: // height = Length.FromMilliMeters(WallPolygon.IfWall.IfDimension.ZDim.MilliMeter).Feet; // break; // // case UnitName.FOOT: // height = WallPolygon.IfWall.IfDimension.ZDim.Feet; // break; // case UnitName.METRE: // height = Length.FromMeters(WallPolygon.IfWall.IfDimension.ZDim.Meter).Feet; // break; // default: // break; //} var dim = IfStud.Setup.Get <IfDimension>("Dimension"); var maxdistance = StudTable.GetSpace(storyNo + 1, height, dim) .LastOrDefault().Spacing; // set maxdistance unit //switch (unit) //{ // case UnitName.MILLIMETRE: // maxdistance = Length.FromInches(maxdistance).MilliMeter; // //dim = dim.ToMilliMeters(); // break; // // case UnitName.METRE: // maxdistance = Length.FromInches(maxdistance).Meter; // //dim = dim.ToMeters(); // break; // // default: // maxdistance = Length.FromInches(maxdistance).Feet; // //dim = dim.ToFeet(); // break; //} //set Left Region foreach (var region in WallPolygon.RLeft) { double distance = 0; //switch (unit) //{ // case UnitName.MILLIMETRE: // distance = region.IfDimension.XDim.Inches; // break; // case UnitName.FOOT: // distance = region.IfDimension.XDim.Inches; // break; // case UnitName.METRE: // distance = region.IfDimension.XDim.Inches; // break; // default: // break; //} distance = region.IfDimension.XDim.Inches; var spaces = Split.Equal(distance - dim.XDim.Inches, maxdistance); for (int i = 0; i < spaces.Count; i++) { var ifStud = new IfStud(WallPolygon.IfWall) { IfModel = WallPolygon.IfWall.IfModel, IfWall = WallPolygon.IfWall, IfLocation = new IfLocation(region.IfLocation.X + spaces[i] + dim.XDim.Inches / 2, region.IfLocation.Y, region.IfLocation.Z), IfDimension = new IfDimension( dim.XDim, dim.YDim, region.IfDimension.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("RLeft"), }; ifStud.New(); ifStud.IfMaterial.AttatchTo(ifStud); //add to studs elments IfStuds.Add(ifStud); // } } //set right Region foreach (var region in WallPolygon.RRight) { double distance = 0; switch (unit) { case UnitName.MILLIMETRE: distance = region.IfDimension.XDim.Inches; break; case UnitName.FOOT: distance = region.IfDimension.XDim.Inches; break; case UnitName.METRE: distance = region.IfDimension.XDim.Inches; break; default: break; } var spaces = Split.Equal(distance - dim.XDim.Inches, maxdistance); for (int i = 0; i < spaces.Count; i++) { var ifStud = new IfStud(WallPolygon.IfWall) { IfModel = WallPolygon.IfWall.IfModel, IfWall = WallPolygon.IfWall, IfLocation = new IfLocation(region.IfLocation.X + spaces[i] + dim.XDim.Inches / 2, region.IfLocation.Y, region.IfLocation.Z), IfDimension = new IfDimension( dim.XDim, dim.YDim, region.IfDimension.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("RRight") }; ifStud.New(); ifStud.IfMaterial.AttatchTo(ifStud); //add to studs elments IfStuds.Add(ifStud); // } } //set between regions foreach (var region in WallPolygon.RBetween) { double distance = 0; switch (unit) { case UnitName.MILLIMETRE: distance = region.IfDimension.XDim.Inches; break; case UnitName.FOOT: distance = region.IfDimension.XDim.Inches; break; case UnitName.METRE: distance = region.IfDimension.XDim.Inches; break; default: break; } var spaces = Split.Equal(distance - dim.XDim.Inches, maxdistance); for (int i = 0; i < spaces.Count; i++) { var ifStud = new IfStud(WallPolygon.IfWall) { IfModel = WallPolygon.IfWall.IfModel, IfWall = WallPolygon.IfWall, IfLocation = new IfLocation(region.IfLocation.X + spaces[i] + dim.XDim.Inches / 2, region.IfLocation.Y, region.IfLocation.Z), IfDimension = new IfDimension( dim.XDim, dim.YDim, region.IfDimension.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("RBetween") }; ifStud.New(); ifStud.IfMaterial.AttatchTo(ifStud); //add to studs elments IfStuds.Add(ifStud); // } } //set Bottom Region foreach (var region in WallPolygon.RBottom) { double distance = 0; switch (unit) { case UnitName.MILLIMETRE: distance = region.IfDimension.XDim.Inches; break; case UnitName.FOOT: distance = region.IfDimension.XDim.Inches; break; case UnitName.METRE: distance = region.IfDimension.XDim.Inches; break; default: break; } var spaces = Split.Equal(distance - dim.XDim.Inches, maxdistance); for (int i = 0; i < spaces.Count; i++) { var ifStud = new IfStud(WallPolygon.IfWall) { IfModel = WallPolygon.IfWall.IfModel, IfWall = WallPolygon.IfWall, IfLocation = new IfLocation(region.IfLocation.X + spaces[i] + dim.XDim.Inches / 2, region.IfLocation.Y, region.IfLocation.Z), IfDimension = new IfDimension( dim.XDim, dim.YDim, region.IfDimension.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("BottomStud") }; ifStud.New(); ifStud.IfMaterial.AttatchTo(ifStud); //add to studs elments IfStuds.Add(ifStud); // } } //set top region foreach (var region in WallPolygon.RTop) { double distance = 0; switch (unit) { case UnitName.MILLIMETRE: distance = region.IfDimension.XDim.Inches; break; case UnitName.FOOT: distance = region.IfDimension.XDim.Inches; break; case UnitName.METRE: distance = region.IfDimension.XDim.Inches; break; default: break; } var spaces = Split.Equal(distance - dim.XDim.Inches, maxdistance); for (int i = 0; i < spaces.Count; i++) { var ifStud = new IfStud(WallPolygon.IfWall) { IfModel = WallPolygon.IfWall.IfModel, IfWall = WallPolygon.IfWall, IfLocation = new IfLocation(region.IfLocation.X + spaces[i] + dim.XDim.Inches / 2, region.IfLocation.Y, region.IfLocation.Z), IfDimension = new IfDimension( dim.XDim, dim.YDim, region.IfDimension.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("TopStud") }; ifStud.New(); ifStud.IfMaterial.AttatchTo(ifStud); //add to studs elments IfStuds.Add(ifStud); // } } }
Task Split_Put(MetaLogEntity arg0) { return(Split.Put(arg0)); }
void UpdateSplits(int numSplits) { Split split = null; if (m_summary.topologyVariance == AbcAPI.aiTopologyVariance.Heterogeneous || numSplits > 1) { for (int i=0; i<numSplits; ++i) { if (i >= m_splits.Count) { split = new Split { positionCache = new Vector3[0], normalCache = new Vector3[0], uvCache = new Vector2[0], tangentCache = new Vector4[0], mesh = null, host = null, clear = true, submeshCount = 0, active = true, center = Vector3.zero, size = Vector3.zero }; m_splits.Add(split); } else { m_splits[i].active = true; } } } else { if (m_splits.Count == 0) { split = new Split { positionCache = new Vector3[0], normalCache = new Vector3[0], uvCache = new Vector2[0], tangentCache = new Vector4[0], mesh = null, host = m_trans.gameObject, clear = true, submeshCount = 0, active = true, center = Vector3.zero, size = Vector3.zero }; m_splits.Add(split); } else { m_splits[0].active = true; } } for (int i=numSplits; i<m_splits.Count; ++i) { m_splits[i].active = false; } }
/// <summary> /// Calculate the automatic approvals-- if any apply mark that approval level as complete /// </summary> /// <param name="order">The order</param> /// <param name="split">The split this autoApproval will be associated with</param> /// <param name="approver">The associated approver</param> private bool AutoApprovable(Order order, Split split, User approver) { if (approver == null) return false; //Only auto approve when assigned to a specific approver var total = split.Amount; var accountId = split.Account ?? string.Empty; if (order.Workgroup.ForceAccountApprover && string.IsNullOrWhiteSpace(accountId)) { return false; //If the workgroup forces account approver decision and this split doesn't have an account, then it can't be auto approved } if (string.Equals(approver.Id, _userIdentity.Current, StringComparison.OrdinalIgnoreCase) && string.Equals(approver.Id, order.CreatedBy.Id, StringComparison.OrdinalIgnoreCase)) { return true; //Auto approved if the approver is the current user } //See if there are any automatic approvals for this user/account. var possibleAutomaticApprovals = _repositoryFactory.AutoApprovalRepository.Queryable .Where(x => x.IsActive && (x.Expiration == null || x.Expiration > DateTime.UtcNow.ToPacificTime())) //valid only if it is active and isn't expired yet .Where(x => x.User.Id == approver.Id) //auto approval must have been created by the approver .Where(x => (x.TargetUser != null && x.TargetUser.Id == order.CreatedBy.Id) || x.Account.Id == accountId)//either applies to the order creator or account .ToList(); foreach (var autoApproval in possibleAutomaticApprovals) //for each autoapproval, check if they apply. If any do, return true { if (autoApproval.Equal) { if (total == autoApproval.MaxAmount) { return true; } } else //less than { if (total < autoApproval.MaxAmount) { return true; } } } return false; }
internal ShadowMapMonitor(int splitCount) { SplitCount = splitCount; split = new Split[SplitCount]; for (int i = 0; i < split.Length; i++) split[i] = new Split(); }
public Split MapXmlToDomain(XmlSplit xmlSplit, Group group) { Split split = new Split(xmlSplit.Id, group, xmlSplit.Axis, xmlSplit.Pivot, xmlSplit.Value, xmlSplit.Restriction); return split; }
public static void SplitSector(Sector t, int MaxTrianglesOnNode, int recursion, List <Split> splitList, List <ushort> TriangleIndexReferenceList, List <Vertex3> vList, List <RenderWareFile.Triangle> tList) { numberoftimes++; Split newSplitX = new Split { negativeSector = new Sector(), positiveSector = new Sector() }; newSplitX.negativeSector.TriangleIndexList = new List <ushort>(); newSplitX.negativeSector.splitPosition = (t.Max.X + t.Min.X) / 2; newSplitX.negativeSector.Min.X = t.Min.X; newSplitX.negativeSector.Min.Y = t.Min.Y; newSplitX.negativeSector.Min.Z = t.Min.Z; newSplitX.negativeSector.Max.X = newSplitX.negativeSector.splitPosition; newSplitX.negativeSector.Max.Y = t.Max.Y; newSplitX.negativeSector.Max.Z = t.Max.Z; newSplitX.negativeSector.type = SectorType.NegativeX; newSplitX.negativeSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitX.negativeSector, t.TriangleIndexList); newSplitX.positiveSector.TriangleIndexList = new List <ushort>(); newSplitX.positiveSector.splitPosition = (t.Max.X + t.Min.X) / 2; newSplitX.positiveSector.Min.X = newSplitX.positiveSector.splitPosition; newSplitX.positiveSector.Min.Y = t.Min.Y; newSplitX.positiveSector.Min.Z = t.Min.Z; newSplitX.positiveSector.Max.X = t.Max.X; newSplitX.positiveSector.Max.Y = t.Max.Y; newSplitX.positiveSector.Max.Z = t.Max.Z; newSplitX.positiveSector.type = SectorType.PositiveX; newSplitX.positiveSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitX.positiveSector, t.TriangleIndexList); //splitList.Add(newSplitX); Split newSplitY = new Split { negativeSector = new Sector(), positiveSector = new Sector() }; newSplitY.negativeSector.TriangleIndexList = new List <ushort>(); newSplitY.negativeSector.splitPosition = (t.Max.Y + t.Min.Y) / 2; newSplitY.negativeSector.Min.X = t.Min.X; newSplitY.negativeSector.Min.Y = t.Min.Y; newSplitY.negativeSector.Min.Z = t.Min.Z; newSplitY.negativeSector.Max.X = t.Max.X; newSplitY.negativeSector.Max.Y = newSplitY.negativeSector.splitPosition; newSplitY.negativeSector.Max.Z = t.Max.Z; newSplitY.negativeSector.type = SectorType.NegativeY; newSplitY.negativeSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitY.negativeSector, t.TriangleIndexList); newSplitY.positiveSector.TriangleIndexList = new List <ushort>(); newSplitY.positiveSector.splitPosition = (t.Max.Y + t.Min.Y) / 2; newSplitY.positiveSector.Min.X = t.Min.X; newSplitY.positiveSector.Min.Y = newSplitY.positiveSector.splitPosition; newSplitY.positiveSector.Min.Z = t.Min.Z; newSplitY.positiveSector.Max.X = t.Max.X; newSplitY.positiveSector.Max.Y = t.Max.Y; newSplitY.positiveSector.Max.Z = t.Max.Z; newSplitY.positiveSector.type = SectorType.PositiveY; newSplitY.positiveSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitY.positiveSector, t.TriangleIndexList); //splitList.Add(newSplitY); Split newSplitZ = new Split { negativeSector = new Sector(), positiveSector = new Sector() }; newSplitZ.negativeSector.TriangleIndexList = new List <ushort>(); newSplitZ.negativeSector.splitPosition = (t.Max.Z + t.Min.Z) / 2; newSplitZ.negativeSector.Min.X = t.Min.X; newSplitZ.negativeSector.Min.Y = t.Min.Y; newSplitZ.negativeSector.Min.Z = t.Min.Z; newSplitZ.negativeSector.Max.X = t.Max.X; newSplitZ.negativeSector.Max.Y = t.Max.Y; newSplitZ.negativeSector.Max.Z = newSplitZ.negativeSector.splitPosition; newSplitZ.negativeSector.type = SectorType.NegativeZ; newSplitZ.negativeSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitZ.negativeSector, t.TriangleIndexList); newSplitZ.positiveSector.TriangleIndexList = new List <ushort>(); newSplitZ.positiveSector.splitPosition = (t.Max.Z + t.Min.Z) / 2; newSplitZ.positiveSector.Min.X = t.Min.X; newSplitZ.positiveSector.Min.Y = t.Min.Y; newSplitZ.positiveSector.Min.Z = newSplitZ.positiveSector.splitPosition; newSplitZ.positiveSector.Max.X = t.Max.X; newSplitZ.positiveSector.Max.Y = t.Max.Y; newSplitZ.positiveSector.Max.Z = t.Max.Z; newSplitZ.positiveSector.type = SectorType.PositiveZ; newSplitZ.positiveSector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, newSplitZ.positiveSector, t.TriangleIndexList); //splitList.Add(newSplitZ); int XDiff = Math.Abs(newSplitX.negativeSector.TriangleIndexList.Count - newSplitX.positiveSector.TriangleIndexList.Count); int YDiff = Math.Abs(newSplitY.negativeSector.TriangleIndexList.Count - newSplitY.positiveSector.TriangleIndexList.Count); int ZDiff = Math.Abs(newSplitZ.negativeSector.TriangleIndexList.Count - newSplitZ.positiveSector.TriangleIndexList.Count); int PairToUse; if (XDiff <= YDiff & XDiff <= ZDiff) { PairToUse = 0; } else if (YDiff <= ZDiff) { PairToUse = 1; } else { PairToUse = 2; } if (PairToUse == 0) { splitList.Add(newSplitX); } else if (PairToUse == 1) { splitList.Add(newSplitY); } else if (PairToUse == 2) { splitList.Add(newSplitZ); } if (splitList.Last().negativeSector.TriangleIndexList.Count > MaxTrianglesOnNode) { splitList.Last().negativeSector.triangleAmount = 0xFF; splitList.Last().negativeSector.referenceIndex = (ushort)(splitList.Count); SplitSector(splitList.Last().negativeSector, MaxTrianglesOnNode, recursion + 1, splitList, TriangleIndexReferenceList, vList, tList); } else { splitList.Last().negativeSector.triangleAmount = (byte)splitList.Last().negativeSector.TriangleIndexList.Count(); splitList.Last().negativeSector.referenceIndex = PositionOnList; TriangleIndexReferenceList.AddRange(splitList.Last().negativeSector.TriangleIndexList); PositionOnList = (ushort)TriangleIndexReferenceList.Count(); } if (splitList.Last().positiveSector.TriangleIndexList.Count > MaxTrianglesOnNode) { splitList.Last().positiveSector.triangleAmount = 0xFF; splitList.Last().positiveSector.referenceIndex = (ushort)(splitList.Count); SplitSector(splitList.Last().positiveSector, MaxTrianglesOnNode, recursion + 1, splitList, TriangleIndexReferenceList, vList, tList); } else { splitList.Last().positiveSector.triangleAmount = (byte)splitList.Last().positiveSector.TriangleIndexList.Count(); splitList.Last().positiveSector.referenceIndex = PositionOnList; TriangleIndexReferenceList.AddRange(splitList.Last().positiveSector.TriangleIndexList); PositionOnList = (ushort)TriangleIndexReferenceList.Count(); } }
public static RWSection[] CreateShadowCollisionBSPFile(ModelConverterData data) { Vertex3 Max = new Vertex3(data.VertexList[0].Position.X, data.VertexList[0].Position.Y, data.VertexList[0].Position.Z); Vertex3 Min = new Vertex3(data.VertexList[0].Position.X, data.VertexList[0].Position.Y, data.VertexList[0].Position.Z); foreach (Vertex i in data.VertexList) { if (i.Position.X > Max.X) { Max.X = i.Position.X; } if (i.Position.Y > Max.Y) { Max.Y = i.Position.Y; } if (i.Position.Z > Max.Z) { Max.Z = i.Position.Z; } if (i.Position.X < Min.X) { Min.X = i.Position.X; } if (i.Position.Y < Min.Y) { Min.Y = i.Position.Y; } if (i.Position.Z < Min.Z) { Min.Z = i.Position.Z; } } List <Vertex3> vList = new List <Vertex3>(data.VertexList.Count); foreach (Vertex v in data.VertexList) { vList.Add(new Vertex3(v.Position.X, v.Position.Y, v.Position.Z)); } List <RenderWareFile.Triangle> tList = new List <RenderWareFile.Triangle>(data.TriangleList.Count); foreach (Triangle t in data.TriangleList) { tList.Add(new RenderWareFile.Triangle((ushort)t.MaterialIndex, (ushort)t.vertex1, (ushort)t.vertex2, (ushort)t.vertex3)); } List <BinMesh> binMeshList = new List <BinMesh>(); int TotalNumberOfTristripIndicies = 0; for (int i = 0; i < data.MaterialList.Count; i++) { List <int> indices = new List <int>(); foreach (Triangle f in data.TriangleList) { if (f.MaterialIndex == i) { indices.Add(f.vertex1); indices.Add(f.vertex2); indices.Add(f.vertex3); } } TotalNumberOfTristripIndicies += indices.Count(); binMeshList.Add(new BinMesh { materialIndex = i, indexCount = indices.Count(), vertexIndices = indices.ToArray() }); } // GENERATE COLLISION DATA List <ushort> TriangleIndexList = new List <ushort>(); List <Split> splitlist = new List <Split>(); ushort loop = 0; bool exitloop = false; Split split = new Split(); byte trianglesPerSplit = 200; while (!exitloop) { split = new Split { negativeSector = new Sector() { Max = Max, Min = Min, TriangleIndexList = new List <ushort>(), splitPosition = Max.X, type = SectorType.NegativeX }, positiveSector = new Sector() { Max = Max, Min = Min, TriangleIndexList = new List <ushort>(), splitPosition = Min.X, type = SectorType.PositiveX } }; for (ushort i = (ushort)(trianglesPerSplit * loop); i < tList.Count(); i++) { TriangleIndexList.Add(i); split.negativeSector.TriangleIndexList.Add(i); if (split.negativeSector.TriangleIndexList.Count() == trianglesPerSplit) { split.negativeSector.triangleAmount = trianglesPerSplit; split.negativeSector.referenceIndex = (ushort)(trianglesPerSplit * loop); loop += 1; split.positiveSector.triangleAmount = 0xFF; split.positiveSector.referenceIndex = loop; splitlist.Add(split); split = new Split(); exitloop = false; break; } exitloop = true; } } split.negativeSector.triangleAmount = (byte)split.negativeSector.TriangleIndexList.Count(); split.negativeSector.referenceIndex = (ushort)(trianglesPerSplit * loop); split.positiveSector.triangleAmount = 0; split.positiveSector.referenceIndex = 0; loop += 1; splitlist.Add(split); //Sector sector = new Sector() //{ // Max = Max, // Min = Min, // TriangleIndexList = new List<ushort>() //}; // sector.TriangleIndexList = FindTrianglesInsideNode(vList, tList, sector, TriangleIndexList); // List<ushort> TriangleIndexReferenceList = new List<ushort>(); // List<Split> splitList = new List<Split>(); //PositionOnList = 0; //SplitSector(sector, 20, 0, splitList, TriangleIndexReferenceList, vList, tList); // COLLISION FLAGS Color[] cFlagList = new Color[data.MaterialList.Count]; for (int i = 0; i < cFlagList.Length; i++) { cFlagList[i] = new Color(0x01, 0x00, 0x02, 0x00); string a = data.MaterialList[i].Split('_').Last(); if (a == "c") // ceiling { cFlagList[i] = new Color(0x00, 0x00, 0x00, 0x00); } else if (a == "f") // road floor { cFlagList[i] = new Color(0x01, 0x00, 0x02, 0x00); } else if (a == "fs") // stone floor { cFlagList[i] = new Color(0x01, 0x00, 0x00, 0x60); } else if (a == "fm") // metal floor { cFlagList[i] = new Color(0x01, 0x01, 0x01, 0x10); } else if (a == "t") // triangle jump wall { cFlagList[i] = new Color(0x02, 0x00, 0x00, 0x00); } else if (a == "a") // angle wall { cFlagList[i] = new Color(0x02, 0x01, 0x01, 0x10); } else if (a == "i") // invisible wall { cFlagList[i] = new Color(0x02, 0x02, 0x00, 0x00); } else if (a == "g") // green goo { cFlagList[i] = new Color(0x05, 0x00, 0x02, 0x00); } else if (a == "k") // barrier { cFlagList[i] = new Color(0x08, 0x00, 0x00, 0x00); } else if (a == "i2") // invisible wall at distance { cFlagList[i] = new Color(0x10, 0x00, 0x00, 0x00); } else if (a == "x") // death { cFlagList[i] = new Color(0x20, 0x00, 0x00, 0x00); } else if (a.Count() == 8) { try { cFlagList[i] = Color.FromString(a); } catch { cFlagList[i] = new Color(0x01, 0x00, 0x02, 0x00); } } } List <Color> cFlags = new List <Color>(); foreach (Triangle t in data.TriangleList) { cFlags.Add(cFlagList[t.MaterialIndex]); } // GENERATE RENDERWARE DATA World_000B world = new World_000B { worldStruct = new WorldStruct_0001() { rootIsWorldSector = 1, inverseOrigin = new Vertex3(-0f, -0f, -0f), numTriangles = (uint)data.TriangleList.Count(), numVertices = (uint)data.VertexList.Count(), numPlaneSectors = 0, numAtomicSectors = 1, colSectorSize = 0, worldFlags = WorldFlags.WorldSectorsOverlap,// | WorldFlags.ModulateMaterialColors, //(WorldFlags)0x40000040, boxMaximum = Max, boxMinimum = Min }, materialList = new MaterialList_0008() { materialListStruct = new MaterialListStruct_0001() { materialCount = data.MaterialList.Count() }, materialList = new Material_0007[data.MaterialList.Count()] }, firstWorldChunk = new AtomicSector_0009() { atomicSectorStruct = new AtomicSectorStruct_0001() { matListWindowBase = 0, numTriangles = data.TriangleList.Count(), numVertices = data.VertexList.Count(), boxMaximum = Max, boxMinimum = Min, collSectorPresent = 0x0012f410, unused = 0, vertexArray = vList.ToArray(), colorArray = null, uvArray = null, triangleArray = tList.ToArray() }, atomicSectorExtension = new Extension_0003() { extensionSectionList = new List <RWSection>() { new BinMeshPLG_050E() { binMeshHeaderFlags = BinMeshHeaderFlags.TriangleList, numMeshes = binMeshList.Count(), totalIndexCount = TotalNumberOfTristripIndicies, binMeshList = binMeshList.ToArray() }, new CollisionPLG_011D() { colTree = new ColTree_002C() { colTreeStruct = new ColTreeStruct_0001() { useMap = 1, boxMaximum = Max, boxMinimum = Min, numSplits = splitlist.Count(), numTriangles = TriangleIndexList.Count(), splitArray = splitlist.ToArray(), triangleArray = TriangleIndexList.ToArray(), }, }, unknownValue = 0x00037002 }, new UserDataPLG_011F() { userDataType = 0x02, unknown2 = 0x0A, attribute = "attribute", unknown3 = 0x01, numTriangles = tList.Count(), collisionFlags = cFlags.ToArray(), unknown4 = 0x0D, userData = "FVF.UserData", unknown5 = 0x01, unknown6 = 0x01, unknown7 = 0x3003 } } } }, worldExtension = new Extension_0003() }; for (int i = 0; i < data.MaterialList.Count; i++) { world.materialList.materialList[i] = new Material_0007() { materialStruct = new MaterialStruct_0001() { unusedFlags = 0, color = new Color() { R = 0xFF, G = 0xFF, B = 0xFF, A = 0xFF }, unusedInt2 = 0x01FAE70C, isTextured = 0, ambient = 1f, specular = 1f, diffuse = 1f }, texture = null, materialExtension = new Extension_0003() }; } return(new RWSection[] { world }); }
public string GetSubAccountDisplayForSplit(Split split) { if (string.IsNullOrWhiteSpace(split.SubAccount)) { return string.Empty; } var subAccount = SubAccounts.FirstOrDefault(x => x.AccountNumber == split.Account && x.SubAccountNumber == split.SubAccount); return subAccount == null ? split.SubAccount : string.Format("{0} ({1})", subAccount.Name, subAccount.SubAccountNumber); }