daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Nov 6th, 2018 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Npgsql;
  7.  
  8. namespace ConsoleApp2
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Random rnd = new Random();
  15.             float value1;
  16.             int value2;
  17.             string value1_bits;
  18.             string value2_bits;
  19.             string tmp;
  20.             int count = 0;
  21.             int len;
  22.             NpgsqlConnection connect = new NpgsqlConnection("server=localhost;user=postgres;database=plc1;password=EvJxRf007;");
  23.             connect.Open();
  24.             NpgsqlCommand command = new NpgsqlCommand("", connect);
  25.             for (long time = 591408000000; time < 591494400000; time += 200)
  26.             {
  27.                 value1_bits = "";
  28.                 value1 = 22.34f;
  29.                 value2 = 10; //rnd.Next(10, 10);
  30.                 foreach (byte num in BitConverter.GetBytes(value1))
  31.                 {
  32.                     tmp = Convert.ToString(num, 2);
  33.                     len = tmp.Length;
  34.                     for (int i = 0; i < 8 - len; ++i)
  35.                     {
  36.                         tmp = "0" + tmp;
  37.                     }
  38.                     value1_bits = tmp + value1_bits;
  39.                 }
  40.                
  41.                 value2_bits = Convert.ToString(value2, 2);
  42.                 len = value2_bits.Length;
  43.                 for (int i = 0; i < 32 - len; ++i)
  44.                 {
  45.                     value2_bits = "0" + value2_bits;
  46.                 }
  47.                 Console.WriteLine(count + "\n");
  48.                 command.CommandText = "INSERT INTO public.db_228_0(\"dword\", \"integer\", \"time\") VALUES(b'" + value1_bits +
  49.                     "', b'" + value2_bits + "'," + time + ");";
  50.                 command.ExecuteNonQuery();
  51.                 count++;
  52.             }
  53.         }
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top