Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Npgsql;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- float value1;
- int value2;
- string value1_bits;
- string value2_bits;
- string tmp;
- int count = 0;
- int len;
- NpgsqlConnection connect = new NpgsqlConnection("server=localhost;user=postgres;database=plc1;password=EvJxRf007;");
- connect.Open();
- NpgsqlCommand command = new NpgsqlCommand("", connect);
- for (long time = 591408000000; time < 591494400000; time += 200)
- {
- value1_bits = "";
- value1 = 22.34f;
- value2 = 10; //rnd.Next(10, 10);
- foreach (byte num in BitConverter.GetBytes(value1))
- {
- tmp = Convert.ToString(num, 2);
- len = tmp.Length;
- for (int i = 0; i < 8 - len; ++i)
- {
- tmp = "0" + tmp;
- }
- value1_bits = tmp + value1_bits;
- }
- value2_bits = Convert.ToString(value2, 2);
- len = value2_bits.Length;
- for (int i = 0; i < 32 - len; ++i)
- {
- value2_bits = "0" + value2_bits;
- }
- Console.WriteLine(count + "\n");
- command.CommandText = "INSERT INTO public.db_228_0(\"dword\", \"integer\", \"time\") VALUES(b'" + value1_bits +
- "', b'" + value2_bits + "'," + time + ");";
- command.ExecuteNonQuery();
- count++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement