CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2007
    Posts
    36

    How to save a "scenario" to a file to load later

    Hi, hope you guys can help me with this.

    Im creating a GUI that will interface with an embedded board.
    Heres what i got so far:


    I got an GUI with several checkboxs that correspond to a "byte". The byte is represented by 8 checkboxes and depending what the user checks, the bit get turn on or off. I have several of this, lets call them "Start Byte, Status Byte, Parameters Byte.. etc ). When the user is done, he hits send and a byte[] buffer is created based of the setting of the form. This "message" gets sent via the serial port.

    What i dont know how to do is to lets say have a "record" mode. In this mode the user will do the same; set the bytes, choose his options and hit send, however the user might have several different paramentes he wants to set, he might want to send several of these "messages" one after another, therefore creating an "scenario". So instead of sending ths stuff everytime he hits send, i need to save the message in a buffer, then when hes done save all into a file.

    In the load mode, he would load this file, ( scenario ) and when he hits send , all the saved "messages" need to be sent out to the target board.

    Hope im clear. Any ideas on how to approach this?

  2. #2
    Join Date
    Mar 2004
    Location
    Ukraine
    Posts
    170

    Re: How to save a "scenario" to a file to load later

    Your scenario will be divided into records.
    when user hit send record will be added to scenario.
    Also you may add to file data after each user click
    God could improve essentially a
    human nature, but he
    was too anxious with compatibility
    with the monkey.
    (Eugeny Goldberg)

  3. #3
    Join Date
    Jun 2007
    Posts
    36

    Re: How to save a "scenario" to a file to load later

    Yes, i was thinking on that but my question doubt is how the save and load from a file. Are "records" a class containing the message, or can i just save the byte buffer directly into a file.

  4. #4
    Join Date
    Mar 2004
    Location
    Ukraine
    Posts
    170

    Re: How to save a "scenario" to a file to load later

    both ways are nice. But if you need easy develop yur software the better idea will be a class that will record messages and save/load them from file. Maybe good idea will be to put it in personal dll file
    God could improve essentially a
    human nature, but he
    was too anxious with compatibility
    with the monkey.
    (Eugeny Goldberg)

  5. #5
    Join Date
    Jun 2007
    Posts
    36

    Re: How to save a "scenario" to a file to load later

    The problem with a class, is that i send to them the "raw" data. I mean they are expecting bits and bytes format that is defined.

    as in if the first byte is 11011110, each bit means something.

    Correct me if im wrong, but if make a class, make it serialzable (sp?) when i send it out via the serial the port, it will arrive as an encapsulation of the class with the data members in there, but not the actualy "byte" data...?


    is it possible to Queue the byte[] as?

    here my idea in pseudo code.
    Code:
    byte[] buffer = new byte[] {.......}
    
    Queue myQueue = new Queue();
    
    myQueue.Enqueue(buffer);
    and so on.

  6. #6
    Join Date
    Mar 2004
    Location
    Ukraine
    Posts
    170

    Re: How to save a "scenario" to a file to load later

    I mean that its not necessesary to send a class yes you will send raw data. but class for writing scenario will be a storage for raw data, and will give you options to save and load scenario files.
    God could improve essentially a
    human nature, but he
    was too anxious with compatibility
    with the monkey.
    (Eugeny Goldberg)

  7. #7
    Join Date
    Jun 2007
    Posts
    36

    Re: How to save a "scenario" to a file to load later

    Guess im not familiar with load and saving data to files yet.

    Can you point me out what classes do i use to say, i have myData Class that stores all the raw data.

    How do i save this to an scenario and to a file to load later?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured