Exemple #1
0
 public void outputChanged(BooleanItem bi)
 {
     Console.WriteLine("Form1: Output Chaged:" + bi.ToString());
     //status.Text="Output changed:"+bi.ToString();
     if (bi == plc_h1)
     {
         this.setImage(pictureBox6, pultRot1Image, pultRot0Image, bi.getState());
     }
     else if (bi == plc_h2)
     {
         this.setImage(pictureBox7, pultGruen1Image, pultGruen0Image, bi.getState());
     }
     else if (bi == plc_h3)
     {
         this.setImage(pictureBox8, pultWeiss1Image, pultWeiss0Image, bi.getState());
     }
     else if (bi == plc_h4)
     {
         this.setImage(pictureBox9, pultWeiss1Image, pultWeiss0Image, bi.getState());
     }
     else
     {
         if (modell != null)
         {
             modell.outputchanged(bi);
         }
     }
 }
Exemple #2
0
        private void OnAdvise(object sender, DdeAdviseEventArgs args)
        {
            //Console.WriteLine("-> OnAdvise:" + args.Text+" sender="+sender+"\n");
            //Console.WriteLine("-> OnAdvise: Item=" + args.Item+"Value="+args.Text);
            //Console.WriteLine("OK");
            String itemString = args.Item;
            String byteAdr    = itemString.Substring(3, itemString.IndexOf(".") - 3);
            String bitAdr     = itemString.Substring(itemString.IndexOf(".") + 1);

            //Console.WriteLine("Byte=(" + byteAdr + ") Bit=(" + bitAdr+")");
            BooleanItem bi = getBooleanItem(Int32.Parse(byteAdr), Int32.Parse(bitAdr));

            //Console.WriteLine("Found: "+bi.ToString()+" NewValue="+args.Data.ToString());
            if (args.Data[0] == 49)
            {
                bi.setState(true);
            }
            else
            {
                bi.setState(false);
            }

            if (listener != null)
            {
                listener.outputChanged(bi);
            }
        }
Exemple #3
0
 public virtual void add(BooleanItem bi)
 {
     //Console.WriteLine("Füge hinzu:" + bi.ToString());
     pool.Add(bi);
     if (listener != null)
     {
         listener.outputChanged(bi);
     }
 }
Exemple #4
0
        override public void add(BooleanItem bi)
        {
            Console.WriteLine("Füge hinzu:" + bi.ToString() + " connected=" + connected);
            pool.Add(bi);
            if (connected)
            {
                ps.StartAdvise("%qx" + bi.byteAdr + "." + bi.bitAdr, 1, true, true, 60000, this);
                //ps.BeginRequest("%qx" + bi.byteAdr + "." + bi.bitAdr, 1, OnRequestComplete, ps);

                String s = ps.Request("%qx" + bi.byteAdr + "." + bi.bitAdr, 60000);
                //Console.WriteLine("Request=" + s);

                //Console.WriteLine("%qx" + bi.byteAdr + "." + bi.bitAdr + "=" + s);
                if (s.StartsWith("1"))
                {
                    bi.setState(true);
                }
                else
                {
                    bi.setState(false);
                }

                //Console.WriteLine("state)" + bi.getState());
            }
            else
            {
                Console.WriteLine("** Achtung Eingang hinzugefügt aber noch nicht verbunden !");
            }


            if (listener != null)
            {
                listener.outputChanged(bi);
            }
            else
            {
                Console.WriteLine("** Achtung Listener ist NULL!");
            }
        }
Exemple #5
0
 public void outputchanged(BooleanItem bi)
 {
     Console.WriteLine("Modell Output changed:" + bi.ToString());
     if (bi == m_left)
     {
         if (bi.getState())
         {
             this.left();
         }
         else
         {
             this.stop();
         }
     }
     else if (bi == m_right)
     {
         if (bi.getState())
         {
             this.right();
         }
         else
         {
             this.stop();
         }
     }
     else if (bi == m_speed)
     {
         if (bi.getState())
         {
             speedup = true;
         }
         else
         {
             speedup = false;
         }
         //Console.WriteLine("Speedup=" + speedup);
     }
 }
Exemple #6
0
        override public void add(BooleanItem bi)
        {
            Boolean oldState = bi.getState();

            // Initiales Mapping
            if ((inValue & 1) != 0 && bi.byteAdr == 4 && bi.bitAdr == 2)
            {
                bi.setState(true);
            }
            if ((inValue & 2) != 0 && bi.byteAdr == 4 && bi.bitAdr == 3)
            {
                bi.setState(true);
            }
            if ((inValue & 4) != 0 && bi.byteAdr == 4 && bi.bitAdr == 4)
            {
                bi.setState(true);
            }
            if ((inValue & 8) != 0 && bi.byteAdr == 4 && bi.bitAdr == 5)
            {
                bi.setState(true);
            }
            if ((inValue & 16) != 0 && bi.byteAdr == 9 && bi.bitAdr == 0)
            {
                bi.setState(true);
            }
            if ((inValue & 32) != 0 && bi.byteAdr == 9 && bi.bitAdr == 1)
            {
                bi.setState(true);
            }
            if ((inValue & 64) != 0 && bi.byteAdr == 9 && bi.bitAdr == 2)
            {
                bi.setState(true);
            }

            if ((inValue & 1) == 0 && bi.byteAdr == 4 && bi.bitAdr == 2)
            {
                bi.setState(false);
            }
            if ((inValue & 2) == 0 && bi.byteAdr == 4 && bi.bitAdr == 3)
            {
                bi.setState(false);
            }
            if ((inValue & 4) == 0 && bi.byteAdr == 4 && bi.bitAdr == 4)
            {
                bi.setState(false);
            }
            if ((inValue & 8) == 0 && bi.byteAdr == 4 && bi.bitAdr == 5)
            {
                bi.setState(false);
            }
            if ((inValue & 16) == 0 && bi.byteAdr == 9 && bi.bitAdr == 0)
            {
                bi.setState(false);
            }
            if ((inValue & 32) == 0 && bi.byteAdr == 9 && bi.bitAdr == 1)
            {
                bi.setState(false);
            }
            if ((inValue & 64) == 0 && bi.byteAdr == 9 && bi.bitAdr == 2)
            {
                bi.setState(false);
            }

            Console.WriteLine("DDE Fluidsim: Füge hinzu:" + bi.ToString());
            pool.Add(bi);

            if (listener != null)
            {
                if (oldState != bi.getState())
                {
                    Console.WriteLine("ADD Output Changed !");
                    listener.outputChanged(bi);
                }
            }
        }