Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes | Static Public Attributes
electric.Diode Class Reference
Inheritance diagram for electric.Diode:
Inheritance graph
[legend]
Collaboration diagram for electric.Diode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def to_gnucap
def set_voltage_intensity
def get_rootitem
def move
def show
def hide
def destroy
def get_nodes
def is_connected
def component_move
def create_wire

Public Attributes

 item_values_x
 item_values_y
 electric
 canvas
 rootitem
 gnucap_name
 gnucap_value
 nodes
 comp_rootitem
 x
 y
 center_x
 center_y
 component_item_offset_x
 component_item_offset_y
 component_item
 item_values
 voltage
 intensity
 pos_x
 pos_y
 wire

Static Public Attributes

string image = "electric/diode.png"
string icon = "electric/diode_icon.png"
int counter = 0

Detailed Description

Definition at line 967 of file electric.py.


Constructor & Destructor Documentation

def electric.Diode.__init__ (   self,
  electric,
  x,
  y,
  dummy 
)

Definition at line 971 of file electric.py.

00971 
00972                x, y, dummy):
00973     super(Diode, self).__init__(electric,
00974                                 "D",
00975                                 "ddd 1.",
00976                                self.image,
00977                                [Node("electric/connect.png", "A", -30, -9),
00978                                 Node("electric/connect.png", "B", 95, -9)])
00979 
00980     # Overide some values
00981     self.item_values_x = 50
00982     self.item_values_y = 12
00983 
00984     self.move(x, y)
00985     self.show()
00986 


Member Function Documentation

def electric.Component.component_move (   self,
  widget,
  event,
  component 
) [inherited]

Reimplemented in electric.Bulb, electric.Rheostat, electric.Switch2, and electric.Switch.

Definition at line 873 of file electric.py.

00873 
00874     def component_move(self, widget, event, component):
00875 
00876       if event.state & gtk.gdk.BUTTON1_MASK:
00877         if event.type == gtk.gdk.MOTION_NOTIFY:
00878           if(self.electric.get_current_tools()=="SELECT"):
00879             component.move(event.x, event.y)
00880 
00881         else:
00882           if(self.electric.get_current_tools()=="DEL"):
00883             self.destroy()
00884 
00885       return True

Here is the call graph for this function:

def electric.Component.create_wire (   self,
  widget,
  event,
  node 
) [inherited]

Definition at line 887 of file electric.py.

00887 
00888     def create_wire(self, widget, event, node):
00889 
00890       if(self.electric.get_current_tools()=="DEL"):
00891         return True
00892 
00893       if event.type == gtk.gdk.BUTTON_PRESS:
00894         if event.button == 1:
00895           bounds = widget.get_bounds()
00896           self.pos_x = (bounds[0]+bounds[2])/2
00897           self.pos_y = (bounds[1]+bounds[3])/2
00898           self.wire = Wire(self.electric, node,
00899                            self.pos_x, self.pos_y, event.x, event.y)
00900           node.add_wire(self.wire)
00901           return True
00902 
00903       if event.type == gtk.gdk.MOTION_NOTIFY:
00904         if event.state & gtk.gdk.BUTTON1_MASK:
00905           self.wire.move_target_node(event.x, event.y)
00906 
00907       if event.type == gtk.gdk.BUTTON_RELEASE:
00908         if event.button == 1:
00909           node_target = None
00910           # Our wire line confuses the get_item_at. Look arround.
00911           for x in range(-10, 11, 5):
00912             target_item = self.canvas.get_item_at(event.x + x, event.y)
00913             if target_item:
00914               node_target = target_item.get_data('node')
00915               if(node_target):
00916                 break
00917 
00918           # Take care not to wire the same component or 2 times the same node
00919           if(not node_target
00920              or node.get_component() == node_target.get_component()
00921              or node_target.has_wire(self.wire)):
00922             node.remove_wire(self.wire, None)
00923             self.wire.destroy()
00924           else:
00925             self.wire.set_target_node(node_target)
00926             node_target.add_wire(self.wire)
00927             self.electric.run_simulation()
00928 
00929           return True
00930 
00931       return False
00932 
00933 # -----------------------------------------------------------------------
00934 # -----------------------------------------------------------------------
00935 # -----------------------------------------------------------------------
00936 #
00937 # Pre defined components
00938 # ----------------------
00939 #
00940 
00941 # ----------------------------------------
00942 # RESISTOR
00943 #
#
def electric.Component.destroy (   self) [inherited]

Definition at line 810 of file electric.py.

00810 
00811     def destroy(self):
00812       try:
00813         # Remove ourself from the list of gnucap aware components
00814         self.electric.components.remove(self)
00815       except:
00816         pass
00817 
00818       for node in self.nodes:
00819         while node.get_wires():
00820           wire = node.get_wires()[0]
00821           node.remove_wire(wire, None)
00822           wire.destroy()
00823 
00824       self.comp_rootitem.destroy()

Here is the caller graph for this function:

def electric.Component.get_nodes (   self) [inherited]

Definition at line 826 of file electric.py.

00826 
00827     def get_nodes(self):
00828       return self.nodes

def electric.Component.get_rootitem (   self) [inherited]

Definition at line 788 of file electric.py.

00788 
00789     def get_rootitem(self):
00790       return self.comp_rootitem

def electric.Component.hide (   self) [inherited]

Definition at line 807 of file electric.py.

00807 
00808     def hide(self):
00809       self.comp_rootitem.hide()

def electric.Component.is_connected (   self) [inherited]

Reimplemented in electric.Rheostat, and electric.Switch2.

Definition at line 834 of file electric.py.

00834 
00835     def is_connected(self):
00836 
00837       for node in self.nodes:
00838         if not node.get_wires():
00839           return False
00840 
00841       return True

def electric.Component.move (   self,
  x,
  y 
) [inherited]

Definition at line 791 of file electric.py.

00791 
00792     def move(self, x, y):
00793       self.x =  x - self.center_x
00794       self.y =  y - self.center_y
00795 
00796       self.item_values.set(x =  self.item_values_x + self.x,
00797                            y =  self.item_values_y + self.y)
00798 
00799       self.component_item.set(x =  self.x + self.component_item_offset_x,
00800                               y =  self.y + self.component_item_offset_y )
00801 
00802       for node in self.nodes:
00803         node.move( self.x,  self.y)

Here is the caller graph for this function:

def electric.Component.set_voltage_intensity (   self,
  valid_value,
  voltage,
  intensity 
) [inherited]

Reimplemented in electric.Battery, electric.Bulb, electric.Rheostat, electric.Switch2, and electric.Switch.

Definition at line 777 of file electric.py.

00777 
00778     def set_voltage_intensity(self, valid_value, voltage, intensity):
00779       self.voltage = voltage
00780       self.intensity = intensity
00781       if(valid_value):
00782         self.item_values.set(text="V=%.2fV\nI=%.3fA"%(voltage,intensity))
00783         self.item_values.show()
00784       else:
00785         self.item_values.hide()
00786       return True
00787 

Here is the caller graph for this function:

def electric.Component.show (   self) [inherited]

Definition at line 804 of file electric.py.

00804 
00805     def show(self):
00806       self.comp_rootitem.show()

Here is the caller graph for this function:

def electric.Diode.to_gnucap (   self,
  model 
)

Reimplemented from electric.Component.

Definition at line 989 of file electric.py.

00989 
00990   def to_gnucap(self, model):
00991     # Our 'ddd' Diode model
00992     # Idealized diode: ~0V treshold voltage. Characteristic graph
00993     # passes through the two points (10 mV, 10 mA) and (20 mV, 2000
00994     # mA) => N  = 0.072 IS = 5x10-5 A
00995     model = ".model  ddd  d  ( is= 50.u  rs= 0.  n= 0.072  tt= 0.  cjo= 1.p  vj= 1.  m= 0.5\n"
00996     model += "+ eg= 1.11  xti= 3.  kf= 0.  af= 1.  fc= 0.5  bv= 0.  ibv= 0.001 )\n"
00997 
00998     gnucap = []
00999     gnucap = super(Diode, self).to_gnucap(model)
01000     return gnucap
01001 
01002 # ----------------------------------------
01003 # SWITCH
01004 #
#

Member Data Documentation

Definition at line 718 of file electric.py.

Definition at line 743 of file electric.py.

Definition at line 744 of file electric.py.

Definition at line 732 of file electric.py.

Definition at line 748 of file electric.py.

Definition at line 746 of file electric.py.

Reimplemented in electric.Switch2.

Definition at line 747 of file electric.py.

int electric.Component.counter = 0 [static, inherited]

Definition at line 713 of file electric.py.

Definition at line 717 of file electric.py.

Definition at line 722 of file electric.py.

Reimplemented in electric.Bulb, and electric.Switch.

Definition at line 728 of file electric.py.

string electric.Diode.icon = "electric/diode_icon.png" [static]

Definition at line 969 of file electric.py.

string electric.Diode.image = "electric/diode.png" [static]

Reimplemented from electric.Component.

Definition at line 968 of file electric.py.

Reimplemented in electric.Rheostat, and electric.Switch.

Definition at line 779 of file electric.py.

Definition at line 764 of file electric.py.

Reimplemented from electric.Component.

Definition at line 980 of file electric.py.

Reimplemented from electric.Component.

Definition at line 981 of file electric.py.

Definition at line 730 of file electric.py.

Definition at line 895 of file electric.py.

Definition at line 896 of file electric.py.

Definition at line 719 of file electric.py.

Reimplemented in electric.Rheostat, and electric.Switch.

Definition at line 778 of file electric.py.

Definition at line 897 of file electric.py.

electric.Component.x [inherited]

Definition at line 741 of file electric.py.

electric.Component.y [inherited]

Definition at line 742 of file electric.py.


The documentation for this class was generated from the following file: