Coder Social home page Coder Social logo

Comments (14)

armink avatar armink commented on July 26, 2024

程序一般做法为删除之前的 9:00-10:00 的数据

from flashdb.

eggcar avatar eggcar commented on July 26, 2024

建议用单调时钟作为时间戳,不要直接用系统时间

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

程序一般做法为删除之前的 9:00-10:00 的数据

如果用所谓的单调时间而不是系统时间,那么通过数据的时间查询就没有意义了

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

程序一般做法为删除之前的 9:00-10:00 的数据

按照你之前的回答,不能直接删除数据,所谓删除只能是修改tsl的状态,是吗?

from flashdb.

armink avatar armink commented on July 26, 2024

程序一般做法为删除之前的 9:00-10:00 的数据

按照你之前的回答,不能直接删除数据,所谓删除只能是修改tsl的状态,是吗?

是的,改为删除状态,应用用的时候就可以有所区分

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

谢谢朱工!

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

朱工你好,请问,是否是这样做:
static bool set_status_cb(fdb_tsl_t tsl, void *arg)
{
fdb_tsdb_t db = arg;

FDB_INFO("set the TSL (time %ld) status from %d to %d\n", tsl->time, tsl->status, FDB_TSL_USER_STATUS1);
fdb_tsl_set_status(db, tsl, FDB_TSL_USER_STATUS1);

return false;

}

static void delete_preTime_hisData(uint32_t tsl_time,uint8_t datatype)
{
uint32_t Last_tsl_time = 0;

/* read last saved time for simulated timestamp */
 fdb_tsdb_control(&RainHs_tsdb, FDB_TSDB_CTRL_GET_LAST_TIME, &Last_tsl_time);
if (tsl_time < Last_tsl_time)
{
	fdb_tsl_iter_by_time(&RainHs_tsdb, tsl_time-1, Last_tsl_time, set_status_cb, &RainHs_tsdb);
}	

}

然后在每次运行插入tsl前,首先判断时间,如果小于上一条记录时间,就删除:
delete_preTime_hisData(RainHs_tsdb.get_time(),Rain);
result = fdb_tsl_append(&RainHs_tsdb, fdb_blob_make(&blob, p_element, sizeof(hrv_history_key)));

---请问,朱工,以上的流程对吗?

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

另外一个问题,如果不删除之前的数据会导致什么后果?因为如果是日志信息,所有的我都不想删除。

from flashdb.

armink avatar armink commented on July 26, 2024
  • 1、删除不是用 FDB_TSL_USER_STATUS1 而是用 FDB_TSL_DELETE
  • 2、在每次运行插入tsl前都判断会不会有些繁琐,第一次启动时候判断下应该就行了
  • 3、不删除会导致数据库时间轴出现紊乱,查询的结果也会乱套
  • 4、如果只是日志,可以不用设置 RTC 时间戳,参考我前两天新改的 demo,每次启动时,读取上次保存的 last_time ,这样是可以保证记录的有序性

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

朱工你好,谢谢你的回复,你在例程中这样写道:

  • NOTE: The actions to modify the state must be in order.
    * FDB_TSL_WRITE -> FDB_TSL_USER_STATUS1 -> FDB_TSL_DELETED -> FDB_TSL_USER_STATUS2
    是否必须按照这个顺序来设置TSL的状态,比如需要设置tsl为 FDB_TSL_DELETED ,首先要设置为FDB_TSL_USER_STATUS1,再次设置FDB_TSL_DELETED?

from flashdb.

armink avatar armink commented on July 26, 2024

是得按照顺序,但可以跳过中间状态

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

嗯,好的,谢谢朱工!
FlashDB很好用,在其进行初始化时,需要对每一个secotr写一个控制信息,如果分区空间比较大,比如3M Bytes,那么初始化时间就比较长,有没有办法改进一下,以减少初始化时间?

from flashdb.

armink avatar armink commented on July 26, 2024

第一次格式化的时间好像没法省吧,这个也就只有第一次才存在问题

from flashdb.

xql923 avatar xql923 commented on July 26, 2024

第一次格式化的时间好像没法省吧,这个也就只有第一次才存在问题

谢谢朱工,谢谢!

from flashdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.