Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
 public void stop()
 {
     Console.WriteLine("Modell Stop");
     dx = 0;
     motor.halt();
     m_left.setState(false);
     m_right.setState(false);
 }
Exemplo n.º 3
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!");
            }
        }
Exemplo n.º 4
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);
                }
            }
        }