Changeset 18 in Main


Ignore:
Timestamp:
26/11/2011 09:26:12 (18 months ago)
Author:
duggan
Message:

Now loads topology data. A sample topology file has been included. To use, copy to output dir for executable.

Location:
src/fake_app_server
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/fake_app_server/App.cpp

    r16 r18  
    1212        if (LoadTopology("topology.txt") != B_OK) 
    1313        { 
     14                status = B_ERROR; 
    1415        } 
    1516        // TODO: create framebuffers and windows to display them 
     
    3334                        // connected(0/1) : number of resolutions : default / current resolution index : widthxheightxbpp@refresh : ... <-- one for each head 
    3435                        file.getline(rawline, 1024); 
    35                         line = rawline; 
    36                         // TODO: fix this if statement (skips any line that has a '#' in it, regardless of location) 
    37                         if (line.FindFirst("#") != B_ERROR) 
     36                        // TODO: implement a Trim function 
     37                        if (rawline[0] == '#' || rawline[0] == '\n') 
    3838                        { 
    3939                                continue; 
    4040                        } 
    41                         // get everything up to the first ':' 
    42                         BString temp(""); 
     41                        line = rawline; 
     42                        BString temp; 
     43                        uint32 slotnum; 
    4344                        line.MoveInto(temp, 0, line.FindFirst(":")); 
    4445                        line.RemoveFirst(":"); 
     46                        slotnum = atoi(temp.String()); 
     47                        cout<<"slotnum: "<<slotnum<<endl; 
     48                        line.MoveInto(temp, 0, line.FindFirst(":")); 
     49                        line.RemoveFirst(":"); 
     50                        Devices[slotnum].HeadCount = atoi(temp.String()); 
     51                        cout<<"headcount: "<<Devices[slotnum].HeadCount<<endl; 
     52                        Devices[slotnum].Heads = new Head[Devices[slotnum].HeadCount]; 
     53                        Devices[slotnum].DeviceID = line; 
     54                        cout<<"deviceid: "<<Devices[slotnum].DeviceID<<endl; 
     55                        for(int a = 0 ; a < Devices[slotnum].HeadCount ; a++) 
     56                        { 
     57                                do 
     58                                { 
     59                                        file.getline(rawline, 1024); 
     60                                } while (rawline[0] == '#' || rawline[0] == '\n'); 
     61                                line = rawline; 
     62                                line.MoveInto(temp, 0, line.FindFirst(":")); 
     63                                line.RemoveFirst(":"); 
     64                                if (atoi(temp.String()) == 0) 
     65                                { 
     66                                        Devices[slotnum].Heads[a].Connected = false; 
     67                                } 
     68                                else 
     69                                { 
     70                                        Devices[slotnum].Heads[a].Connected = true; 
     71                                } 
     72                                cout<<"connected: "<<Devices[slotnum].Heads[a].Connected<<endl; 
     73                                line.MoveInto(temp, 0, line.FindFirst(":")); 
     74                                line.RemoveFirst(":"); 
     75                                Devices[slotnum].Heads[a].ResolutionCount = atoi(temp.String()); 
     76                                cout<<"rescount: "<<Devices[slotnum].Heads[a].ResolutionCount<<endl; 
     77                                Devices[slotnum].Heads[a].Resolutions = new Resolution[Devices[slotnum].Heads[a].ResolutionCount]; 
     78                                line.MoveInto(temp, 0, line.FindFirst(":")); 
     79                                line.RemoveFirst(":"); 
     80                                Devices[slotnum].Heads[a].CurrentResolution = atoi(temp.String()); 
     81                                cout<<"current: "<<Devices[slotnum].Heads[a].CurrentResolution<<endl; 
     82                                for (int b = 0; b < Devices[slotnum].Heads[a].ResolutionCount; b++) 
     83                                { 
     84                                        if (line.FindFirst(":") != B_ERROR) 
     85                                        { 
     86                                                line.MoveInto(temp, 0, line.FindFirst(":")); 
     87                                                line.RemoveFirst(":"); 
     88                                        } 
     89                                        else 
     90                                        { 
     91                                                temp = line; 
     92                                        } 
     93                                        BString temp2; 
     94                                        temp.MoveInto(temp2, 0, line.FindFirst("x")); 
     95                                        temp.RemoveFirst("x"); 
     96                                        Devices[slotnum].Heads[a].Resolutions[b].Width = atoi(temp2.String()); 
     97                                        temp.MoveInto(temp2, 0, line.FindFirst("x")); 
     98                                        temp.RemoveFirst("x"); 
     99                                        Devices[slotnum].Heads[a].Resolutions[b].Height = atoi(temp2.String()); 
     100                                        temp.MoveInto(temp2, 0, line.FindFirst("@")); 
     101                                        temp.RemoveFirst("@"); 
     102                                        Devices[slotnum].Heads[a].Resolutions[b].BPP = atoi(temp2.String()); 
     103                                        Devices[slotnum].Heads[a].Resolutions[b].Refresh = atoi(temp.String()); 
     104                                } 
     105                        } 
    45106                } 
     107        } 
     108        else 
     109        { 
     110                // File not found 
     111                return B_ERROR; 
    46112        } 
    47113        return B_OK; 
    48114} 
     115 
     116status_t 
     117App::Status() 
     118{ 
     119        return status; 
     120} 
  • src/fake_app_server/App.h

    r17 r18  
    1515#include <iostream> 
    1616#include <fstream> 
     17#include <stdlib.h> 
     18 
     19#define MAX_SLOTS 8 
    1720 
    1821 
     
    3033        bool Connected; 
    3134        uint32 ResolutionCount; 
    32         Resolution* ResolutionList; 
     35        uint32 CurrentResolution; 
     36        Resolution* Resolutions; 
    3337}; 
    3438 
     
    3640struct Device 
    3741{ 
    38         uint32 Slot; 
    3942        uint32 HeadCount; 
    4043        BString DeviceID; 
    41         HeadData* Heads; 
     44        Head* Heads; 
    4245}; 
    4346 
     
    4649public: 
    4750        App(void); 
     51        status_t        Status(); 
    4852 
    4953private: 
    5054        status_t LoadTopology(BString); 
    51         Device* Devices; 
     55        Device Devices[MAX_SLOTS]; 
     56        status_t        status; 
    5257}; 
    5358 
  • src/fake_app_server/main.cpp

    r14 r18  
    1515{ 
    1616        App* app = new App(); 
    17         app->Run(); 
     17        if (app->Status() == B_OK) 
     18        { 
     19                app->Run(); 
     20        } 
    1821/* 
    1922// TODO: PUT THIS IN ANOTHER THREAD (probably from within App) 
Note: See TracChangeset for help on using the changeset viewer.