Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Smart people, please look at this

Smart people, please look at this

Scheduled Pinned Locked Moved IT & Infrastructure
graphicscsharpdatabasequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Niklas Ulvinge
    wrote on last edited by
    #1

    Here I got some classes that should make a circut system. If I connect 3 cords and a battery it works. If I connect only one pole (the right one) to a cord that goes to ground, it says it goes thru... Since the other pole isn't connected it shouldn't do this. How could I make it work? And how does ground really work? The code is written in C#: using System; using System.Collections.Generic; using System.Drawing; using System.Text; namespace NiklasUlvinge.ChipsEater { abstract class Item { //var's public Item[][] input; public int x; public int y; public abstract Point[] Snap { get; } protected Item(int X, int Y) { x = X; y = Y; input = new Item[1][]; } //abstract funcs public abstract float Output(Item Inputitem); public abstract Item function(); public abstract void draw(Graphics g); public abstract bool isOn(); //funcs public void addBothInput(int index, int fromindex, Item Input) { Input.addInput(fromindex, this); this.addInput(index, Input); } private void addInput(int index, Item Input) { //index = input.Length & index; Item[] inp = input[index]; Item[] titem; if ((inp == null) || (inp.Length == 0)) { titem = new Item[1]; } else if (inp[0].x == -50) { titem = new Item[1]; } else titem = new Item[inp.Length + 1]; for (int i = 0; i < titem.Length - 1; i++) { titem[i] = inp[i]; } titem[titem.Length - 1] = Input; input[index] = titem; } //const protected Brush surf = Brushes.LightGray; protected Pen side = Pens.DarkGray; protected Pen loff = Pens.Black; protected Pen lon = Pens.Red; } class Cord : Item { public int x2, y2; public override bool isOn() { float l = 0; for (int i = 0; i < input[0].Length; i++) { l += input[0][i].Output(this); } float r = 0; for (int i = 0; i < input[1].Length; i++) { r += input[1][i].Out

    C 1 Reply Last reply
    0
    • N Niklas Ulvinge

      Here I got some classes that should make a circut system. If I connect 3 cords and a battery it works. If I connect only one pole (the right one) to a cord that goes to ground, it says it goes thru... Since the other pole isn't connected it shouldn't do this. How could I make it work? And how does ground really work? The code is written in C#: using System; using System.Collections.Generic; using System.Drawing; using System.Text; namespace NiklasUlvinge.ChipsEater { abstract class Item { //var's public Item[][] input; public int x; public int y; public abstract Point[] Snap { get; } protected Item(int X, int Y) { x = X; y = Y; input = new Item[1][]; } //abstract funcs public abstract float Output(Item Inputitem); public abstract Item function(); public abstract void draw(Graphics g); public abstract bool isOn(); //funcs public void addBothInput(int index, int fromindex, Item Input) { Input.addInput(fromindex, this); this.addInput(index, Input); } private void addInput(int index, Item Input) { //index = input.Length & index; Item[] inp = input[index]; Item[] titem; if ((inp == null) || (inp.Length == 0)) { titem = new Item[1]; } else if (inp[0].x == -50) { titem = new Item[1]; } else titem = new Item[inp.Length + 1]; for (int i = 0; i < titem.Length - 1; i++) { titem[i] = inp[i]; } titem[titem.Length - 1] = Input; input[index] = titem; } //const protected Brush surf = Brushes.LightGray; protected Pen side = Pens.DarkGray; protected Pen loff = Pens.Black; protected Pen lon = Pens.Red; } class Cord : Item { public int x2, y2; public override bool isOn() { float l = 0; for (int i = 0; i < input[0].Length; i++) { l += input[0][i].Output(this); } float r = 0; for (int i = 0; i < input[1].Length; i++) { r += input[1][i].Out

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I don't think I'm qualified to look at this, I'm not smart enough :-) However: Niklas Ulvinge wrote: And how does ground really work? The purpose of grounding is to cause any leaked electricity to have a direct circuit into the ground. For example, if you have a metal toaster, the earth wire is attached to the body of the toaster. That way, if a live wire ever gets loose, and touches the body, instead of a circuit to ground being created the next time you touch it, it's created right away, and it blows your fuse. It's there totally for safety, it has not 'necessary' in the sense that you can have power without it. All you need is active and neutral, as a lot of smaller products like cassette players do ( no earth ). Your earth wires all run to one bar in your fuse box, and that runs to a big old spike that's hammered into the ground. Sounds to me like you're creating a circuit to earth, and that your project is otherwise working as you'd expect. So, I'd say you don't have a problem :-) Christian Graus - Microsoft MVP - C++

      N 1 Reply Last reply
      0
      • C Christian Graus

        I don't think I'm qualified to look at this, I'm not smart enough :-) However: Niklas Ulvinge wrote: And how does ground really work? The purpose of grounding is to cause any leaked electricity to have a direct circuit into the ground. For example, if you have a metal toaster, the earth wire is attached to the body of the toaster. That way, if a live wire ever gets loose, and touches the body, instead of a circuit to ground being created the next time you touch it, it's created right away, and it blows your fuse. It's there totally for safety, it has not 'necessary' in the sense that you can have power without it. All you need is active and neutral, as a lot of smaller products like cassette players do ( no earth ). Your earth wires all run to one bar in your fuse box, and that runs to a big old spike that's hammered into the ground. Sounds to me like you're creating a circuit to earth, and that your project is otherwise working as you'd expect. So, I'd say you don't have a problem :-) Christian Graus - Microsoft MVP - C++

        N Offline
        N Offline
        Niklas Ulvinge
        wrote on last edited by
        #3

        Yes I do got a problem. If I only connect one pole (lets say the minus pole) to ground. It closes the circuit. Look at this ____ | /\ /\ | | |______/ \/ \______| | | | | \ /\ / | | | \/__\/ | Battery Lamp Ground The lamp is lit. It shouldn't be. That is what isn't working. Ground is used in a lot of other ways to. Niklas Ulvinge aka IDK

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups