コード例 #1
0
ファイル: DataSerializer.cs プロジェクト: pavkam/school
        public static Int32 Serialize(StringBuilder toBuilder, ScalarSet scalarSet)
        {
            Int32 preCount = toBuilder.Length;

            /* Group Id */
            toBuilder.Append(scalarSet.Id);
            toBuilder.Append(':');
            toBuilder.Append(scalarSet.Count);
            toBuilder.Append(':');

            /* Each parameter */
            foreach (Object o in scalarSet.AsInvokeParameters)
            {
                /* Append type first */
                if (o is Byte) { toBuilder.Append("u8>"); toBuilder.Append((Byte)o); toBuilder.Append("<"); }
                else if (o is SByte) { toBuilder.Append("i8>"); toBuilder.Append((SByte)o); toBuilder.Append("<"); }
                else if (o is UInt16) { toBuilder.Append("u16>"); toBuilder.Append((UInt16)o); toBuilder.Append("<"); }
                else if (o is Int16) { toBuilder.Append("i16>"); toBuilder.Append((Int16)o); toBuilder.Append("<"); }
                else if (o is UInt32) { toBuilder.Append("u32>"); toBuilder.Append((UInt32)o); toBuilder.Append("<"); }
                else if (o is Int32) { toBuilder.Append("i32>"); toBuilder.Append((Int32)o); toBuilder.Append("<"); }
                else if (o is UInt64) { toBuilder.Append("u64>"); toBuilder.Append((UInt64)o); toBuilder.Append("<"); }
                else if (o is Int64) { toBuilder.Append("i64>"); toBuilder.Append((Int64)o); toBuilder.Append("<"); }
                else if (o is Single) { toBuilder.Append("sf>"); toBuilder.Append(((Single)o).ToString(System.Globalization.CultureInfo.InvariantCulture)); toBuilder.Append("<"); }
                else if (o is Double) { toBuilder.Append("df>"); toBuilder.Append(((Double)o).ToString(System.Globalization.CultureInfo.InvariantCulture)); toBuilder.Append("<"); }
                else if (o is String) { toBuilder.Append("s>"); toBuilder.Append(((String)o).Length); toBuilder.Append(">"); toBuilder.Append((String)o); }
                else
                {
                    return -1;
                }
            }

            return toBuilder.Length - preCount;
        }
コード例 #2
0
ファイル: DataSerializer.cs プロジェクト: pavkam/school
        /// <summary>
        /// Initializes a new instance of the <see cref="DataSerializer"/> class.
        /// </summary>
        /// <param name="sets">The sets.</param>
        public DataSerializer(ScalarSet[] sets)
        {
            if (sets == null)
                throw new ArgumentNullException("sets");

            if (sets.Length == 0)
                throw new ArgumentException("sets");

            m_Sets = sets;
        }
コード例 #3
0
ファイル: WorkQueueItem.cs プロジェクト: pavkam/school
        /// <summary>
        /// Initializes a new instance of the <see cref="WorkQueueItem"/> class.
        /// </summary>
        /// <param name="compiledScript">The compiled script.</param>
        /// <param name="script">The script.</param>
        /// <param name="scalarSet">The scalar set.</param>
        public WorkQueueItem(ICompiledScript compiledScript, IScript script, ScalarSet scalarSet)
        {
            if (compiledScript == null)
                throw new ArgumentNullException("compiledScript");

            if (script == null)
                throw new ArgumentNullException("script");

            if (scalarSet == null)
                throw new ArgumentNullException("scalarSet");

            m_CompiledScript = compiledScript;
            m_InputSet = scalarSet;
            m_Script = script;
        }
コード例 #4
0
ファイル: DotNetCompiledScript.cs プロジェクト: pavkam/school
        /// <summary>
        /// Executes the specified script.
        /// </summary>
        /// <param name="set">The set to use as input.</param>
        /// <returns>Output result set</returns>
        public ScalarSet Execute(ScalarSet set)
        {
            if (set == null)
                throw new ArgumentNullException("set");

            Object result = m_RemoteCall.__CallRemotely(m_MethodName, set.AsInvokeParameters);

            if (result == null)
            {
                return null;
            }

            /* Check for basic types */
            if (result is Byte || result is SByte || result is Int16 || result is UInt16 ||
                result is Int32 || result is UInt32 || result is Int64 || result is UInt64 || result is Single ||
                result is Double || result is String)
                return new ScalarSet(set.Id, result);
            else if (result is Object[])
                return new ScalarSet(set.Id, (Object[])result);
            else return null;
        }
コード例 #5
0
ファイル: TcpRemoteGateClient.cs プロジェクト: pavkam/school
        /// <summary>
        /// Operation DATAIN.
        /// </summary>
        /// <param name="clientId">The client id.</param>
        /// <param name="scriptId">The script id.</param>
        /// <param name="sets">The sets.</param>
        /// <returns></returns>
        private Boolean Operation_DATAIN(String clientId, String scriptId, ScalarSet[] sets)
        {
            XPortCommBody response = ContactServer("DATAIN", sets, clientId, scriptId);

            if (response != null && response.Code.Equals("DATAINED"))
            {
                return true;
            }

            return false;
        }
コード例 #6
0
ファイル: TcpRemoteGateClient.cs プロジェクト: pavkam/school
 /// <summary>
 /// Contacts the server.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="sets">The sets.</param>
 /// <param name="clientId">The client id.</param>
 /// <param name="scriptId">The script id.</param>
 /// <returns></returns>
 private XPortCommBody ContactServer(String operation, ScalarSet[] sets, String clientId, String scriptId)
 {
     return ContactServerWithParams(operation, new String[] { clientId, scriptId }, new DataSerializer(sets).Serialize());
 }
コード例 #7
0
ファイル: TcpRemoteGateClient.cs プロジェクト: pavkam/school
        /// <summary>
        /// Queues some work to be done remotely.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="set">The set.</param>
        /// <returns></returns>
        public Boolean AsyncQueueWork(IScript script, ScalarSet set)
        {
            if (script == null)
                throw new ArgumentNullException("script");

            if (set == null)
                throw new ArgumentNullException("set");

            lock (m_SyncRoot)
            {
                if (m_ClientId == null)
                    return false;

                /* Put the script into a queue */
                m_DataRegistry.Place(script, set);

                return true;
            }
        }
コード例 #8
0
ファイル: MMatrixAlgorithm.cs プロジェクト: pavkam/school
        /// <summary>
        /// Returns the output set to the algorithm.
        /// </summary>
        /// <param name="set">The set.</param>
        /// <param name="setNumber">The set number.</param>
        public void ReceiveOutputSet(ScalarSet set, Int32 setNumber)
        {
            if (set == null)
                throw new ArgumentNullException("set");

            if (set.Count != 1)
                throw new ArgumentException("set");

            /* Find the row and column this cell */
            Int32 row = (setNumber / m_Matrix2X);
            Int32 col = (setNumber % m_Matrix2X);

            m_ResultMatrix[col, row] = (Double)set[0];
        }
コード例 #9
0
ファイル: DynAlgorithm.cs プロジェクト: pavkam/school
        /// <summary>
        /// Returns the output set to the algorithm.
        /// </summary>
        /// <param name="set">The set.</param>
        /// <param name="setNumber">The set number.</param>
        public void ReceiveOutputSet(ScalarSet set, Int32 setNumber)
        {
            foreach (Object r in set.AsInvokeParameters)
            {
                m_Results.Append(r.ToString());
                m_Results.Append("    ");
            }

            m_Results.Append(Environment.NewLine);
        }
コード例 #10
0
ファイル: QueueEventArgs.cs プロジェクト: pavkam/school
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueEventArgs"/> class.
 /// </summary>
 /// <param name="outSet">The out set.</param>
 /// <param name="setId">The set id.</param>
 internal QueueEventArgs(ScalarSet outSet, Int32 setId)
 {
     m_OutSet = outSet;
     m_SetId = setId;
 }
コード例 #11
0
ファイル: RemoteMachineRunner.cs プロジェクト: pavkam/school
        /// <summary>
        /// Queues work to be done.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="inputSet">The input set.</param>
        /// <returns></returns>
        public Boolean QueueWork(IScript script, ScalarSet inputSet)
        {
            if (script == null)
                throw new ArgumentNullException("script");

            if (inputSet == null)
                throw new ArgumentNullException("inputSet");

            lock (m_SyncRoot)
            {
                return m_Gate.AsyncQueueWork(script, inputSet);
            }
        }
コード例 #12
0
ファイル: EchoAlgorithm.cs プロジェクト: pavkam/school
 /// <summary>
 /// Returns the output set to the algorithm.
 /// </summary>
 /// <param name="set">The set.</param>
 /// <param name="setNumber">The set number.</param>
 public void ReceiveOutputSet(ScalarSet set, Int32 setNumber)
 {
 }
コード例 #13
0
ファイル: HttpRemoteGateClient.cs プロジェクト: pavkam/school
 /// <summary>
 /// Contacts the server.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="sets">The sets.</param>
 /// <param name="clientId">The client id.</param>
 /// <param name="scriptId">The script id.</param>
 /// <returns></returns>
 private XPortCommBody ContactServer(String operation, ScalarSet[] sets, String clientId, String scriptId)
 {
     return ContactServerWithParams(operation, String.Format("id={0}&sid={1}",
         Uri.EscapeDataString(clientId), Uri.EscapeDataString(scriptId)), new DataSerializer(sets).Serialize());
 }
コード例 #14
0
ファイル: WorkQueue.cs プロジェクト: pavkam/school
        /// <summary>
        /// Queues the evaluation of a script.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="compiledScript">The compiled script.</param>
        /// <param name="inputSet">The input set.</param>
        public void QueueEvaluation(IScript script, ICompiledScript compiledScript, ScalarSet inputSet)
        {
            if (script == null)
                throw new ArgumentNullException("script");

            if (compiledScript == null)
                throw new ArgumentNullException("compiledScript");

            if (inputSet == null)
                throw new ArgumentNullException("inputSet");

            lock (m_SyncRoot)
            {
                m_Queue.Add(new WorkQueueItem(compiledScript, script, inputSet));
            }
        }
コード例 #15
0
ファイル: ScriptQueueEventArgs.cs プロジェクト: pavkam/school
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueEventArgs"/> class.
 /// </summary>
 /// <param name="script">The script.</param>
 /// <param name="outSet">The out set.</param>
 /// <param name="setId">The set id.</param>
 internal ScriptQueueEventArgs(IScript script, ScalarSet outSet, Int32 setId)
 {
     m_OutSet = outSet;
     m_SetId = setId;
     m_Script = script;
 }