无法获得c#过程输出

本文关键字:过程 输出 | 更新日期: 2023-09-27 18:08:41

在尝试读取新生成的进程输出时遇到无法解释的行为-

这是我使用的代码:

    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和Kp.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

无法获得c#过程输出

在读取m_planStream之前需要冲洗planWriter