changeset 24:d0df32594874

add images
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Thu, 06 May 2021 16:47:35 +0900
parents 4d1009ff72c5
children d5db71167d90
files Paper/paper.pdf Paper/paper.tex
diffstat 2 files changed, 113 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
Binary file Paper/paper.pdf has changed
--- a/Paper/paper.tex	Thu May 06 16:14:15 2021 +0900
+++ b/Paper/paper.tex	Thu May 06 16:47:35 2021 +0900
@@ -291,17 +291,126 @@
 WordCountの例題は大きく分けて, 指定した名前のファイルをFIle構造体としてOpenするFileOpenスレッド, ファイル構造体を受け取り文字列(word)を表示し文字数(bytes)と行数(lines)をCountUpするWordCountスレッドの二つのCodeGearで記述することができる.  
 図\ref{fig:WCGearbox}で示したWordCountの遷移図はFileをオープンしたCGとWordCountのCGを巡回することにより, 
 
-
+ \ref{codes: StartHelloCG}
+  \ref{fig:WCStates}
+  \ref{fig:WCDGMwChristie}
+  
 \begin{figure}[tb]
     \begin{center}
-        \includegraphics[width=80mm]{images/wordCountGearBox.pdf}
+        \includegraphics[width=80mm]{images/wordCountStates.pdf}
     \end{center}
-    \caption{WordCount with Gearbox}
-    \label{fig:WCGearbox}
+    \caption{WordCount with CbC}
+    \label{fig:WCStates}
 \end{figure}
 
 
 
+\begin{lstlisting}[frame=lrbt,label=codes: UnixFI,caption={UnixFileImpl.cbc}]
+#include <stdio.h>
+#impl UnixFileImp as "UnixFileImpl.h"
+
+
+File* createUnixFileImpl(struct Context* context) {
+    File *file = new File();
+    file->FileImpl = (union Data*)new FileImpl();
+    return file;
+}
+
+readBlock(UnixFileImpl* file) {
+   Block *block = new Block();
+   int len = read(fd, BUFSIZE, block->data);
+   block->eof &= ~BLOCK_FLAG_EOF;
+   if (len <=0 ) {
+       block->eof |= BLOCK_FLAG_EOF;
+       close(file->fd);
+   } 
+   return block ;
+}
+
+__code unixOpen(UnixFileImpl* file,Key *key, __code next(Block *block,...));
+   file->fd = open(key->path,unix_mode(key->modde));
+   if (fd < 0) {
+       goto error("can't open");
+   }
+   goto next(readBlock(file), ...);
+}
+
+__code uniAck(UnixFileImpl* file,Ack *ack, __code next(Block *block,...));
+   if (!ack->isOk) {
+      close(file->fd);
+      goto next(...);
+   }
+   goto next(readBlock(file), ...);   // file is automaticaly put into local dataGearManger/input
+}
+\end{lstlisting}
+
+
+\begin{lstlisting}[frame=lrbt,label=codes: WCImple,caption={WcImpl.cbc}]
+#include "../../../context.h"
+#include <stdio.h>
+#impl "Wc.h" as "WcImpl.h"
+#interface "WcResult.h"
+
+Wc* createWcImpl(struct Context* context) {
+    Wc *wc = new Wc();
+    wc->wc = (union Data*)new WcImpl();
+    wc->bytes = 0;
+    wc->words = 0;
+    wc->lines = 0;
+    return wc;
+}
+
+__code take(Impl* wc, Block *block,__code next(Ack *ack, ...),__code finish(StdData *result,...) {
+    if (isEof(block->eof )) {
+        result.buffer = new Buffer(1);
+        result.buffer->data = new Byte(BUSIZE);
+        result.size = 1;
+        result.buffer->size = 
+            snprintf(result.buffer[0]->data, "%d %d %d\n",wc->bytes,wc->words,wc->lines);
+        goto finish(resut);
+    }
+    for(size_t i = 0 ; i<block->size; i++) {
+        if (block->data[i] == '\n') wc->lines++;
+        if (block->data[i] == ' ') {
+            wc->words++;
+            while(block->data[i] == ' ') {
+               if(i>=block->size) 
+                    goto next(ack,take);
+               i++;
+               wc->bytes++;
+            }
+        }
+        wc->bytes++;
+    }
+    goto next(ack,take);
+}
+\end{lstlisting}
+
+
+\begin{figure}[tb]
+    \begin{center}
+        \includegraphics[width=80mm]{images/wordCountDGM.pdf}
+    \end{center}
+    \caption{WordCountDGM with Christie}
+    \label{fig:WCDGMwChristie}
+\end{figure}
+
+
+\begin{figure}[tb]
+    \begin{center}
+        \includegraphics[width=80mm]{images/fileImplementation.pdf}
+    \end{center}
+    \caption{file Implementation}
+    \label{fig:fileImpletation}
+\end{figure}
+
+\begin{figure}[tb]
+    \begin{center}
+        \includegraphics[width=80mm]{images/filePersistency.pdf}
+    \end{center}
+    \caption{file Persistency}
+    \label{fig:filePersist}
+\end{figure}