Пример #1
0
        private void Connect100ms()
        {
            short[] buffer_array = new short[158];

            int amount = 315;


            //var buffer2 = new ushort[128];
            int Byte_Col_r = 0;

            int resultReadField = stan.field_read('M', 0, 3000, amount, out buffer, out Byte_Col_r);

            if (resultReadField == 0)
            {
                //Console.WriteLine("OK.Read fied M3000-M3315");
                //System.Diagnostics.Debug.WriteLine("OK.Read fied M3000-M3315");

                //Console.WriteLine(string.Format("\t\t {0}  ({1})  {2}", "Message 100mc", DateTime.Now - dt100ms, Thread.CurrentThread.ManagedThreadId));
                dt100ms = DateTime.Now;


                //Todo 100ms Далее передаем данные в критическую сецкию из которой будут забирать потоки каждый в свой момент

                //Console.WriteLine("Byte_Col_r = " + Byte_Col_r);

                Console.WriteLine("Скорость 1(in) = " + BitConverter.ToInt16(buffer, 0));
                //Console.WriteLine("Скорость 2 = " + BitConverter.ToInt16(buffer, 2));
                //Console.WriteLine("Скорость 3 = " + BitConverter.ToInt16(buffer, 4));
                //Console.WriteLine("Скорость 4 = " + BitConverter.ToInt16(buffer, 6));
                //Console.WriteLine("Скорость 5 = " + BitConverter.ToInt16(buffer, 8));

                //Console.WriteLine("Толщина 1 = " + BitConverter.ToInt16(buffer, 10));
                //Console.WriteLine("Толщина 5 = " + BitConverter.ToInt16(buffer, 12));

                //Console.WriteLine("Ширина = " + BitConverter.ToInt16(buffer, 14));
                //Console.WriteLine("Диаметр выпуска = " + BitConverter.ToInt16(buffer, 16));
                //Console.WriteLine("Диаметр разматывателя = " + BitConverter.ToInt16(buffer, 18));
                //Console.WriteLine("Диаметр моталки = " + BitConverter.ToInt16(buffer, 20));


                Thread PLS100ms = new Thread(BufferToBuffer);
                PLS100ms.Start();
                //new Thread(BufferSQLToBufferPLS).Start();
            }
            else
            {
                Console.WriteLine("Error.Read fied M3000-M3315. " + stan.Error(resultReadField));
                System.Diagnostics.Debug.WriteLine("Error.Read fied M3000-M3315. " + stan.Error(resultReadField));
                LogSystem.WriteEventLog("ProDaveStan", "Test", "Соединение не активировано. " + stan.Error(resultReadField), EventLogEntryType.Error);
            }
        }
Пример #2
0
        private void Window_Closed(object sender, EventArgs e)
        {
            int result = stan.UnloadConnection(0);

            if (result == 0)
            {
                //Console.WriteLine("Connect close");
                LogSystem.WriteEventLog("ProDaveStan", "Test", "Close connection", EventLogEntryType.Information);
            }
            else
            {
                Console.WriteLine("Connect open. Error - " + stan.Error(result));
                LogSystem.WriteEventLog("ProDaveStan", "Test", "Connect open. Error - " + stan.Error(result), EventLogEntryType.Warning);
            }

            Console.ReadKey();
        }
Пример #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //TODO запуск таймеров 100ms(100ms), 101ms(SQL), 200ms(message), 1000ms(1s)

            stan = new Prodave();
            byte[] conn = new byte[] { 192, 168, 0, 11 };

            int res = stan.LoadConnection(Connect, 2, conn, 3, 0);

            if (res != 0)
            {
                Console.WriteLine("Error connection! " + stan.Error(res));
                LogSystem.WriteEventLog("ProDaveStan", "Test", "Error connection!. Error - " + stan.Error(res), EventLogEntryType.Error);
            }
            else
            {
                LogSystem.WriteEventLog("ProDaveStan", "Test", "Connect OK!", EventLogEntryType.Information);

                int resSAC = stan.SetActiveConnection(Connect);
                if (resSAC == 0)
                {
                    Console.WriteLine("Соединение активно.");
                    LogSystem.WriteEventLog("ProDaveStan", "Test", "Соединение активно.", EventLogEntryType.Information);



                    //Connect100ms();
                    TTimer100ms = new Timer(new TimerCallback(TicTimer100ms), null, 0, 100);

                    TTimerMessage = new Timer(new TimerCallback(TicTimerMessage), null, 0, 200);
                    TTimerSQL     = new Timer(new TimerCallback(TicTimerSQL), null, 0, 101);
                    TTimer1s      = new Timer(new TimerCallback(TicTimer1s), null, 0, 1000);
                }
                else
                {
                    Console.WriteLine("Соединение не активировано. " + stan.Error(resSAC));
                    LogSystem.WriteEventLog("ProDaveStan", "Test", "Соединение не активировано. " + stan.Error(resSAC), EventLogEntryType.Error);
                    System.Diagnostics.Debug.WriteLine("Error - Соединение не активировано.");
                }
            }
        }
Пример #4
0
 private void btnLogSaveClassLogger_Click(object sender, RoutedEventArgs e)
 {
     LogSystem.WriteEventLog("S7-BD(LPC2)", "Stan-BD-Prodave", "test message", EventLogEntryType.Information);
 }