Example #1
0
 private void btnrecord_Click(object sender, EventArgs e)
 {
     try
     {
         RealValue = Convert.ToInt32(txt_RELDISC.Text);
         richTextBox1.AppendText("第" + Recordlist.Count + "组数据" + "\n" +
                                 "实际值" + RealValue.ToString() + "\n" +
                                 "最大值" + g_n32ScanMax.ToString() + "\n" +
                                 "最小值" + g_n32ScanMin.ToString() + "\n" +
                                 "平均值" + g_n64ScanAve.ToString() + "\n" +
                                 "离散度" + "±" + txt_DISPERSION.Text + "\n" +
                                 "概率" + g_n64ScanPercent.ToString() + "\r\n");
         RecordStruct l_sRecordData = new RecordStruct();
         l_sRecordData.m_int32max        = g_n32ScanMax;
         l_sRecordData.m_int32min        = g_n32ScanMin;
         l_sRecordData.m_int32ave        = (Int32)g_n64ScanAve;
         l_sRecordData.m_int32realdisc   = RealValue;
         l_sRecordData.m_int32maxdiff    = g_n32ScanMax - RealValue;
         l_sRecordData.m_int32mindiff    = g_n32ScanMin - RealValue;
         l_sRecordData.m_int32avediff    = (Int32)g_n64ScanAve - RealValue;
         l_sRecordData.m_int32dispersion = g_n32ScanMax - g_n32ScanMin;
         Recordlist.Add(l_sRecordData);
     }
     catch
     { }
 }
Example #2
0
        public Stack <RecordStruct> GetRecordList()
        {
            RecordStruct         recordInfo;
            Stack <RecordStruct> stack;

            stack = new Stack <RecordStruct>();
            string        commandText = "select * from task";
            SQLiteCommand command     = m_connect.CreateCommand();

            command.CommandText = commandText;
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                recordInfo                  = new RecordStruct();
                recordInfo.Url              = reader["url"].ToString();
                recordInfo.TaskName         = reader["taskName"].ToString();
                recordInfo.Path             = reader["path"].ToString();
                recordInfo.PageCount        = Convert.ToInt32(reader["pageCount"].ToString());
                recordInfo.DownLoadProgress = Convert.ToInt32(reader["pageDownLoad"].ToString());
                recordInfo.isFinished       = Convert.ToBoolean(reader["isFinished"].ToString());
                stack.Push(recordInfo);
            }
            return(stack);
        }
Example #3
0
        static public unsafe int InsertRecNo(IntPtr handle, IntPtr txnhandle,
                                             ref byte[] keydata, byte[] recordData, int flags)
        {
            KeyStruct    key    = new KeyStruct();
            RecordStruct record = new RecordStruct();

            fixed(byte *br = recordData)
            {
                record.data = br;
                record.size = recordData.GetLength(0);
                key.data    = null;
                key.size    = 0;
                int st = InsertLow(handle, txnhandle, ref key, ref record, flags);

                if (st != 0)
                {
                    return(st);
                }
                IntPtr keyData = new IntPtr(key.data);

                byte[] newKeyData = new byte[key.size];
                Marshal.Copy(keyData, newKeyData, 0, key.size);
                keydata = newKeyData;
                return(0);
            }
        }
Example #4
0
        static unsafe public int CursorFind(IntPtr handle, ref byte[] keydata,
                                            ref byte[] recdata, int flags)
        {
            KeyStruct    key    = new KeyStruct();
            RecordStruct record = new RecordStruct();

            fixed(byte *bk = keydata)
            {
                key.data = bk;
                key.size = (short)keydata.Length;
                int st = CursorFindLow(handle, ref key, ref record, flags);

                if (st != 0)
                {
                    return(st);
                }
                // I didn't found a way to avoid the copying...
                IntPtr recData = new IntPtr(record.data);

                byte[] newRecData = new byte[record.size];
                Marshal.Copy(recData, newRecData, 0, record.size);
                recdata = newRecData;
                // also copy the key data if approx. matching was requested
                if ((flags & (UpsConst.UPS_FIND_LT_MATCH | UpsConst.UPS_FIND_GT_MATCH)) != 0)
                {
                    IntPtr keyData    = new IntPtr(key.data);
                    byte[] newKeyData = new byte[key.size];
                    Marshal.Copy(keyData, newKeyData, 0, key.size);
                    keydata = newKeyData;
                }
                return(0);
            }
        }
Example #5
0
        public static unsafe int CursorFind(IntPtr handle, ref byte[] keydata,
                            ref byte[] recdata, int flags)
        {
            KeyStruct key = new KeyStruct();
              RecordStruct record = new RecordStruct();

              fixed (byte* bk = keydata) {
            key.data = bk;
            key.size = (short)keydata.Length;
            int st = CursorFindLow(handle, ref key, ref record, flags);
            if (st != 0)
              return st;
            // I didn't found a way to avoid the copying...
            IntPtr recData = new IntPtr(record.data);
            byte[] newRecData = new byte[record.size];
            Marshal.Copy(recData, newRecData, 0, record.size);
            recdata = newRecData;
            // also copy the key data if approx. matching was requested
            if ((flags & (UpsConst.UPS_FIND_LT_MATCH | UpsConst.UPS_FIND_GT_MATCH)) != 0) {
              IntPtr keyData = new IntPtr(key.data);
              byte[] newKeyData = new byte[key.size];
              Marshal.Copy(keyData, newKeyData, 0, key.size);
              keydata = newKeyData;
            }
            return 0;
              }
        }
Example #6
0
    private void M2()
    {
        var o = Source <object>(2);
        var r1 = new RecordStruct(o, null);

        Sink(r1.Prop1); // $ hasValueFlow=2
        Sink(r1.Prop2); // no flow

        var r2 = r1 with {
        };

        Sink(r2.Prop1); // $ hasValueFlow=2
        Sink(r2.Prop2); // no flow

        var r3 = r1 with {
            Prop2 = Source <object>(3)
        };

        Sink(r3.Prop1); // $ hasValueFlow=2
        Sink(r3.Prop2); // $ hasValueFlow=3

        var r4 = r1 with {
            Prop1 = null
        };

        Sink(r4.Prop1); // no flow
        Sink(r4.Prop2); // no flow
    }
Example #7
0
        /// <summary>
        /// Set of rules for adjusting data -- these are only hacks, and ought to be removed later...
        /// </summary>
        public static RecordStruct AdjustGPRSTime(RecordStruct record, string databaseName)
        {
            // Quokka security requires their data to be moved backward by 3 hours...
            if (databaseName == "RvQ9b3INZzATdwq0JtrH")
            {
                record.ReadTime = record.ReadTime.AddHours(-3);
            }

            return record;
        }
Example #8
0
        /// <summary>
        /// Set of rules for adjusting data -- these are only hacks, and ought to be removed later...
        /// </summary>
        public static RecordStruct AdjustGPRSTime(RecordStruct record, string databaseName)
        {
            // Quokka security requires their data to be moved backward by 3 hours...
            if (databaseName == "RvQ9b3INZzATdwq0JtrH")
            {
                record.ReadTime = record.ReadTime.AddHours(-3);
            }

            return(record);
        }
Example #9
0
        static unsafe public int CursorOverwrite(IntPtr handle, byte[] data, int flags)
        {
            RecordStruct record = new RecordStruct();

            fixed(byte *b = data)
            {
                record.data = b;
                record.size = data.GetLength(0);
                return(CursorOverwriteLow(handle, ref record, flags));
            }
        }
Example #10
0
        static unsafe public byte[] ResultGetRecord(IntPtr handle, int row)
        {
            RecordStruct record = new RecordStruct();

            ResultGetRecordLow(handle, row, ref record);
            IntPtr pdata = new IntPtr(record.data);

            byte[] data = new byte[record.size];
            Marshal.Copy(pdata, data, 0, record.size);
            return(data);
        }
Example #11
0
        static unsafe public byte[] CursorGetRecord(IntPtr handle, int flags)
        {
            RecordStruct record = new RecordStruct();
            int          st     = CursorMoveLow(handle, IntPtr.Zero, ref record, flags);

            if (st == 0)
            {
                // I didn't found a way to avoid the copying...
                IntPtr recData  = new IntPtr(record.data);
                byte[] newArray = new byte[record.size];
                Marshal.Copy(recData, newArray, 0, record.size);
                return(newArray);
            }
            throw new DatabaseException(st);
        }
Example #12
0
        static public unsafe int CursorInsert(IntPtr handle,
                                              byte[] keyData, byte[] recordData, int flags)
        {
            RecordStruct record = new RecordStruct();
            KeyStruct    key    = new KeyStruct();

            fixed(byte *br = recordData, bk = keyData)
            {
                record.data = br;
                record.size = recordData.GetLength(0);
                key.data    = bk;
                key.size    = (short)keyData.GetLength(0);
                return(CursorInsertLow(handle, ref key, ref record, flags));
            }
        }
Example #13
0
        static unsafe public int CursorGet(IntPtr handle, int flags, ref byte[] keyArray, ref byte[] recordArray)
        {
            KeyStruct    key    = new KeyStruct();
            RecordStruct record = new RecordStruct();
            int          st     = CursorMoveLow(handle, ref key, ref record, flags);

            if (st == 0)
            {
                IntPtr keyData = new IntPtr(key.data);
                keyArray = new byte[key.size];
                Marshal.Copy(keyData, keyArray, 0, key.size);

                IntPtr recData = new IntPtr(record.data);
                recordArray = new byte[record.size];
                Marshal.Copy(recData, recordArray, 0, record.size);
            }
            return(st);
        }
Example #14
0
        static public unsafe byte[] Find(IntPtr handle, IntPtr txnhandle, byte[] data, int flags)
        {
            KeyStruct    key    = new KeyStruct();
            RecordStruct record = new RecordStruct();

            key.size = (short)data.GetLength(0);
            fixed(byte *bk = data)
            {
                key.data = bk;
                int st = FindLow(handle, txnhandle, ref key, ref record, flags);

                if (st == 0)
                {
                    // I didn't found a way to avoid the copying...
                    IntPtr recData  = new IntPtr(record.data);
                    byte[] newArray = new byte[record.size];
                    Marshal.Copy(recData, newArray, 0, record.size);
                    return(newArray);
                }
                throw new DatabaseException(st);
            }
        }
Example #15
0
    void Update()
    {
        // TODO: Record in lower FPS and interpolate

        foreach (RecordStruct s in recordingControllers)
        {
            s.recording.AddLast(new PlaybackState(s.controller.transform.position, s.controller.transform.rotation, InputManager.GetInputState(s.controller).TriggerActuation));
        }

        for (int i = playingControllers.Count - 1; i >= 0; i--)
        {
            RecordStruct s = playingControllers[i];

            PlaybackState curState = s.iterator.Current;

            s.controller.transform.position = curState.position;
            s.controller.transform.rotation = curState.rotation;

            // Emulate input state changes
            InputManager.GetInputState(s.controller).TriggerActuation = curState.triggerActuation;

            if (curState.buttons != InputManager.InputState.ActiveFunction.None)
            {
                InputManager.GetInputState(s.controller).AddButton(curState.buttons);
                InputManager.GetInputState(s.controller).RemoveButton(InputManager.InputState.ActiveFunction.All);
            }

            if (!s.iterator.MoveNext())
            {
                InputManager.RemoveUserController(s.controller);
                Destroy(s.controller);

                playingControllers.RemoveAt(i);
            }
        }
    }
Example #16
0
 public static unsafe int CursorOverwrite(IntPtr handle, byte[] data, int flags)
 {
     RecordStruct record = new RecordStruct();
       fixed (byte* b = data) {
     record.data = b;
     record.size = data.GetLength(0);
     return CursorOverwriteLow(handle, ref record, flags);
       }
 }
Example #17
0
 public static unsafe byte[] CursorGetRecord(IntPtr handle, int flags)
 {
     RecordStruct record = new RecordStruct();
       int st = CursorMoveLow(handle, IntPtr.Zero, ref record, flags);
       if (st == 0) {
     // I didn't found a way to avoid the copying...
     IntPtr recData = new IntPtr(record.data);
     byte[] newArray = new byte[record.size];
     Marshal.Copy(recData, newArray, 0, record.size);
     return newArray;
       }
       throw new DatabaseException(st);
 }
Example #18
0
 public static unsafe int Insert(IntPtr handle, IntPtr txnhandle,
 byte[] keyData, byte[] recordData, int flags)
 {
     KeyStruct key = new KeyStruct();
       RecordStruct record = new RecordStruct();
       fixed (byte* br = recordData, bk = keyData) {
     record.data = br;
     record.size = recordData.GetLength(0);
     key.data = bk;
     key.size = (short)keyData.GetLength(0);
     return InsertLow(handle, txnhandle, ref key, ref record, flags);
       }
 }
Example #19
0
 static private extern void ResultGetRecordLow(IntPtr handle,
                                               int row, ref RecordStruct record);
Example #20
0
 public static unsafe int InsertRecNo(IntPtr handle, IntPtr txnhandle,
 ref byte[] keydata, byte[] recordData, int flags)
 {
     KeyStruct key = new KeyStruct();
     RecordStruct record = new RecordStruct();
     fixed (byte* br = recordData)
     {
     record.data = br;
     record.size = recordData.GetLength(0);
     key.data = null;
     key.size = 0;
     int st = InsertLow(handle, txnhandle, ref key, ref record, flags);
     if (st != 0)
         return st;
     IntPtr keyData = new IntPtr(key.data);
     byte[] newKeyData = new byte[key.size];
     Marshal.Copy(keyData, newKeyData, 0, key.size);
     keydata = newKeyData;
     return 0;
     }
 }
Example #21
0
 static private extern int CursorInsertLow(IntPtr handle,
                                           ref KeyStruct key, ref RecordStruct record, int flags);
Example #22
0
 static private extern int CursorOverwriteLow(IntPtr handle,
                                              ref RecordStruct record, int flags);
Example #23
0
 public static unsafe byte[] ResultGetRecord(IntPtr handle, int row)
 {
     RecordStruct record = new RecordStruct();
     ResultGetRecordLow(handle, row, ref record);
     IntPtr pdata = new IntPtr(record.data);
     byte[] data = new byte[record.size];
     Marshal.Copy(pdata, data, 0, record.size);
     return data;
 }
Example #24
0
 private static extern int CursorOverwriteLow(IntPtr handle,
 ref RecordStruct record, int flags);
Example #25
0
 private static extern int CursorMoveLow(IntPtr handle,
 ref KeyStruct key, ref RecordStruct record, int flags);
Example #26
0
 static private extern int CursorMoveLow(IntPtr handle,
                                         IntPtr key, ref RecordStruct record, int flags);
Example #27
0
 private static extern int InsertLow(IntPtr handle, IntPtr txnhandle,
 ref KeyStruct key, ref RecordStruct record, int flags);
Example #28
0
        public static unsafe int CursorGet(IntPtr handle, int flags, ref byte[] keyArray, ref byte[] recordArray)
        {
            KeyStruct key = new KeyStruct();
            RecordStruct record = new RecordStruct();
            int st = CursorMoveLow(handle, ref key, ref record, flags);
            if (st == 0)
            {
            IntPtr keyData = new IntPtr(key.data);
            keyArray = new byte[key.size];
            Marshal.Copy(keyData, keyArray, 0, key.size);

            IntPtr recData = new IntPtr(record.data);
            recordArray = new byte[record.size];
            Marshal.Copy(recData, recordArray, 0, record.size);
            }
            return st;
        }
Example #29
0
    private void OnControllerCallback(InputManager.InputState inputState)
    {
        if (inputState.Buttons.HasFlag(InputManager.InputState.ActiveFunction.SequenceRecord))
        {
            // Ensure that only one recording takes place at a time.
            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    return;
                }
            }

            recordingControllers.Add(new RecordStruct()
            {
                controller = inputState.Controller, recording = new LinkedList <PlaybackState>()
            });
        }
        else if ((inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks) > 0)
        {
            bool isRecording = false;


            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    isRecording = true;
                }
            }

            int offset = -1;

            if (!controllerPlaybackOffset.TryGetValue(inputState.Controller, out offset))
            {
                offset = nextOffset++;

                controllerPlaybackOffset.Add(inputState.Controller, offset);
            }

            int playbackIndex = 0;

            switch (inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks)
            {
            case InputManager.InputState.ActiveFunction.SequencePlayback0:
                playbackIndex = 0;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback1:
                playbackIndex = 1;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback2:
                playbackIndex = 2;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback3:
                playbackIndex = 3;
                break;
            }

            if (isRecording)
            {
                RecordStruct recStruct = null;

                foreach (RecordStruct s in recordingControllers)
                {
                    if (s.controller == inputState.Controller)
                    {
                        recStruct = s;
                        break;
                    }
                }

                // Last frame is the frame that will destroy the controller clone, so it won't be seen
                recStruct.recording.AddLast(new PlaybackState(Vector3.zero, Quaternion.identity, 0));


                recordedPlaybacks.Remove(offset * NUM_SEQUENCES + playbackIndex);
                recordedPlaybacks.Add(offset * NUM_SEQUENCES + playbackIndex, recStruct.recording);

                recordingControllers.Remove(recStruct);
            }
            else
            {
                LinkedList <PlaybackState> recording;

                if (recordedPlaybacks.TryGetValue(offset * NUM_SEQUENCES + playbackIndex, out recording))
                {
                    GameObject controller = Instantiate(controllerTemplate);

                    controller.SetActive(true);

                    controller.transform.parent = null;

                    // Update() may not be called directly after cloning, to avoid odd starting positions, we place the controller at the first frame
                    controller.transform.position = recording.First.Value.position;
                    controller.transform.rotation = recording.First.Value.rotation;

                    InputManager.AddUserController(controller);

                    playingControllers.Add(new RecordStruct()
                    {
                        controller = controller, recording = recording, iterator = recording.GetEnumerator()
                    });
                }
            }
        }
        else
        {
            // Record changes to input state too.
            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    // Add buttons to last recorded state (good enough approximation)
                    PlaybackState lastState = s.recording.Last.Value;

                    lastState.buttons |= inputState.Buttons;

                    s.recording.Last.Value = lastState;
                }
            }
        }
    }
Example #30
0
 private static extern void ResultGetRecordLow(IntPtr handle,
 int row, ref RecordStruct record);
Example #31
0
    public void RecordStructGetHashCodeInvocation()
    {
        var st = new RecordStruct();

        Allocations.AssertNoAllocations(() => st.GetHashCode());
    }
Example #32
0
 static private extern int FindLow(IntPtr handle, IntPtr txnhandle,
                                   ref KeyStruct key, ref RecordStruct record, int flags);