Ejemplo n.º 1
0
        /// <summary>
        /// 保存数据到历史记录表
        /// </summary>
        /// <param name="tx300"></param>
        private void SaveTX300History(TX300 tx300, DateTime receiveTime, string mac_id)
        {
            TB_HISTORIES obj = DataInstance.GetObject();

            obj.command_id       = "0x" + CustomConvert.IntToDigit(tx300.CommandID, CustomConvert.HEX, 4);
            obj.mac_id           = mac_id;
            obj.message_content  = CustomConvert.GetHex(tx300.MsgContent);
            obj.message_type     = 1;
            obj.package_id       = tx300.PackageID;
            obj.protocol_type    = tx300.ProtocolType;
            obj.protocol_version = tx300.ProtocolVersion;
            obj.receive_time     = receiveTime;
            obj.sequence_id      = tx300.SequenceID.ToString();
            obj.server_port      = 31875;
            obj.terminal_id      = tx300.TerminalID;
            obj.terminal_type    = tx300.TerminalType;
            obj.total_length     = (short)tx300.TotalLength;
            obj.total_package    = tx300.TotalPackage;
            DataInstance.Add(obj);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Reads all valid entries(determined by DataReader) and stores values into a List[object]
 /// in our DataSet; paired with the attributes read in from the names file.
 /// </summary>
 private void BuildDataEntries(ref DataSet dataSet)
 {
     foreach(string entry in m_DataReader.ValidEntries()) {
         string[] data = entry.Split(',');
         if(data.Length != dataSet.Features.Count){
             Console.WriteLine("[Error]: Invalid # of data elements in {0}.", data.Select(s=>s.ToString(CultureInfo.InvariantCulture)));
             continue;
         }
         var instance = new DataInstance();
         for(int i=0; i<data.Length; i++) {
             if(IsValidValue(dataSet.Features[i].Type, data[i], dataSet.Features[i].PossibleValues.ToArray()))
                 instance.Add(data[i]);
         }
         if(instance.Count == dataSet.Features.Count)
             dataSet.DataEntries.Add(instance);
     }
 }