using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace StartServerWPF.Modules.MseedChart
{
    public class Mseed2asciiApi
    {
        public delegate void LoopCallbackHandler(AsciiDataStruct asciiData);
        [DllImport("mseedC.dll", EntryPoint = "MseedDatas")]
        public extern static int MseedDatas(int a, string[] name);
        //public extern static int MseedDatas(Byte[] bytes, int lenght);
        [DllImport("mseedC.dll", EntryPoint = "bufferMseedData")]
        public extern static int bufferMseedData(int argc, Byte[] argv);
        [DllImport("mseedC.dll", EntryPoint = "testc")]
        public extern static int testc(int a, int b);
        [DllImport("mseedC.dll")]
        public static extern void MseedDatasCallFun(LoopCallbackHandler callback);
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct AsciiDataStruct
    {
       public string sid;
      //  [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
        public string starttime;               //!< Time of first sample
      //   [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
        public string endtime;                 //!< Time of last sample
        public double samprate;                  //!< Nominal sample rate (Hz)
        public Int64 samplecnt;                //!< Number of samples in trace coverage
        public UInt64 datasize;                  //!< Size of datasamples buffer in bytes
        public Int64 numsamples;               //!< Number of data samples in datasamples
        public char sampletype;                 //!< Sample type code, see @ref sample-types
        public char samplesize;
        public System.IntPtr datasamples;       //!< Data samples, \a numsamples of type \a sampletype
    }
}
