public void GetNetlist(NetList obj) { Label = obj.Label; Node1 = obj.Node1; Node2 = obj.Node2; Value = obj.Value; }
public NetList <LinkData> GetLinksByLinkId(int linkId) { var response = new NetList <LinkData>(); var linkData = new LinkData(); try { linkData.processes = db.Processes.Where(x => x.LinkId == linkId).ToList(); linkData.peoples = db.Peoples.Where(x => x.LinkId == linkId).ToList(); linkData.tools = db.Tools.Where(x => x.LinkId == linkId).ToList(); response.Collection = new List <LinkData> { linkData }; response.Status = ResponseStatus.Succeed; } catch (Exception ex) { response.Status = ResponseStatus.Failed; response.Message = ex.Message; response.Exception = ex; } return(response); }
public void AddComponent() { var test = new NetList(); var component = new SimTestComponent(1); test.Add(component); }
public void GetVoltage2() { var test = new NetList(); var component = new SimTestComponent(2); test.Add(component); test.Simulate(); Assert.AreEqual(component.GetVoltageDrop(), 2); }
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { currentCookables = null; ingredients = new NetList <Item, NetRef <Item> >() { null, null, null, null, null, null, null, null, null, null, null }; oldIngredients = new Item[] { null, null, null, null, null, null, null, null, null, null, null }; ingredients.OnElementChanged += Ingredients_OnElementChanged; }
public void AddNode(ref NetList argData, int mode) { Console.WriteLine("Adding node {0}", argData.Label); Console.WriteLine("Type : {0}", argData.getComponentType()); NetListNode toAdd = new NetListNode(); toAdd.data.GetNetlist(argData); if (mode == NEW_ENTRY) { NetListCount++; } switch (argData.getComponentType()) { case 'R': if (mode == NEW_ENTRY) { ++ResistorCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(ResistorCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; case 'V': if (mode == NEW_ENTRY) { ++VoltageSourceCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(VoltageSourceCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; case 'C': if (mode == NEW_ENTRY) { ++CurrentSourceCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(CurrentSourceCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; } if (head == null) { head = toAdd; tail = toAdd; } else { tail.next = toAdd; tail = toAdd; } }
public void TestSingleResistors3() { var testResistComponent = new Resistor(1); var testBatteryComponent = new Battery(2); var test = new NetList(); test.Add(testResistComponent); test.Add(testBatteryComponent); test.AddConnection(testBatteryComponent.Bottom, testResistComponent.Top); test.AddConnection(testBatteryComponent.Top, testResistComponent.Bottom); test.Simulate(); Assert.AreEqual(2, testResistComponent.GetVoltageDrop()); }
public void Refresh() { NetList.Clear(); try { var builder = new LSBuilder(); var obj = builder.Get(MARKET_URL); if (obj["status"].Value.Equals("success")) { NetList = obj["tag"].GetValue(typeof(List <Metadata>)) as List <Metadata>; } } catch (Exception e) { } }
public void GetVoltageTwoComponent4() { var test = new NetList(); var component = new SimTestComponent(3); test.Add(component); var component2 = new SimTestComponent(3); test.Add(component2); test.AddConnection(component.Bottom, component2.Top); test.Simulate(); Assert.AreEqual(NetList.GetVoltageDrop(component.Top, component2.Bottom), 6); }
public void Refresh() { NetList.Clear(); try { var builder = new LSBuilder(); var obj = builder.Get(Config["MarketUrl"].Value); if (obj["status"].Value.Equals("success")) { NetList = obj["tag"].GetValue(typeof(List <Metadata>)) as List <Metadata>; } } catch (Exception e) { throw new PluginExecption("PluginListDownloadError"); } }
public NetList <Manager> GetAllManagerResponsibilities() { var response = new NetList <Manager>(); try { var data = db.Managers.ToList(); response.Collection = data; response.Status = ResponseStatus.Succeed; } catch (Exception ex) { response.Status = ResponseStatus.Failed; response.Message = ex.Message; response.Exception = ex; } return(response); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="field">The field to watch.</param> public NetListWatcher(NetList <TValue, NetRef <TValue> > field) { this.Field = field; #if SMAPI_FOR_MOBILE this.innerArray = (NetRef <NetArray <TValue, NetRef <TValue> > >) this.Field.GetType().GetField("array", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this.Field); this.hookArray(this.innerArray.Value); this.innerArray.fieldChangeVisibleEvent += (arrayRef, oldArray, newArray) => { if (newArray != null) { this.hookArray(newArray); } this.OnArrayReplaced(this.Field, oldArray, newArray); }; #else field.OnElementChanged += this.OnElementChanged; field.OnArrayReplaced += this.OnArrayReplaced; #endif }
public NetList <Link> GetAllLinks() { var response = new NetList <Link>(); try { var data = db.Links.ToList(); response.Collection = data; response.Status = ResponseStatus.Succeed; } catch (Exception ex) { response.Status = ResponseStatus.Failed; response.Message = ex.Message; response.Exception = ex; } return(response); }
/********* ** Private methods *********/ /// <summary>A callback invoked when the value list is replaced.</summary> /// <param name="list">The net field whose values changed.</param> /// <param name="oldValues">The previous list of values.</param> /// <param name="newValues">The new list of values.</param> private void OnArrayReplaced(NetList <TValue, NetRef <TValue> > list, IList <TValue> oldValues, IList <TValue> newValues) { ISet <TValue> oldSet = new HashSet <TValue>(oldValues, new ObjectReferenceComparer <TValue>()); ISet <TValue> changed = new HashSet <TValue>(newValues, new ObjectReferenceComparer <TValue>()); foreach (TValue value in oldSet) { if (!changed.Contains(value)) { this.Remove(value); } } foreach (TValue value in changed) { if (!oldSet.Contains(value)) { this.Add(value); } } }
public void Report_Via_Pad() { dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")); wordApp.Visible = true; dynamic wordDoc = wordApp.Documents.Add(); ////// StringBuilder sb = new StringBuilder(); IStep step = Parent.GetCurrentStep(); IMatrix m = Parent.GetMatrix(); foreach (INet NetList in step.GetNets()) { foreach (IODBObject obj in NetList.GetAllNetObjects(Parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); float x = ps.Location.X; float Y = ps.Location.Y; sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } } ////// string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString(); dynamic rng = wordApp.ActiveDocument.Range(0, 0); rng.Text = LVText; System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); }
public void Report_Via_Pad() { var excelType = Type.GetTypeFromProgID("Excel.Application"); dynamic excel = Activator.CreateInstance(excelType); excel.Visible = true; excel.Workbooks.Add(); ////// StringBuilder sb = new StringBuilder(); IStep step = Parent.GetCurrentStep(); IMatrix m = Parent.GetMatrix(); foreach (INet NetList in step.GetNets()) { foreach (IODBObject obj in NetList.GetAllNetObjects(Parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } else if (obj.GetParentLayerName().ToLower() == m.GetTopSignalLayer().ToLower()) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); if (ps.Type != PCBI.Symbol_Type.r) { float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("PAD_top;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } else if (obj.GetParentLayerName().ToLower() == m.GetBotSignalLayer().ToLower()) { if (obj.Type == IObjectType.Pad) { IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics(); if (ps.Type != PCBI.Symbol_Type.r) { float x = ps.Location.X; float Y = ps.Location.Y; if (Parent.GetUnit()) { float unit = 25.4f / 1000; x = x * unit; Y = Y * unit; } sb.Append("PAD_bot;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine); } } } } } ////// //string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString(); string LVText = "Type;NetName;posx;posy" + Environment.NewLine + sb.ToString(); string LVCsv = sb.ToString(); DataObject LVDataObject = new DataObject(); LVDataObject.SetData(DataFormats.Text, false, LVText); LVDataObject.SetData(DataFormats.CommaSeparatedValue, false, LVCsv); Clipboard.SetDataObject(LVDataObject, true); excel.ActiveSheet.Paste(); //release the object System.Runtime.InteropServices.Marshal.ReleaseComObject(excel); }
private void Ingredients_OnElementChanged(NetList <Item, NetRef <Item> > list, int index, Item oldValue, Item newValue) { UpdateCurrentCookables(); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="field">The field to watch.</param> public NetListWatcher(NetList <TValue, NetRef <TValue> > field) { this.Field = field; field.OnElementChanged += this.OnElementChanged; field.OnArrayReplaced += this.OnArrayReplaced; }
/// <summary>A callback invoked when an entry is replaced.</summary> /// <param name="list">The net field whose values changed.</param> /// <param name="index">The list index which changed.</param> /// <param name="oldValue">The previous value.</param> /// <param name="newValue">The new value.</param> private void OnElementChanged(NetList <TValue, NetRef <TValue> > list, int index, TValue oldValue, TValue newValue) { this.Remove(oldValue); this.Add(newValue); }
public void Execute(IPCBIWindow parent) { if (parent == null) { return; } TextType tt = TextType.angle; ShowInputDialog(ref tt); // MessageBox.Show( tt.ToString()); IMatrix m = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); if (tt == TextType.angle) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double angle = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)); obj.FreeText = "? " + angle.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; double angle = PAD.Rotation; obj.FreeText = "? " + angle.ToString(); } } } } if (tt == TextType.lenght) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100; if (parent.GetUnit()) { length *= 2.54f; } length = Math.Round(length, 2); obj.FreeText = "L: " + length.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; RectangleF bounds = obj.GetBounds(); double w = bounds.Width / 100; double h = bounds.Height / 100; if (parent.GetUnit()) { w *= 2.54f; h *= 2.54f; } w = Math.Round(w, 2); h = Math.Round(h, 2); obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString(); } } } } if (tt == TextType.ViaCount) { foreach (INet NetList in step.GetNets()) { int drillCount = 0; foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { drillCount++; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "DrillCount: " + drillCount.ToString(); } } } if (tt == TextType.NetOnLayer) { foreach (INet NetList in step.GetNets()) { string LNames = ""; foreach (string LayerNames in NetList.GetAllUsedLayers(step)) { if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal) { LNames += LayerNames + "; "; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "layer: " + LNames; } } } if (tt == TextType.NetLength) { foreach (INet NetList in step.GetNets()) { double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100; if (parent.GetUnit()) { length *= 2.54f; } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "Netlength: " + Math.Round(length, 2); } } } parent.ShowFreeTextInfoOnAllLayer = true; parent.UpdateView(); }
protected override void ReadDelta(BinaryReader reader, NetVersion version) { NetCoreObject obj = new NetCoreObject(); obj.Read(reader, version); //Values already taken care of in NetCoreObject NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> > netList = new NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> >(); netList.Read(reader, version); if (netList.ToList() == null) { throw new Exception("WTF WHY IS NETLIST NULL?!?!?!?!"); } foreach (var v in netList.ToList()) { StardustCore.ModCore.ModMonitor.Log(v.Value.name, StardewModdingAPI.LogLevel.Alert); } Value.objects = netList.ToList(); //this.value.objects=netList.ToArray().ToList(); NetColor col = new NetColor(); col.Read(reader, version); Value.categoryColor = col.Value; NetString name = new NetString(); name.Read(reader, version); Value.categoryName = name.Value; }
/// <summary>Get a watcher for a net list.</summary> /// <typeparam name="T">The value type.</typeparam> /// <param name="collection">The net list.</param> public static ICollectionWatcher <T> ForNetList <T>(NetList <T, NetRef <T> > collection) where T : class, INetObject <INetSerializable> { return(new NetListWatcher <T>(collection)); }
protected override void WriteDelta(BinaryWriter writer) { NetCoreObject obj = new NetCoreObject(Value); obj.Write(writer); NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> > netList = new NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> >(); if (Value.objects == null) { throw new Exception("Trying to write null object list!"); } foreach (var v in Value.objects) { StardustCore.ModCore.ModMonitor.Log(v.Value.name); netList.Add(v); } netList.Write(writer); NetColor col = new NetColor(Value.categoryColor); col.Write(writer); NetString catName = new NetString(Value.categoryName); catName.Write(writer); }
public static void Main(string[] args) { LinkedListNetList NetListObj = new LinkedListNetList(); LinkedListNetList ResistorList = new LinkedListNetList(); LinkedListNetList VoltageSourceList = new LinkedListNetList(); LinkedListNetList CurrentSourceList = new LinkedListNetList(); // Console.Write("Number of elements: "); // string NetListNumString = Console.ReadLine(); // int NetListNum = Convert.ToInt32(NetListNumString); int NetListNum = 5; string[] NetListStringArray = new string[] { "V1 1 0 15", "R1 1 2 2700", "R2 2 0 5000", "R35 2 3 1000000", "RZ 3 0 10000" }; for (int i = 0; i < NetListNum; i++) { // NetListStringArray[i] = Console.ReadLine(); // for (int i = 0; i < args.Length; i++) // extracting NetList from input and storing in linked list string[] parts = NetListStringArray[i].Split(' '); string Type = parts[0]; string Node1str = parts[1]; string Node2str = parts[2]; string Valuestr = parts[3]; int Node1 = Convert.ToInt32(Node1str); int Node2 = Convert.ToInt32(Node2str); int Value = Convert.ToInt32(Valuestr); NetList newElement = new NetList(); newElement.GetNetlist(Type, Node1, Node2, Value); NetListObj.AddNode(ref newElement, NEW_ENTRY); switch (newElement.getComponentType()) { case 'R': Console.WriteLine("newElement read resistor"); ResistorList.AddNode(ref newElement, OLD_ENTRY); break; case 'V': Console.WriteLine("newElement read voltage"); VoltageSourceList.AddNode(ref newElement, OLD_ENTRY); break; case 'C': Console.WriteLine("newElement read current"); CurrentSourceList.AddNode(ref newElement, OLD_ENTRY); break; default: // break; } } Console.WriteLine("Read all netlist..."); NetListObj.PrintLinkedListNetList(); VoltageSourceList.PrintLinkedListNetList(); ResistorList.PrintLinkedListNetList(); // asdasd int nodeNum = NetListObj.NodeCount(); // counts non-redundant nodes int voltageNum = VoltageSourceList.VoltageCount(); // counts individual voltage nodes from list Console.WriteLine("{0} {1}", nodeNum, voltageNum); double[,] matrixA = new double[nodeNum + voltageNum, nodeNum + voltageNum]; double[,] matrixG = new double[nodeNum, nodeNum]; double[,] matrixB = new double[nodeNum, voltageNum]; double[,] matrixC = new double[voltageNum, nodeNum]; double[,] matrixD = new double[voltageNum, voltageNum]; // matrixD is zero, no dependent sources assumed double[,] matrixX = new double[nodeNum + voltageNum, 1]; // unknown double[,] matrixZ = new double[nodeNum + voltageNum, 1]; double[,] matrixI = new double[nodeNum, 1]; double[,] matrixE = new double[voltageNum, 1]; double[,] matrixAsub1 = new double[nodeNum, nodeNum + voltageNum]; double[,] matrixAsub2 = new double[voltageNum, nodeNum + voltageNum]; double[,] matrixAinv = new double[nodeNum + voltageNum, nodeNum + voltageNum]; Console.WriteLine("Init matrix done"); matrixG = GetMatrixG(nodeNum, nodeNum, NetListObj); Console.WriteLine("MatrixG done"); PrintMatrix(matrixG); matrixB = GetMatrixB(nodeNum, voltageNum, NetListObj); Console.WriteLine("MatrixB done"); PrintMatrix(matrixB); matrixC = TransposeMatrix(nodeNum, voltageNum, matrixB); Console.WriteLine("MatrixC done"); matrixI = GetMatrixI(nodeNum, 1, CurrentSourceList); Console.WriteLine("MatrixI done"); matrixAsub1 = ConcatenateMatrix(matrixG, matrixB, HORIZONTAL); Console.WriteLine("MatrixAsub1 done"); matrixAsub2 = ConcatenateMatrix(matrixC, matrixD, HORIZONTAL); Console.WriteLine("MatrixAsub2 done"); matrixA = ConcatenateMatrix(matrixAsub1, matrixAsub2, VERTICAL); // matrixA done Console.WriteLine("MatrixA done"); PrintMatrix(matrixA); matrixZ = ConcatenateMatrix(matrixI, matrixE, VERTICAL); // matrixZ done matrixAinv = InverseMatrix(matrixA); matrixX = ProductMatrix(matrixAinv, matrixZ); Console.WriteLine("MatrixX"); }
public NetListNode() { next = null; data = new NetList(); }