using System;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [DllImport("TX.dll")]
        private static extern int txOpenController(int comnr);
        [DllImport("TX.dll")]
        private static extern int txGetInput(int ctrl, int io);
        [DllImport("TX.dll")]
        private static extern int txSetLamp(int ctrl, int io, int power);
         [DllImport("TX.dll")]
        private static extern int txCloseController();
        [DllImport("TX.dll")]
        private static extern int txSleep(int ms);

        static void Main(string[] args)
        {
           int res = txOpenController(95);

           if (res == 0) {Console.WriteLine("--- TX-Controller an COM95 verbunden ---\n");}
           else {Console.WriteLine("OpenError"); return;}
 
  Console.WriteLine("--- Zum Blinken: Taster I3 drücken ---");

  while (txGetInput(0, 2) == 0) txSleep(12); // Warten auf Tastendruck
  Console.WriteLine("--- Bei der Arbeit ---");
            txSetLamp(0, 4, 512); txSleep(200); // Hupen
  txSetLamp(0, 4, 0);
  for (int i=0; i<10; i++) {  // Blinken
	txSetLamp(0, 6, 512);
	txSetLamp(0, 7, 0);
	txSleep(200);
	txSetLamp(0, 6, 0);
	txSetLamp(0, 7, 512);
	txSleep(200);
  }
  txSetLamp(0, 7, 0);
  Console.WriteLine("Das war's");
  txSleep(1000);
  txCloseController();
        }
    }
}
