2016-09-24 68 views
0

尝试读取新生成的过程输出,当我达到一个无法解释的行为 -未能获得过程输出C#

这是我使用的代码:

p.StartInfo.Arguments += "-o Kd.pddl -f Kp.pddl";   
    StreamWriter planeWriter = new StreamWriter(m_planStream); 
    p.StartInfo.UseShellExecute = false; 
    p.StartInfo.RedirectStandardOutput = true; 
    p.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); 
    p.OutputDataReceived += (sender, args) => planeWriter.WriteLine(args.Data); 
    p.Start(); 

    p.BeginOutputReadLine(); 
    p.WaitForExit(); 
    m_planStream.Position = 0; 
    StreamReader planReader = new StreamReader(m_planStream); 
    m_sFFOutput = planReader.ReadToEnd(); 
    List<string> lPlan = new List<string>(); 
    Console.WriteLine(m_sFFOutput); 

这是很简单的,对于大多数产出来说,这就是为什么我说这是无法解释的原因。

我每次都用不同的输入(Kd.pddl和K​​p.pddl)加载程序。 对于一些投入它的一切正常,但对于一些投入,我无法得到任何输出。 在任何情况下都有输出,因为我也手动运行它,对于具有不同输出的不同输入,我能够检索输出。

即使当我坚持和错误的参数 - 我得到的程序输出。

可以使用一些有关这方面的见解,我相当新的C#。

示例输出我无法找回(得到这个直通程序的手动运行):

ff: parsing domain file 
domain 'KTRIANGLE_TIREWORLD_POMDP' defined 
... done. 
ff: parsing problem file 
problem 'KTRIANGLE_TIREWORLD_INST_POMDP__1' defined 
... done. 



Cueing down from goal distance: 3 into depth [1] 
            2   [1] 
            1   [1] 
            0 

ff: found legal plan as follows 

step 0: MOVE_CAR__LA1A1_LA1A2 
     1: MOVE_CAR__LA1A2_LA1A3 
     2: CHANGETIRE 


time spent: 0.00 seconds instantiating 44 easy, 0 hard action templates 
       0.00 seconds reachability analysis, yielding 19 facts and 44 actions 
       0.00 seconds creating final representation with 18 relevant facts 
       0.00 seconds building connectivity graph 
       0.00 seconds searching, evaluating 4 states, to a max depth of 1 
       0.00 seconds total time 

,当我坚持一个随机的信错误的论点,我得到这个输出,一个我我能够找回它:

usage of ff: 

OPTIONS DESCRIPTIONS 

-p <str> path for operator and fact file 
-o <str> operator file name 
-f <str> fact file name 

-i <num> run-time information level(preset: 1) 
     0  only times 
     1  problem name, planning process infos 
    101  parsed problem data 
    102  cleaned up ADL problem 
    103  collected string tables 
    104  encoded domain 
    105  predicates inertia info 
    106  splitted initial state 
    107  domain with Wff s normalized 
    108  domain with NOT conds translated 
    109  splitted domain 
    110  cleaned up easy domain 
    111  unaries encoded easy domain 
    112  effects multiplied easy domain 
    113  inertia removed easy domain 
    114  easy action templates 
    115  cleaned up hard domain representation 
    116  mixed hard domain representation 
    117  final hard domain representation 
    118  reachability analysis results 
    119  facts selected as relevant 
    120  final domain and problem representations 
    121  connectivity graph 
    122  fixpoint result on each evaluated state 
    123  1P extracted on each evaluated state 
    124  H set collected for each evaluated state 
    125  False sets of goals <GAM> 
    126  detected ordering constraints leq_h <GAM> 
    127  the Goal Agenda <GAM> 

-d <num> switch on debugging 
+0

您开始的程序是否总是写入标准输出,或者有时写入标准错误?这将解释你为什么没有得到任何东西。 – Pezo

+0

不,总是标准的,唯一的区别是我可以找到“工作”和不工作的输出之间的工作是稍长,但只有约5行左右。 而且总是有输出。 –

+1

你可以在从'm_planStream'读取之前尝试刷新'planWriter' – Pezo

回答

1

你需要从m_planStream阅读前冲洗planWriter