Re: [protobuf] generate .proto file from C# code

2016-09-12 Thread Marc Gravell
That output is from protobuf-net, not protoc. I already showed the code to
ask protobuf-net to have a go at writing a .proto schema from a type. Note
that it is not perfect and you may want to tweak names etc to match
convention. But names don't matter much to protobuf.

On 12 Sep 2016 1:59 pm, "Gayatri Shah"  wrote:

> Thank you Marc.  Do you have sample of .proto file?  What did you have to
> do to make it compile? I just wrote few lines of .proto file and I m using 
> *protoc-3.0.0-win32.zip
> 
>  for
> compiler?   Can you also give me ur input (.proto file) for that you gout
> output *https://gist.github.com/mgravell/4967b490d40f13300919b018af23b282
>  .
>
> Thanks for your time.
>
>
> On Fri, Sep 9, 2016 at 7:08 PM, Marc Gravell 
> wrote:
>
>> You'd be best off creating it by hand, but if you want a starting point,
>> you can use protobuf-net to get some hints; add
>> [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] to your root
>> type (UAVState?), and use something like 
>> Console.WriteLine(Serializer.GetProto());
>> to see the content. I had to invent a lot of stuff to get it to compile,
>> but that gives output like https://gist.github.com/m
>> gravell/4967b490d40f13300919b018af23b282 - how useful this is for actual
>> serialization depends a lot on your system.
>>
>> On 7 September 2016 at 13:41, Gayatri Shah  wrote:
>>
>>> I am new to Protocol buffer.  I have huge file that is in C# and I want
>>> to convert that to protocol buffer definition.
>>>
>>> How do I do that?  Do i need to write Protocol definition line by line?
>>>
>>> See attached file (Anything marked as non-serialized could be omitted;
>>> pretty much anything that’s a list can be skipped.)
>>>
>>> thanks in advance.
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to protobuf+unsubscr...@googlegroups.com.
>>> To post to this group, send email to protobuf@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/protobuf.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Regards,
>>
>> Marc
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] generate .proto file from C# code

2016-09-12 Thread Gayatri Shah
Thank you Marc.  Do you have sample of .proto file?  What did you have to
do to make it compile? I just wrote few lines of .proto file and I m
using *protoc-3.0.0-win32.zip

for
compiler?   Can you also give me ur input (.proto file) for that you gout
output *https://gist.github.com/mgravell/4967b490d40f13300919b018af23b282 .

Thanks for your time.


On Fri, Sep 9, 2016 at 7:08 PM, Marc Gravell  wrote:

> You'd be best off creating it by hand, but if you want a starting point,
> you can use protobuf-net to get some hints; add
> [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] to your root
> type (UAVState?), and use something like Console.WriteLine(
> Serializer.GetProto()); to see the content. I had to invent a
> lot of stuff to get it to compile, but that gives output like
> https://gist.github.com/mgravell/4967b490d40f13300919b018af23b282 - how
> useful this is for actual serialization depends a lot on your system.
>
> On 7 September 2016 at 13:41, Gayatri Shah  wrote:
>
>> I am new to Protocol buffer.  I have huge file that is in C# and I want
>> to convert that to protocol buffer definition.
>>
>> How do I do that?  Do i need to write Protocol definition line by line?
>>
>> See attached file (Anything marked as non-serialized could be omitted;
>> pretty much anything that’s a list can be skipped.)
>>
>> thanks in advance.
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to protobuf+unsubscr...@googlegroups.com.
>> To post to this group, send email to protobuf@googlegroups.com.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Regards,
>
> Marc
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] generate .proto file from C# code

2016-09-09 Thread Marc Gravell
You'd be best off creating it by hand, but if you want a starting point,
you can use protobuf-net to get some hints; add
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] to your root
type (UAVState?), and use something
like Console.WriteLine(Serializer.GetProto()); to see the
content. I had to invent a lot of stuff to get it to compile, but that
gives output like
https://gist.github.com/mgravell/4967b490d40f13300919b018af23b282 - how
useful this is for actual serialization depends a lot on your system.

On 7 September 2016 at 13:41, Gayatri Shah  wrote:

> I am new to Protocol buffer.  I have huge file that is in C# and I want to
> convert that to protocol buffer definition.
>
> How do I do that?  Do i need to write Protocol definition line by line?
>
> See attached file (Anything marked as non-serialized could be omitted;
> pretty much anything that’s a list can be skipped.)
>
> thanks in advance.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] generate .proto file from C# code

2016-09-09 Thread Gayatri Shah
I am new to Protocol buffer.  I have huge file that is in C# and I want to 
convert that to protocol buffer definition.  

How do I do that?  Do i need to write Protocol definition line by line?  

See attached file (Anything marked as non-serialized could be omitted; 
pretty much anything that’s a list can be skipped.) 

thanks in advance.


 

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Threading;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using SOI;
using gtri_uav;
using System.Runtime.CompilerServices;

using LatLonAltTuple = System.Tuple;
using LatLonAltRadiusTuple = System.Tuple;
using IDRGBTuple = System.Tuple;
using System.Threading.Tasks;
using System.ComponentModel;

namespace SOIComms
{
public enum AutonomyMode
{
MANUAL = 0,
PICCOLO = 1,
PAYLOAD = 2,
NOT_CONNECTED = 255
}

public enum UAVCondition
{
GOOD,
CAUTION,
ERROR,
INVALID,
UNKNOWN
};

[Serializable]
public struct AutonomyVersions
{
public uint AutonomyVersionHash;
public uint AutopilotBoardSerialNum;
public byte AutopilotSoftwareVersionMajor;
public byte AutopilotSoftwareVersionMinor;
public byte AutopilotSoftwareVersionSubversion;
public byte AutopilotSoftwareVersionPatch;

public AutonomyVersions(uint autonomyVersionHash, uint autopilotBoardSerialNum, byte autopilotSoftwareVersionMajor, byte autopilotSoftwareVersionMinor,
byte autopilotSoftwareVersionSubversion, byte autopilotSoftwareVersionPatch)
{
AutonomyVersionHash = autonomyVersionHash;
AutopilotBoardSerialNum = autopilotBoardSerialNum;
AutopilotSoftwareVersionMajor = autopilotSoftwareVersionMajor;
AutopilotSoftwareVersionMinor = autopilotSoftwareVersionMinor;
AutopilotSoftwareVersionSubversion = autopilotSoftwareVersionSubversion;
AutopilotSoftwareVersionPatch = autopilotSoftwareVersionPatch;
}

public AutonomyVersions(AutonomyVersions a)
{
AutonomyVersionHash = a.AutonomyVersionHash;
AutopilotBoardSerialNum = a.AutopilotBoardSerialNum;
AutopilotSoftwareVersionMajor = a.AutopilotSoftwareVersionMajor;
AutopilotSoftwareVersionMinor = a.AutopilotSoftwareVersionMinor;
AutopilotSoftwareVersionSubversion = a.AutopilotSoftwareVersionSubversion;
AutopilotSoftwareVersionPatch = a.AutopilotSoftwareVersionPatch;
}
}

[Serializable]
public class UAVState : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

private void setFlying()
{
if (RPM >= 0)
{
const int TIME_BETWEEN_STATE_CHANGE_AND_TAKEOFF_S = 9;
LaunchTime = DateTime.Now.Subtract(new TimeSpan(0, 0, TIME_BETWEEN_STATE_CHANGE_AND_TAKEOFF_S));
LaunchTimeSet = true;

if (m_timerChangeDelegate != null)
{
m_timerChangeDelegate(true, this);
}
}
}

public static float getPositionUpdatesPerSecond(float seconds, List positionUpdateTimes, DateTime serverTime)
{
List times = positionUpdateTimes.Where(d => serverTime.Subtract(d).TotalSeconds <= seconds).ToList();
return times.Count / seconds;
}
public static float getPositionUpdatesPerSecond(float span, float divisor, List positionUpdateTimes, DateTime serverTime)
{
List times = positionUpdateTimes.Where(d => serverTime.Subtract(d).TotalSeconds <= span).ToList();
return times.Count / divisor;
}

#region Member Vars

#region Serialized Vars

private int m_ID = 0;
public int ID { get { retu